dschandra commited on
Commit
6637607
·
verified ·
1 Parent(s): 9575f33

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
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()