Spaces:
Sleeping
Sleeping
vitor.fran commited on
Commit Β·
767b86a
1
Parent(s): f5bad34
fix: update app.py parameters call and add prompt customization to LineartConfig
Browse files- app.py +5 -6
- faceless_processing.py +4 -2
app.py
CHANGED
|
@@ -5,7 +5,7 @@ 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=""):
|
|
@@ -15,12 +15,11 @@ def process_faceless(input_image, prompt="", negative_prompt=""):
|
|
| 15 |
# NΓO REDIMENSIONAMOS A IMAGEM β a funΓ§Γ£o interna jΓ‘ lida com tamanhos variados.
|
| 16 |
# Gera lineart e cutout usando a funΓ§Γ£o otimizada
|
| 17 |
try:
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
prompt=prompt or None,
|
| 22 |
-
negative_prompt=negative_prompt or None,
|
| 23 |
)
|
|
|
|
| 24 |
return lineart, cutout
|
| 25 |
except Exception as e:
|
| 26 |
print(f"[ERRO] process_faceless: {e}")
|
|
|
|
| 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=""):
|
|
|
|
| 15 |
# NΓO REDIMENSIONAMOS A IMAGEM β a funΓ§Γ£o interna jΓ‘ lida com tamanhos variados.
|
| 16 |
# Gera lineart e cutout usando a funΓ§Γ£o otimizada
|
| 17 |
try:
|
| 18 |
+
cfg = LineartConfig(
|
| 19 |
+
prompt=prompt or "technical line art, clean vector, simple continuous lines, white background",
|
| 20 |
+
negative_prompt=negative_prompt or "shading, realism, messy lines, noisy, double lines, background clutter"
|
|
|
|
|
|
|
| 21 |
)
|
| 22 |
+
lineart, cutout = build_faceless_embroidery_assets(input_image, cfg)
|
| 23 |
return lineart, cutout
|
| 24 |
except Exception as e:
|
| 25 |
print(f"[ERRO] process_faceless: {e}")
|
faceless_processing.py
CHANGED
|
@@ -33,6 +33,8 @@ class LineartConfig:
|
|
| 33 |
mediapipe_model_path: str = "face_landmarker.task"
|
| 34 |
rembg_model: str = "isnet-general-use"
|
| 35 |
transparency_threshold: float = 0.03
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# ββ Carregamento Otimizado βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 38 |
def get_sd_pipeline(cfg: LineartConfig):
|
|
@@ -94,8 +96,8 @@ def make_faceless_lineart(img: Image.Image, cfg: LineartConfig = LineartConfig()
|
|
| 94 |
if pipe:
|
| 95 |
logger.info("Executando IA...")
|
| 96 |
generated = pipe(
|
| 97 |
-
|
| 98 |
-
negative_prompt=
|
| 99 |
image=rgb_input,
|
| 100 |
controlnet_conditioning_scale=cfg.controlnet_conditioning_scale,
|
| 101 |
num_inference_steps=cfg.num_inference_steps
|
|
|
|
| 33 |
mediapipe_model_path: str = "face_landmarker.task"
|
| 34 |
rembg_model: str = "isnet-general-use"
|
| 35 |
transparency_threshold: float = 0.03
|
| 36 |
+
prompt: str = "technical line art, clean vector, simple continuous lines, white background"
|
| 37 |
+
negative_prompt: str = "shading, realism, messy lines, noisy, double lines, background clutter"
|
| 38 |
|
| 39 |
# ββ Carregamento Otimizado βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 40 |
def get_sd_pipeline(cfg: LineartConfig):
|
|
|
|
| 96 |
if pipe:
|
| 97 |
logger.info("Executando IA...")
|
| 98 |
generated = pipe(
|
| 99 |
+
cfg.prompt,
|
| 100 |
+
negative_prompt=cfg.negative_prompt,
|
| 101 |
image=rgb_input,
|
| 102 |
controlnet_conditioning_scale=cfg.controlnet_conditioning_scale,
|
| 103 |
num_inference_steps=cfg.num_inference_steps
|