Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusers import DiffusionPipeline
|
2 |
+
import torch
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
|
5 |
+
# Vérifier si un GPU est disponible et l'utiliser si possible
|
6 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
7 |
+
|
8 |
+
# Charger le modèle
|
9 |
+
pipe = DiffusionPipeline.from_pretrained("XLabs-AI/flux-controlnet-canny").to(device)
|
10 |
+
|
11 |
+
# Définir le prompt
|
12 |
+
prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
|
13 |
+
|
14 |
+
# Générer l'image
|
15 |
+
image = pipe(prompt).images[0]
|
16 |
+
|
17 |
+
# Afficher l'image
|
18 |
+
plt.imshow(image)
|
19 |
+
plt.axis("off")
|
20 |
+
plt.show()
|