pormungtai commited on
Commit
d7cb2d1
·
verified ·
1 Parent(s): 5dbf2b4

Tab1: hair -> dropdown (reliable short/long+color tags), bake skin-realism into face prompt for ALL models, SDXL face canvas 768x1024

Browse files
Files changed (1) hide show
  1. app.py +35 -9
app.py CHANGED
@@ -248,20 +248,26 @@ def generate_face(model_id, prompt, translator):
248
  import random as _r
249
  seed = _r.randint(0, MAX_SEED)
250
  p = pm.translate_prompt(prompt, translator)
251
- # Head-and-shoulders framing with headroom (NOT extreme close-up, which crops the
252
- # top of the head). Put it first so it survives CLIP truncation.
253
- p = ("RAW photo, upper body portrait, head and shoulders, full head in frame, "
254
- "headroom above the head, centered, looking at viewer, " + p)
255
- # push away from macro/cropped framings that cut the head off
 
 
 
 
256
  neg = (cfg.get("negative_prompt", "") +
257
- ", (extreme close-up, macro, cropped head, head out of frame, "
258
- "forehead cut off, face too close:1.3)")
 
 
259
  try:
260
  img = pm.run_generation(
261
  cfg=cfg, mode="txt2img", prompt=p, negative_prompt=neg, ref_image=None,
262
  steps=int(cfg.get("default_steps", 30)),
263
  guidance=float(cfg.get("default_guidance", 5.0)),
264
- denoise=0.4, ip_scale=0.7, width=512, height=768, seed=seed,
265
  )
266
  except Exception as e: # noqa
267
  traceback.print_exc()
@@ -390,7 +396,27 @@ with gr.Blocks(css=CSS, theme=gr.themes.Soft(primary_hue="blue"),
390
  ("ยิ้มมุมปาก / slight smile", "slight smile"),
391
  ],
392
  value=None, multiselect=True, allow_custom_value=True)
393
- f_hair = gr.Textbox(label="ทรงผม / สีผม", placeholder="เช่น ผมยาวสีดำ")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
394
  f_expr = gr.Dropdown(
395
  label="สีหน้า / อารมณ์ (เลือกได้/พิมพ์เองได้)",
396
  choices=[
 
248
  import random as _r
249
  seed = _r.randint(0, MAX_SEED)
250
  p = pm.translate_prompt(prompt, translator)
251
+ # Head-and-shoulders framing with headroom (NOT extreme close-up) + a strong skin-
252
+ # realism push baked in here, because only majicMIX has a style_prefix — this makes
253
+ # ALL models (incl. SDXL base) render real skin in the identity tab. Front-loaded so
254
+ # it survives CLIP truncation.
255
+ p = ("RAW photo, photograph, upper body portrait, head and shoulders, full head in "
256
+ "frame, headroom above the head, centered, looking at viewer, "
257
+ "(photorealistic skin:1.1), detailed skin texture, visible skin pores, "
258
+ "fine vellus hair, film grain, " + p)
259
+ # push away from macro/cropped framings + plastic/CG skin
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:
266
  img = pm.run_generation(
267
  cfg=cfg, mode="txt2img", prompt=p, negative_prompt=neg, ref_image=None,
268
  steps=int(cfg.get("default_steps", 30)),
269
  guidance=float(cfg.get("default_guidance", 5.0)),
270
+ denoise=0.4, ip_scale=0.7, width=fw, height=fh, seed=seed,
271
  )
272
  except Exception as e: # noqa
273
  traceback.print_exc()
 
396
  ("ยิ้มมุมปาก / slight smile", "slight smile"),
397
  ],
398
  value=None, multiselect=True, allow_custom_value=True)
399
+ f_hair = gr.Dropdown(
400
+ label="ทรงผม / สีผม (เลือกความยาว+สี · พิมพ์เองได้)",
401
+ choices=[
402
+ ("ผมสั้น / short", "short hair"),
403
+ ("บ๊อบ / bob", "bob cut"),
404
+ ("ประบ่า / medium", "medium hair, shoulder-length"),
405
+ ("ผมยาว / long", "long hair"),
406
+ ("ยาวมาก / very long", "very long hair"),
407
+ ("หางม้า / ponytail", "ponytail"),
408
+ ("มัดมวย / bun", "hair bun"),
409
+ ("ผมม้า / bangs", "blunt bangs"),
410
+ ("หยิก / curly", "curly hair"),
411
+ ("ตรง / straight", "straight hair"),
412
+ ("ดำ / black", "black hair"),
413
+ ("น้ำตาลเข้ม / dark brown", "dark brown hair"),
414
+ ("น้ำตาล / brown", "brown hair"),
415
+ ("บลอนด์ / blonde", "blonde hair"),
416
+ ("ทอง / golden", "golden blonde hair"),
417
+ ("แดง / red", "red hair"),
418
+ ],
419
+ value=None, multiselect=True, allow_custom_value=True)
420
  f_expr = gr.Dropdown(
421
  label="สีหน้า / อารมณ์ (เลือกได้/พิมพ์เองได้)",
422
  choices=[