import gradio as gr from diffusers import DiffusionPipeline # Load the pretrained model pipeline = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo") # Define a function to use the model for prediction def predict(text_input): # Use the pipeline to make predictions output = pipeline(text_input) return output # Create a Gradio interface iface = gr.Interface( fn=predict, inputs=gr.Textbox(lines=5, label="Input Text"), outputs=gr.Image(type="numpy", label="Output Image"), title="Diffusion Pipeline App", description="Enter the text to get the model's predictions as an output image." ) # Launch the Gradio interface iface.launch()