Spaces:
Running on Zero
Running on Zero
Commit ·
46dcf38
1
Parent(s): 0446524
Framing+gaze fix: detect full-body from original Thai (translator drops it) + inject English tag, canvas 896; swap looking-at-camera->looking at viewer (#34)
Browse files- Framing+gaze fix: detect full-body from original Thai (translator drops it) + inject English tag, canvas 896; swap looking-at-camera->looking at viewer (32054e82f50e930a23cadd7623a658bb06834834)
Co-authored-by: pormungtailaw <pormungtai@users.noreply.huggingface.co>
- app.py +15 -0
- pipeline_manager.py +1 -1
app.py
CHANGED
|
@@ -94,6 +94,21 @@ def generate(model_id, mode, prompt, negative_prompt, ref_image,
|
|
| 94 |
orig_prompt = prompt
|
| 95 |
prompt = pm.translate_prompt(prompt, translator)
|
| 96 |
negative_prompt = pm.translate_prompt(negative_prompt, translator)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
if prompt != orig_prompt:
|
| 98 |
note = f" · 🌐 {translator}: _{prompt[:120]}_"
|
| 99 |
|
|
|
|
| 94 |
orig_prompt = prompt
|
| 95 |
prompt = pm.translate_prompt(prompt, translator)
|
| 96 |
negative_prompt = pm.translate_prompt(negative_prompt, translator)
|
| 97 |
+
|
| 98 |
+
# --- Post-translation fixes (the translator often drops/softens these) ---
|
| 99 |
+
# 1) Full-body framing: detect intent from the ORIGINAL Thai (translator tends to
|
| 100 |
+
# drop "เต็มตัว/ทั้งตัว"); inject an explicit English tag up front so the model AND
|
| 101 |
+
# the auto-tall-canvas logic in run_generation reliably honor it.
|
| 102 |
+
if pm.wants_full_body(orig_prompt) or pm.wants_full_body(prompt):
|
| 103 |
+
if "full body" not in prompt.lower():
|
| 104 |
+
prompt = "full body shot, head to toe, full body visible, " + prompt
|
| 105 |
+
# 2) Gaze: SD1.5 obeys the booru tag "looking at viewer" far better than "...camera".
|
| 106 |
+
if "looking at the camera" in prompt.lower() or "looking at camera" in prompt.lower():
|
| 107 |
+
prompt = (prompt.replace("looking at the camera", "looking at viewer, eye contact")
|
| 108 |
+
.replace("looking at camera", "looking at viewer, eye contact"))
|
| 109 |
+
elif "มองกล้อง" in (orig_prompt or "") and "looking at viewer" not in prompt.lower():
|
| 110 |
+
prompt = "looking at viewer, eye contact, " + prompt
|
| 111 |
+
|
| 112 |
if prompt != orig_prompt:
|
| 113 |
note = f" · 🌐 {translator}: _{prompt[:120]}_"
|
| 114 |
|
pipeline_manager.py
CHANGED
|
@@ -491,7 +491,7 @@ def run_generation(cfg, mode, prompt, negative_prompt, ref_image,
|
|
| 491 |
# Full-body framing fix: on SD1.5 a 512x768 canvas crops standing/seated subjects
|
| 492 |
# to a portrait even when "full body" is requested. Give it more vertical room.
|
| 493 |
if base == "sd15" and mode == "txt2img" and wants_full_body(prompt):
|
| 494 |
-
height = max(int(height),
|
| 495 |
|
| 496 |
call = dict(
|
| 497 |
prompt=full_prompt,
|
|
|
|
| 491 |
# Full-body framing fix: on SD1.5 a 512x768 canvas crops standing/seated subjects
|
| 492 |
# to a portrait even when "full body" is requested. Give it more vertical room.
|
| 493 |
if base == "sd15" and mode == "txt2img" and wants_full_body(prompt):
|
| 494 |
+
height = max(int(height), 896)
|
| 495 |
|
| 496 |
call = dict(
|
| 497 |
prompt=full_prompt,
|