Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,18 +5,35 @@ import io
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
# Importa a função melhorada do seu módulo (que já está ajustado )
|
| 8 |
-
from faceless_processing import build_faceless_embroidery_assets
|
| 9 |
|
| 10 |
@spaces.GPU
|
| 11 |
-
def process_faceless(input_image, prompt="", negative_prompt=""):
|
| 12 |
if input_image is None:
|
| 13 |
return None, None
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# NÃO REDIMENSIONAMOS A IMAGEM – a função interna ( embroidery_processing.py) já lida com tamanhos variados.
|
| 16 |
# Gera lineart e cutout usando a função otimizada
|
| 17 |
try:
|
| 18 |
lineart, cutout = build_faceless_embroidery_assets(
|
| 19 |
input_image,
|
|
|
|
| 20 |
use_huggingface=False, # Desativa Hugging Face (pode ativar se tiver token)
|
| 21 |
prompt=prompt or None,
|
| 22 |
negative_prompt=negative_prompt or None,
|
|
@@ -33,14 +50,15 @@ demo = gr.Interface(
|
|
| 33 |
inputs=[
|
| 34 |
gr.Image(type="pil", label="Imagem de Entrada"),
|
| 35 |
gr.Textbox(label="Prompt (Opcional)", value=""),
|
| 36 |
-
gr.Textbox(label="Prompt Negativo (Opcional)", value="")
|
|
|
|
| 37 |
],
|
| 38 |
outputs=[
|
| 39 |
gr.Image(label="Lineart Final (Transparente)"),
|
| 40 |
gr.Image(label="Recorte do Rosto (Sem Fundo)")
|
| 41 |
],
|
| 42 |
title="Faceless Embroidery Studio Generator",
|
| 43 |
-
description="Gera contornos e linearts minimalistas (Faceless) para bordados a partir de retratos.\n\n**Nota:** O rosto é completamente apagado e apenas a silhueta externa é desenhada."
|
| 44 |
)
|
| 45 |
|
| 46 |
if __name__ == "__main__":
|
|
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
# Importa a função melhorada do seu módulo (que já está ajustado )
|
| 8 |
+
from faceless_processing import build_faceless_embroidery_assets, LineartConfig
|
| 9 |
|
| 10 |
@spaces.GPU
|
| 11 |
+
def process_faceless(input_image, prompt="", negative_prompt="", is_cartoon=False):
|
| 12 |
if input_image is None:
|
| 13 |
return None, None
|
| 14 |
|
| 15 |
+
# Configuração base
|
| 16 |
+
cfg = LineartConfig()
|
| 17 |
+
|
| 18 |
+
if is_cartoon:
|
| 19 |
+
# Afrouxa as regras para não apagar detalhes do desenho
|
| 20 |
+
cfg.lineart_threshold = 60
|
| 21 |
+
cfg.lineart_min_perimeter = 25.0
|
| 22 |
+
cfg.detect_eyebrows = False
|
| 23 |
+
|
| 24 |
+
# Impede de achar rosto e apagar os olhos/boca do desenho
|
| 25 |
+
cfg.face_min_size = (9999, 9999)
|
| 26 |
+
|
| 27 |
+
# Mantém grossinho para bordar!
|
| 28 |
+
cfg.silhouette_line_thickness = 5
|
| 29 |
+
cfg.interior_line_thickness = 4
|
| 30 |
+
|
| 31 |
# NÃO REDIMENSIONAMOS A IMAGEM – a função interna ( embroidery_processing.py) já lida com tamanhos variados.
|
| 32 |
# Gera lineart e cutout usando a função otimizada
|
| 33 |
try:
|
| 34 |
lineart, cutout = build_faceless_embroidery_assets(
|
| 35 |
input_image,
|
| 36 |
+
cfg=cfg,
|
| 37 |
use_huggingface=False, # Desativa Hugging Face (pode ativar se tiver token)
|
| 38 |
prompt=prompt or None,
|
| 39 |
negative_prompt=negative_prompt or None,
|
|
|
|
| 50 |
inputs=[
|
| 51 |
gr.Image(type="pil", label="Imagem de Entrada"),
|
| 52 |
gr.Textbox(label="Prompt (Opcional)", value=""),
|
| 53 |
+
gr.Textbox(label="Prompt Negativo (Opcional)", value=""),
|
| 54 |
+
gr.Checkbox(label="Modo Cartoon / Desenho (Mantém detalhes e rostos)", value=False)
|
| 55 |
],
|
| 56 |
outputs=[
|
| 57 |
gr.Image(label="Lineart Final (Transparente)"),
|
| 58 |
gr.Image(label="Recorte do Rosto (Sem Fundo)")
|
| 59 |
],
|
| 60 |
title="Faceless Embroidery Studio Generator",
|
| 61 |
+
description="Gera contornos e linearts minimalistas (Faceless) para bordados a partir de retratos.\n\n**Nota:** O rosto é completamente apagado e apenas a silhueta externa é desenhada (exceto no Modo Cartoon)."
|
| 62 |
)
|
| 63 |
|
| 64 |
if __name__ == "__main__":
|