nsfwalex Claude Opus 4.8 commited on
Commit
657d09f
Β·
1 Parent(s): a2d7364

Prompt-improve as system prompt + One Obsession quality defaults

Browse files

- Prompt-improve: pass the improve instruction as the LLM system prompt and
the user's original prompt as the user message (was a combined user turn).
- One Obsession (NoobXL): prepend a quality prefix (masterpiece, best quality,
…) to the positive prompt, skipping any tag already present; replace the
baseline NOOBXL_NEGATIVE with the new default negative (applied via the
existing negative wiring + UI default).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +28 -4
app.py CHANGED
@@ -99,12 +99,32 @@ def _checkpoint_path(filename):
99
 
100
  MAX_SEED = np.iinfo(np.int32).max
101
 
 
 
 
 
 
 
 
102
  NOOBXL_NEGATIVE = (
103
- "lowres, {bad}, error, fewer, extra, missing, worst quality, jpeg artifacts, "
104
- "bad quality, watermark, unfinished, displeasing, chromatic aberration, signature, "
105
- "extra digits, artistic error, username, scan, [abstract]"
106
  )
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  # -----------------------------------------------------------------------------
109
  # Load both pipelines once at startup. On ZeroGPU the `.to("cuda")` calls are
110
  # captured by the runtime and the work happens inside the @spaces.GPU function.
@@ -545,9 +565,11 @@ def generate_image(
545
  effective_prompt = prompt
546
  instruction = (prompt_improve_instruction or "").strip()
547
  if instruction:
 
 
548
  improved = ""
549
  for ev in _vlm_chat_core(
550
- _compose_instruction(instruction, prompt), None, "Off", 512
551
  ):
552
  if ev[0] == "text":
553
  improved = ev[1]
@@ -629,6 +651,8 @@ def _generate_image_inner(
629
  requires_pooled=[False, True],
630
  truncate_long_prompts=False,
631
  )
 
 
632
  # Wire the negative prompt in only when this model supports it and the
633
  # caller hasn't disabled it; otherwise fall back to no negative prompt.
634
  if not (use_negative_prompt and _supports_negative(model_name)):
 
99
 
100
  MAX_SEED = np.iinfo(np.int32).max
101
 
102
+ # One Obsession (Illustrious/SDXL) quality defaults. The prefix is prepended to
103
+ # the positive prompt (skipping any tag the prompt already has); the negative is
104
+ # the model's baseline negative.
105
+ NOOBXL_PREFIX = (
106
+ "masterpiece, best quality, amazing quality, very awa, absurdres, newest, "
107
+ "very aesthetic, depth of field, highres"
108
+ )
109
  NOOBXL_NEGATIVE = (
110
+ "worst quality, normal quality, anatomical nonsense, bad anatomy, "
111
+ "interlocked fingers, extra fingers, watermark, simple background, transparent, "
112
+ "low quality, logo, text, signature, face backlighting, backlighting"
113
  )
114
 
115
+
116
+ def _apply_noobxl_prefix(prompt):
117
+ """Prepend ``NOOBXL_PREFIX`` to ``prompt``, dropping any prefix tag the prompt
118
+ already contains (case-insensitive, per comma-separated token)."""
119
+ prompt = (prompt or "").strip()
120
+ have = {t.strip().lower() for t in prompt.split(",") if t.strip()}
121
+ add = [t.strip() for t in NOOBXL_PREFIX.split(",")
122
+ if t.strip() and t.strip().lower() not in have]
123
+ if not add:
124
+ return prompt
125
+ pre = ", ".join(add)
126
+ return f"{pre}, {prompt}" if prompt else pre
127
+
128
  # -----------------------------------------------------------------------------
129
  # Load both pipelines once at startup. On ZeroGPU the `.to("cuda")` calls are
130
  # captured by the runtime and the work happens inside the @spaces.GPU function.
 
565
  effective_prompt = prompt
566
  instruction = (prompt_improve_instruction or "").strip()
567
  if instruction:
568
+ # The improve instruction is the LLM's SYSTEM prompt; the user's original
569
+ # prompt is the user message it rewrites.
570
  improved = ""
571
  for ev in _vlm_chat_core(
572
+ prompt, None, "Off", 512, system_prompt=instruction
573
  ):
574
  if ev[0] == "text":
575
  improved = ev[1]
 
651
  requires_pooled=[False, True],
652
  truncate_long_prompts=False,
653
  )
654
+ # One Obsession quality prefix (skipping tags already in the prompt).
655
+ prompt = _apply_noobxl_prefix(prompt)
656
  # Wire the negative prompt in only when this model supports it and the
657
  # caller hasn't disabled it; otherwise fall back to no negative prompt.
658
  if not (use_negative_prompt and _supports_negative(model_name)):