import gradio as gr from diffusers import StableDiffusionPipeline import torch # Load the pre-trained Stable Diffusion model model_id = "runwayml/stable-diffusion-v1-5" pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16) pipe = pipe.to("cuda") def generate_one_line_art(prompt): # Generate an image based on the text prompt image = pipe(prompt).images[0] # Convert the image to a simple one-line art (this is a placeholder) # In practice, you would need a more sophisticated method to convert the image to one-line art. # For simplicity, we'll just return the generated image. return image # Define the Gradio interface iface = gr.Interface( fn=generate_one_line_art, inputs=gr.Textbox(lines=2, placeholder="Enter a text prompt..."), outputs="image", title="One-Line Art Generator", description="Enter a text prompt to generate a simple one-line art." ) # Launch the app iface.launch()