DRDELATV commited on
Commit
b70d2c8
verified
1 Parent(s): c942bbe

Create app.py with image generation

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import StableDiffusionPipeline
3
+ import torch
4
+
5
+ pipe = StableDiffusionPipeline.from_pretrained(
6
+ "runwayml/stable-diffusion-v1-5",
7
+ torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
8
+ revision="fp16" if torch.cuda.is_available() else "main"
9
+ ).to("cuda" if torch.cuda.is_available() else "cpu")
10
+
11
+ def generar_imagen(prompt):
12
+ image = pipe(prompt).images[0]
13
+ return image
14
+
15
+ demo = gr.Interface(
16
+ fn=generar_imagen,
17
+ inputs=gr.Textbox(label="Descripci贸n de la imagen"),
18
+ outputs="image",
19
+ title="Generador de Im谩genes - DRDELATV",
20
+ description="Escribe una descripci贸n y genera una imagen con IA usando Stable Diffusion"
21
+ )
22
+
23
+ demo.launch()