cforge42 commited on
Commit
4d7123e
·
verified ·
1 Parent(s): e8cb6ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -5
app.py CHANGED
@@ -1,8 +1,23 @@
1
  import gradio as gr
 
2
 
3
- # Load the interface without specifying examples in the load() method
4
- interface = gr.Interface.load("huggingface/osanseviero/BigGAN-deep-128")
5
 
6
- # To add examples, you would typically define the interface yourself,
7
- # but for a loaded interface, you just call the method without the extra args.
8
- interface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # Load the BigGAN model using the transformers pipeline
5
+ generator = pipeline("text-to-image", model="osanseviero/BigGAN-deep-128")
6
 
7
+ def generate_image(text_input):
8
+ """Generates an image from text using the BigGAN pipeline."""
9
+ # The pipeline's output is an image.
10
+ image = generator(text_input)["images"][0]
11
+ return image
12
+
13
+ # Create the Gradio interface directly
14
+ interface = gr.Interface(
15
+ fn=generate_image,
16
+ inputs=gr.Textbox(label="Enter a prompt"),
17
+ outputs=gr.Image(label="Generated Image"),
18
+ title="BigGAN ImageNet",
19
+ description="BigGAN text-to-image demo.",
20
+ examples=[["american robin"], ["ocean sunset"], ["cat in a hat"]]
21
+ )
22
+
23
+ interface.launch()