Allex21 commited on
Commit
e3f6801
·
verified ·
1 Parent(s): b11e4f5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -0
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import os
3
+ import gradio as gr
4
+ from utils.editor import run_pipeline
5
+ from PIL import Image
6
+ import io
7
+
8
+ DESCRIPTION = """
9
+ # 👗 Fashion Editor — Stable Diffusion + ControlNet (OpenPose)
10
+ Envie a foto da modelo e uma foto da peça (jaqueta, camiseta etc.). A ferramenta
11
+ irá alinhar a peça, extrair a pose e usar Stable Diffusion + ControlNet para gerar
12
+ a composição fotorrealista.
13
+ """
14
+
15
+ examples = [
16
+ # Você pode adicionar exemplos aqui (caminhos relativos dentro do repo) após fazer upload
17
+ ]
18
+
19
+ def infer(model_image, garment_image, prompt_extra):
20
+ """
21
+ model_image: PIL.Image or numpy
22
+ garment_image: PIL.Image or numpy
23
+ prompt_extra: str - description tweaks
24
+ """
25
+ if model_image is None or garment_image is None:
26
+ return None, "Envie as duas imagens (modelo e peça)."
27
+
28
+ # run_pipeline retorna (pil_image_result, debug_info_dict)
29
+ try:
30
+ result, info = run_pipeline(model_image, garment_image, prompt_extra)
31
+ return result, f"OK — steps: {info.get('steps')}, guidance: {info.get('guidance_scale')}"
32
+ except Exception as e:
33
+ return None, f"Erro durante a geração: {str(e)}"
34
+
35
+ with gr.Blocks(title="Fashion Editor (SD + ControlNet)") as demo:
36
+ gr.Markdown(DESCRIPTION)
37
+ with gr.Row():
38
+ with gr.Column():
39
+ model_input = gr.Image(label="Foto da Modelo", type="pil")
40
+ garment_input = gr.Image(label="Foto da Peça (Roupa)", type="pil")
41
+ prompt_extra = gr.Textbox(label="Prompt extra (opcional) — ex: 'leather biker jacket, black, shiny, realistic'", lines=2)
42
+ run_button = gr.Button("Gerar Edição")
43
+ status = gr.Textbox(label="Status / Informações", interactive=False)
44
+ with gr.Column():
45
+ output = gr.Image(label="Resultado (Final)")
46
+
47
+ run_button.click(fn=infer, inputs=[model_input, garment_input, prompt_extra], outputs=[output, status])
48
+
49
+ if __name__ == "__main__":
50
+ demo.launch()