Spaces:
Runtime error
Runtime error
requirements.txt
Browse filesgradio
diffusers
torch
transformers
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from diffusers import StableDiffusionPipeline
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
# Charger le modèle Stable Diffusion
|
| 6 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
| 7 |
+
"runwayml/stable-diffusion-v1-5",
|
| 8 |
+
torch_dtype=torch.float16
|
| 9 |
+
).to("cuda" if torch.cuda.is_available() else "cpu")
|
| 10 |
+
|
| 11 |
+
def generate_image(prompt):
|
| 12 |
+
image = pipe(prompt).images[0]
|
| 13 |
+
return image
|
| 14 |
+
|
| 15 |
+
# Interface Gradio
|
| 16 |
+
with gr.Blocks() as demo:
|
| 17 |
+
gr.Markdown("<h1 style='color: #008000;'>B-ID Creativity Generator</h1>")
|
| 18 |
+
gr.Markdown("<p style='color: #0000FF;'>Génère des images style Business & Argent 🚀</p>")
|
| 19 |
+
|
| 20 |
+
with gr.Row():
|
| 21 |
+
prompt_input = gr.Textbox(label="Entrez votre prompt")
|
| 22 |
+
generate_btn = gr.Button("Générer l'image")
|
| 23 |
+
|
| 24 |
+
output_image = gr.Image(label="Image générée")
|
| 25 |
+
|
| 26 |
+
generate_btn.click(fn=generate_image, inputs=prompt_input, outputs=output_image)
|
| 27 |
+
|
| 28 |
+
demo.launch()
|