BAKULODid commited on
Commit
b6a660a
1 Parent(s): a1b8562

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import DiffusionPipeline
3
+ import torch
4
+
5
+ # Cargar el modelo de stable diffusion
6
+ pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-3-medium")
7
+
8
+ def generate_image(image, prompt, steps):
9
+ # Ajustar los parámetros de difusión
10
+ generator = torch.manual_seed(42)
11
+ result = pipeline(prompt=prompt, image=image, num_inference_steps=steps, generator=generator)
12
+ return result.images[0]
13
+
14
+ with gr.Blocks() as demo:
15
+ with gr.Row():
16
+ with gr.Column():
17
+ canvas = gr.Sketchpad(label="Dibuja aquí")
18
+ prompt = gr.Textbox(label="Prompt")
19
+ steps = gr.Slider(label="Steps", minimum=1, maximum=50, value=28)
20
+ submit_btn = gr.Button("Convertir")
21
+ with gr.Column():
22
+ output_image = gr.Image(label="Imagen Generada")
23
+
24
+ submit_btn.click(fn=generate_image, inputs=[canvas, prompt, steps], outputs=output_image)
25
+
26
+ demo.launch()