vitor.fran commited on
Commit
16dfd40
·
1 Parent(s): ff7210d

fix: return file paths from process_faceless to bypass Gradio image conversion

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -20,11 +20,23 @@ def process_faceless(input_image, prompt="", negative_prompt=""):
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}")
26
- # Fallback: retorna a imagem original e uma mensagem de erro
27
- return input_image, None
 
 
28
 
29
  # Interface Gradio
30
  demo = gr.Interface(
 
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
+
24
+ # Save to temp files to preserve RGBA transparency channels
25
+ lineart_path = os.path.join(tempfile.gettempdir(), f"lineart_{os.getpid()}_{os.urandom(4).hex()}.png")
26
+ cutout_path = os.path.join(tempfile.gettempdir(), f"cutout_{os.getpid()}_{os.urandom(4).hex()}.png")
27
+
28
+ lineart.save(lineart_path, "PNG")
29
+ if cutout:
30
+ cutout.save(cutout_path, "PNG")
31
+ return lineart_path, cutout_path
32
+ else:
33
+ return lineart_path, None
34
  except Exception as e:
35
  print(f"[ERRO] process_faceless: {e}")
36
+ # Save original to temp file to be safe
37
+ orig_path = os.path.join(tempfile.gettempdir(), f"orig_{os.getpid()}.png")
38
+ input_image.save(orig_path, "PNG")
39
+ return orig_path, None
40
 
41
  # Interface Gradio
42
  demo = gr.Interface(