Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from diffusers import StableDiffusionPipeline
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
# Load the pre-trained Stable Diffusion model
|
| 6 |
+
model_id = "runwayml/stable-diffusion-v1-5"
|
| 7 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
| 8 |
+
pipe = pipe.to("cuda")
|
| 9 |
+
|
| 10 |
+
def generate_one_line_art(prompt):
|
| 11 |
+
# Generate an image based on the text prompt
|
| 12 |
+
image = pipe(prompt).images[0]
|
| 13 |
+
|
| 14 |
+
# Convert the image to a simple one-line art (this is a placeholder)
|
| 15 |
+
# In practice, you would need a more sophisticated method to convert the image to one-line art.
|
| 16 |
+
# For simplicity, we'll just return the generated image.
|
| 17 |
+
|
| 18 |
+
return image
|
| 19 |
+
|
| 20 |
+
# Define the Gradio interface
|
| 21 |
+
iface = gr.Interface(
|
| 22 |
+
fn=generate_one_line_art,
|
| 23 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter a text prompt..."),
|
| 24 |
+
outputs="image",
|
| 25 |
+
title="One-Line Art Generator",
|
| 26 |
+
description="Enter a text prompt to generate a simple one-line art."
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
# Launch the app
|
| 30 |
+
iface.launch()
|