Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,23 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
# Load the
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|