renderfy commited on
Commit
e272907
·
verified ·
1 Parent(s): 87e6e93

Upload streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +28 -11
streamlit_app.py CHANGED
@@ -1,4 +1,4 @@
1
- # streamlit_app.py — AI LightBox · Beauty (packshot + on-face + SR + video)
2
  import os, io, zipfile, requests, streamlit as st
3
  from PIL import Image
4
 
@@ -16,7 +16,24 @@ if "job_counter" not in st.session_state:
16
  if "duration" not in st.session_state:
17
  st.session_state["duration"] = "6" # widget oluşturulmadan önce default
18
 
19
- # ================= Yardımcılar =================
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  def _needs_auth(url: str) -> bool:
21
  return url.startswith(API_BASE) or url.startswith("outputs/")
22
 
@@ -143,7 +160,7 @@ def make_zip(named_bytes: list[tuple[str, bytes]]) -> bytes:
143
  # ================= Sayfa =================
144
  st.set_page_config(page_title="AI LightBox · Beauty", layout="wide", page_icon="💄")
145
  st.title("💄 AI LightBox · Beauty")
146
- st.caption("Packshot → Padding (square) → On-Face placement · Super Resolution · (optional) Video")
147
 
148
  # ================= Üst Kontrol Şeridi =================
149
  ok = backend_ok()
@@ -197,10 +214,10 @@ with colT1:
197
  with colT2:
198
  canvas_size = st.number_input("Canvas size (px)", min_value=256, max_value=8192, value=1200, step=64, key="canvas_size")
199
 
200
- face_url = st.text_input("Face image URL (optional)", key="face_url")
201
 
202
  # ================= Girdi Önizleme =================
203
- c_in, c_pack, c_pad, c_face = st.columns(4)
204
  white_bg = (255, 255, 255)
205
 
206
  input_preview_bytes = None
@@ -237,7 +254,7 @@ if run:
237
  "edit_prompt": "",
238
  "num_images": "1",
239
  "image_urls": (image_url or ""),
240
- "mannequin_image_url": (face_url or ""), # face ref
241
  "padding_ratio": str(padding_ratio),
242
  "identity_lock": "true" if identity_lock else "false",
243
  # SR
@@ -334,10 +351,10 @@ if res:
334
  )
335
 
336
  shown_final_url = res.get("placed_sr_url") or res.get("placed_url")
337
- m_title = "On-Face (SR)" if res.get("placed_sr_url") else "On-Face"
338
  m_url, m_bytes = show_tile(
339
- c_face, m_title, shown_final_url,
340
- bg_rgb=white_bg, filename_stub="onface", key_prefix=key_prefix
341
  )
342
 
343
  # ---- Video (final görselden) ----
@@ -380,7 +397,7 @@ if res:
380
  named = []
381
  if p_bytes: named.append((f"packshot{infer_ext(p_bytes)}", p_bytes))
382
  if pad_bytes: named.append((f"padded{infer_ext(pad_bytes)}", pad_bytes))
383
- if m_bytes: named.append((f"onface{infer_ext(m_bytes)}", m_bytes))
384
  if vbytes: named.append(("video.mp4", vbytes))
385
  if named:
386
  zip_bytes = make_zip(named)
@@ -418,4 +435,4 @@ with st.sidebar:
418
  st.success("Results cleared.")
419
  st.caption(f"API_BASE: {API_BASE}")
420
  if HF_TOKEN:
421
- st.caption("Auth: Bearer (active)")
 
1
+ # streamlit_app.py — AI LightBox · Beauty (packshot + try-on + SR + video)
2
  import os, io, zipfile, requests, streamlit as st
3
  from PIL import Image
4
 
 
16
  if "duration" not in st.session_state:
17
  st.session_state["duration"] = "6" # widget oluşturulmadan önce default
18
 
19
+ # ====== Try-on başlığı için kategori eşleme ======
20
+ LIPS = {"lipstick","lipgloss","lipliner"}
21
+ EYES = {"eyeshadow","eyeliner","mascara"}
22
+ FACE = {"foundation","concealer","blush","bronzer","contour","highlighter"}
23
+ HANDS = {"nail_polish"}
24
+ LIFESTYLE = {"skincare","perfume","tools","set"}
25
+
26
+ def tryon_label(cat: str, sr: bool) -> str:
27
+ c = (cat or "auto").lower()
28
+ if c in LIPS: base = "On-Lips"
29
+ elif c in EYES: base = "On-Eyes"
30
+ elif c in HANDS: base = "On-Nails"
31
+ elif c in FACE: base = "On-Face"
32
+ elif c in LIFESTYLE: base = "Lifestyle"
33
+ else: base = "Try-on"
34
+ return f"{base} (SR)" if sr else base
35
+
36
+ # ================= Yardımcılar =================
37
  def _needs_auth(url: str) -> bool:
38
  return url.startswith(API_BASE) or url.startswith("outputs/")
39
 
 
160
  # ================= Sayfa =================
161
  st.set_page_config(page_title="AI LightBox · Beauty", layout="wide", page_icon="💄")
162
  st.title("💄 AI LightBox · Beauty")
163
+ st.caption("Packshot → Padding (square) → Try-on (lips/eyes/face/hand/lifestyle) · Super Resolution · (optional) Video")
164
 
165
  # ================= Üst Kontrol Şeridi =================
166
  ok = backend_ok()
 
214
  with colT2:
215
  canvas_size = st.number_input("Canvas size (px)", min_value=256, max_value=8192, value=1200, step=64, key="canvas_size")
216
 
217
+ face_url = st.text_input("Model image URL (face/hand/eyes — optional)", key="face_url")
218
 
219
  # ================= Girdi Önizleme =================
220
+ c_in, c_pack, c_pad, c_try = st.columns(4)
221
  white_bg = (255, 255, 255)
222
 
223
  input_preview_bytes = None
 
254
  "edit_prompt": "",
255
  "num_images": "1",
256
  "image_urls": (image_url or ""),
257
+ "mannequin_image_url": (face_url or ""), # face/hand/eyes ref
258
  "padding_ratio": str(padding_ratio),
259
  "identity_lock": "true" if identity_lock else "false",
260
  # SR
 
351
  )
352
 
353
  shown_final_url = res.get("placed_sr_url") or res.get("placed_url")
354
+ m_title = tryon_label(st.session_state.get("category","auto"), bool(res.get("placed_sr_url")))
355
  m_url, m_bytes = show_tile(
356
+ c_try, m_title, shown_final_url,
357
+ bg_rgb=white_bg, filename_stub="tryon", key_prefix=key_prefix
358
  )
359
 
360
  # ---- Video (final görselden) ----
 
397
  named = []
398
  if p_bytes: named.append((f"packshot{infer_ext(p_bytes)}", p_bytes))
399
  if pad_bytes: named.append((f"padded{infer_ext(pad_bytes)}", pad_bytes))
400
+ if m_bytes: named.append((f"tryon{infer_ext(m_bytes)}", m_bytes))
401
  if vbytes: named.append(("video.mp4", vbytes))
402
  if named:
403
  zip_bytes = make_zip(named)
 
435
  st.success("Results cleared.")
436
  st.caption(f"API_BASE: {API_BASE}")
437
  if HF_TOKEN:
438
+ st.caption("Auth: Bearer (active)")