Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
|
|
| 1 |
from diffusers import DiffusionPipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
generator = DiffusionPipeline.from_pretrained("CompVis/ldm-text2im-large-256")
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def generate(prompts):
|
| 8 |
images = generator(list(prompts)).images
|
| 9 |
return [images]
|
| 10 |
|
| 11 |
-
gr.Interface(generate,
|
| 12 |
"textbox",
|
| 13 |
"image",
|
| 14 |
batch=True,
|
| 15 |
max_batch_size=4 # Set the batch size based on your CPU/GPU memory
|
| 16 |
-
).queue()
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
from diffusers import DiffusionPipeline
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
generator = DiffusionPipeline.from_pretrained("CompVis/ldm-text2im-large-256")
|
| 6 |
+
# move to GPU if available
|
| 7 |
+
if torch.cuda.is_available():
|
| 8 |
+
generator = generator.to("cuda")
|
| 9 |
|
| 10 |
def generate(prompts):
|
| 11 |
images = generator(list(prompts)).images
|
| 12 |
return [images]
|
| 13 |
|
| 14 |
+
demo = gr.Interface(generate,
|
| 15 |
"textbox",
|
| 16 |
"image",
|
| 17 |
batch=True,
|
| 18 |
max_batch_size=4 # Set the batch size based on your CPU/GPU memory
|
| 19 |
+
).queue()
|
| 20 |
+
|
| 21 |
+
if __name__ == "__main__":
|
| 22 |
+
demo.launch()
|