Commit
·
1cb0342
1
Parent(s):
60bb516
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,21 @@
|
|
| 1 |
from diffusers import DiffusionPipeline
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
import torch
|
| 11 |
-
|
| 12 |
-
generator = torch.Generator("cuda").manual_seed(0)
|
| 13 |
-
|
| 14 |
-
image = pipeline(prompt, generator=generator).images[0]
|
| 15 |
-
image
|
|
|
|
| 1 |
from diffusers import DiffusionPipeline
|
| 2 |
|
| 3 |
+
def generate_image(prompt):
|
| 4 |
+
model_id = "runwayml/stable-diffusion-v1-5"
|
| 5 |
+
pipeline = DiffusionPipeline.from_pretrained(model_id)
|
| 6 |
+
pipeline = pipeline.to("cuda")
|
| 7 |
+
|
| 8 |
+
generator = torch.Generator("cuda").manual_seed(0)
|
| 9 |
+
image = pipeline(prompt, generator=generator).images[0]
|
| 10 |
+
|
| 11 |
+
return image
|
| 12 |
|
| 13 |
+
iface = gr.Interface(
|
| 14 |
+
fn=generate_image,
|
| 15 |
+
inputs="text",
|
| 16 |
+
outputs="image",
|
| 17 |
+
title="Diffusion d'images",
|
| 18 |
+
description="Générez des images à partir d'une description.",
|
| 19 |
+
)
|
| 20 |
|
| 21 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|