Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the text-to-image pipeline from Hugging Face
|
| 5 |
+
generator = pipeline('text-to-image', model="CompVis/stable-diffusion-v1-4")
|
| 6 |
+
|
| 7 |
+
def generate_image(description):
|
| 8 |
+
# Generate the image based on the description
|
| 9 |
+
image = generator(description)
|
| 10 |
+
return image[0]['image']
|
| 11 |
+
|
| 12 |
+
# Create the Gradio interface
|
| 13 |
+
interface = gr.Interface(
|
| 14 |
+
fn=generate_image,
|
| 15 |
+
inputs="text",
|
| 16 |
+
outputs="image",
|
| 17 |
+
title="Image Generator from Description",
|
| 18 |
+
description="Enter a text description and generate an image based on it."
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
# Launch the Gradio interface
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
interface.launch()
|