import gradio as gr from diffusers import StableDiffusionPipeline import torch # Load the model (you can replace this with the specific Kwai-Kolors/Kolors model if available) pipe = StableDiffusionPipeline.from_pretrained("Kwai-Kolors/Kolors") pipe.to("cuda" if torch.cuda.is_available() else "cpu") # Define function to generate image from text def generate_image(prompt): # Generate an image based on the provided text prompt image = pipe(prompt).images[0] return image # Create Gradio interface for chatbot interface = gr.Interface( fn=generate_image, inputs=gr.Textbox(label="Enter your prompt:"), outputs=gr.Image(type="pil"), live=True, title="Text-to-Image Generation", description="Enter a text prompt to generate a photorealistic image." ) # Launch the interface interface.launch()