pormungtai commited on
Commit
499adbc
·
verified ·
1 Parent(s): d3855ab

Tab1: gender -> dropdown (woman/1girl strong tag), auto male-negatives when female so short-hair/jaw dont flip to male

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -260,6 +260,13 @@ def generate_face(model_id, prompt, translator):
260
  neg = (cfg.get("negative_prompt", "") +
261
  ", (extreme close-up, macro, cropped head, head out of frame, forehead cut off:1.3)"
262
  ", (plastic skin, airbrushed, smooth skin, waxy skin, doll, 3d, cgi, render:1.2)")
 
 
 
 
 
 
 
263
  # SDXL models need their native ~1024 canvas; SD1.5 stays 512-wide.
264
  fw, fh = (768, 1024) if cfg["base"] == "sdxl" else (512, 768)
265
  try:
@@ -318,7 +325,14 @@ with gr.Blocks(css=CSS, theme=gr.themes.Soft(primary_hue="blue"),
318
  gr.Markdown("### 👤 แถบ 1 · สร้างใบหน้า/อัตลักษณ์ก่อน — เน้นโคลสอัพให้ได้หน้าที่ต้องการ แล้วส่งไปแถบ 2")
319
  gr.Markdown("กรอกลักษณะใบหน้า (ไทยได้) → กด สร้าง prompt → กด สร้างใบหน้า · ใช้โมเดลที่เลือกจากแถบ 2")
320
  with gr.Row():
321
- f_gender = gr.Textbox(label="เพศ", value="ผู้หญิง")
 
 
 
 
 
 
 
322
  f_age = gr.Textbox(label="อายุ", placeholder="เช่น 22")
323
  f_ethnicity = gr.Textbox(label="เชื้อชาติ", placeholder="เช่น ไทย, เกาหลี")
324
  with gr.Row():
 
260
  neg = (cfg.get("negative_prompt", "") +
261
  ", (extreme close-up, macro, cropped head, head out of frame, forehead cut off:1.3)"
262
  ", (plastic skin, airbrushed, smooth skin, waxy skin, doll, 3d, cgi, render:1.2)")
263
+ # Gender lock: "short hair / square jaw / pointed nose" bias SD1.5 toward MALE and can
264
+ # override a lone gender word. Default to female unless the user explicitly picked male,
265
+ # and add strong male negatives so "woman" sticks.
266
+ _raw = (prompt or "").lower()
267
+ _is_male = ("1boy" in _raw) or ("ผู้ชาย" in (prompt or "")) or ("ชาย" in (prompt or "") and "หญิง" not in (prompt or ""))
268
+ if not _is_male:
269
+ neg += ", (man, male, masculine, beard, mustache, facial hair, adam's apple:1.4)"
270
  # SDXL models need their native ~1024 canvas; SD1.5 stays 512-wide.
271
  fw, fh = (768, 1024) if cfg["base"] == "sdxl" else (512, 768)
272
  try:
 
325
  gr.Markdown("### 👤 แถบ 1 · สร้างใบหน้า/อัตลักษณ์ก่อน — เน้นโคลสอัพให้ได้หน้าที่ต้องการ แล้วส่งไปแถบ 2")
326
  gr.Markdown("กรอกลักษณะใบหน้า (ไทยได้) → กด สร้าง prompt → กด สร้างใบหน้า · ใช้โมเดลที่เลือกจากแถบ 2")
327
  with gr.Row():
328
+ f_gender = gr.Dropdown(
329
+ label="เพศ",
330
+ choices=[
331
+ ("หญิง / woman", "woman, 1girl, female, feminine"),
332
+ ("ชาย / man", "man, 1boy, male, masculine"),
333
+ ],
334
+ value="woman, 1girl, female, feminine",
335
+ multiselect=False, allow_custom_value=True)
336
  f_age = gr.Textbox(label="อายุ", placeholder="เช่น 22")
337
  f_ethnicity = gr.Textbox(label="เชื้อชาติ", placeholder="เช่น ไทย, เกาหลี")
338
  with gr.Row():