Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,19 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
|
|
|
| 3 |
|
| 4 |
-
# Load the BigGAN model using the
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 =
|
| 11 |
return image
|
| 12 |
|
| 13 |
# Create the Gradio interface directly
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from diffusers import DiffusionPipeline
|
| 4 |
|
| 5 |
+
# Load the BigGAN model using the diffusers library
|
| 6 |
+
# The model type is "biggan", which is the correct pipeline to use.
|
| 7 |
+
# Move model to GPU if available for faster generation
|
| 8 |
+
pipeline = DiffusionPipeline.from_pretrained(
|
| 9 |
+
"osanseviero/BigGAN-deep-128",
|
| 10 |
+
use_auth_token=True
|
| 11 |
+
).to("cuda" if torch.cuda.is_available() else "cpu")
|
| 12 |
|
| 13 |
def generate_image(text_input):
|
| 14 |
+
"""Generates an image from text using the BigGAN diffusers pipeline."""
|
| 15 |
# The pipeline's output is an image.
|
| 16 |
+
image = pipeline(text_input).images[0]
|
| 17 |
return image
|
| 18 |
|
| 19 |
# Create the Gradio interface directly
|