Spaces:
Runtime error
Runtime error
nsfwalex commited on
Commit Β·
6efc873
1
Parent(s): 86620e2
Per-model prefix + default_negative (realism-illustrious, wai-anima, samanima); apply in illustrious+anima branches
Browse files
app.py
CHANGED
|
@@ -155,18 +155,27 @@ def _apply_prefix(prompt, prefix):
|
|
| 155 |
# anima -> Anima (Cosmos-Predict2 DiT) via the experimental modular
|
| 156 |
# pipeline. NON-COMMERCIAL license (CircleStone Labs).
|
| 157 |
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
IMAGE_MODELS = {
|
| 159 |
"one-obsession": dict(
|
| 160 |
label=MODEL_NOOBXL, family="illustrious",
|
| 161 |
checkpoint="checkpoints/il/oneObsession_v21Anime.safetensors",
|
| 162 |
steps=28, guidance=5.0, height=1536, width=1024,
|
| 163 |
-
negative=True, prefix=NOOBXL_PREFIX,
|
| 164 |
),
|
| 165 |
"realism-illustrious": dict(
|
| 166 |
label="Realism Illustrious (Stable Yogi)", family="illustrious",
|
| 167 |
checkpoint="checkpoints/il/realismIllustriousBy_v55FP16.safetensors",
|
| 168 |
-
steps=30, guidance=5.0, height=1152, width=896,
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
),
|
| 171 |
"moody-pro-mix": dict(
|
| 172 |
label=MODEL_ZIMAGE, family="zimageturbo",
|
|
@@ -186,12 +195,23 @@ IMAGE_MODELS = {
|
|
| 186 |
"wai-anima": dict(
|
| 187 |
label="WAI-ANIMA", family="anima",
|
| 188 |
checkpoint="checkpoints/anima/waiANIMA_v10Base10.safetensors",
|
| 189 |
-
steps=24, guidance=0.0, height=1024, width=1024, negative=True,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
),
|
| 191 |
"samanima": dict(
|
| 192 |
label="SamANIMA", family="anima",
|
| 193 |
checkpoint="checkpoints/anima/samANIMA_v20.safetensors",
|
| 194 |
-
steps=24, guidance=0.0, height=1024, width=1024, negative=True,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
),
|
| 196 |
}
|
| 197 |
|
|
@@ -203,6 +223,15 @@ def _model_entry(model_name):
|
|
| 203 |
return MODEL_BY_LABEL.get(model_name, {})
|
| 204 |
|
| 205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
# Which models to load this boot. Unknown keys are ignored; an empty / all-invalid
|
| 207 |
# selection falls back to the first registered model so the Space always boots.
|
| 208 |
DEFAULT_IMAGE_MODELS = "one-obsession,moody-pro-mix"
|
|
@@ -841,12 +870,10 @@ def _generate_image_inner(
|
|
| 841 |
requires_pooled=[False, True],
|
| 842 |
truncate_long_prompts=False,
|
| 843 |
)
|
| 844 |
-
# Per-model quality prefix (skipping tags already in the prompt)
|
|
|
|
| 845 |
prompt = _apply_prefix(prompt, entry.get("prefix", ""))
|
| 846 |
-
|
| 847 |
-
# caller hasn't disabled it; otherwise fall back to no negative prompt.
|
| 848 |
-
if not (use_negative_prompt and _supports_negative(model_name)):
|
| 849 |
-
negative_prompt = ""
|
| 850 |
conv_prompt = get_embed_new(prompt, pipe, compel, only_convert_string=True)
|
| 851 |
conv_negative = get_embed_new(negative_prompt, pipe, compel, only_convert_string=True)
|
| 852 |
# Encode prompt and negative separately, then pad to equal length. The
|
|
@@ -884,8 +911,8 @@ def _generate_image_inner(
|
|
| 884 |
# manages guidance internally (no `guidance_scale` input) but does honor a
|
| 885 |
# negative prompt. The modular call returns the requested `output` value.
|
| 886 |
generator = torch.Generator("cuda").manual_seed(seed)
|
| 887 |
-
|
| 888 |
-
|
| 889 |
images = pipe(
|
| 890 |
prompt=prompt,
|
| 891 |
negative_prompt=negative_prompt or None,
|
|
@@ -1535,7 +1562,7 @@ with gr.Blocks(fill_height=True) as demo:
|
|
| 1535 |
)
|
| 1536 |
negative_prompt = gr.Textbox(
|
| 1537 |
label="π« Negative Prompt",
|
| 1538 |
-
value=
|
| 1539 |
lines=3,
|
| 1540 |
max_lines=6,
|
| 1541 |
interactive=_default_supports_neg,
|
|
|
|
| 155 |
# anima -> Anima (Cosmos-Predict2 DiT) via the experimental modular
|
| 156 |
# pipeline. NON-COMMERCIAL license (CircleStone Labs).
|
| 157 |
# -----------------------------------------------------------------------------
|
| 158 |
+
# `prefix` is prepended to the positive prompt (dedup'd, via _apply_prefix);
|
| 159 |
+
# `default_negative` is used as the negative prompt when the caller supports
|
| 160 |
+
# negatives but supplies none. Both apply to the illustrious + anima families
|
| 161 |
+
# (the guidance-free zimageturbo family ignores negatives).
|
| 162 |
IMAGE_MODELS = {
|
| 163 |
"one-obsession": dict(
|
| 164 |
label=MODEL_NOOBXL, family="illustrious",
|
| 165 |
checkpoint="checkpoints/il/oneObsession_v21Anime.safetensors",
|
| 166 |
steps=28, guidance=5.0, height=1536, width=1024,
|
| 167 |
+
negative=True, prefix=NOOBXL_PREFIX, default_negative=NOOBXL_NEGATIVE,
|
| 168 |
),
|
| 169 |
"realism-illustrious": dict(
|
| 170 |
label="Realism Illustrious (Stable Yogi)", family="illustrious",
|
| 171 |
checkpoint="checkpoints/il/realismIllustriousBy_v55FP16.safetensors",
|
| 172 |
+
steps=30, guidance=5.0, height=1152, width=896, negative=True,
|
| 173 |
+
prefix="masterpiece, best quality, amazing quality, very aesthetic, absurdres, highres, ultra detailed",
|
| 174 |
+
default_negative=(
|
| 175 |
+
"worst quality, low quality, normal quality, blurry, jpeg artifacts, "
|
| 176 |
+
"bad anatomy, bad hands, bad toes, extra digits, fewer digits, deformed, "
|
| 177 |
+
"distorted, disfigured, simple background, text, watermark, signature, "
|
| 178 |
+
"web address, username, NEGATIVE_HANDS, lazyhand, lazyneg"),
|
| 179 |
),
|
| 180 |
"moody-pro-mix": dict(
|
| 181 |
label=MODEL_ZIMAGE, family="zimageturbo",
|
|
|
|
| 195 |
"wai-anima": dict(
|
| 196 |
label="WAI-ANIMA", family="anima",
|
| 197 |
checkpoint="checkpoints/anima/waiANIMA_v10Base10.safetensors",
|
| 198 |
+
steps=24, guidance=0.0, height=1024, width=1024, negative=True,
|
| 199 |
+
prefix="masterpiece, best quality,score_7,",
|
| 200 |
+
default_negative=(
|
| 201 |
+
"worst quality, low quality, score_1, score_2, score_3, artist name,"
|
| 202 |
+
"blurry, jpeg artifacts, lowres,censor"),
|
| 203 |
),
|
| 204 |
"samanima": dict(
|
| 205 |
label="SamANIMA", family="anima",
|
| 206 |
checkpoint="checkpoints/anima/samANIMA_v20.safetensors",
|
| 207 |
+
steps=24, guidance=0.0, height=1024, width=1024, negative=True,
|
| 208 |
+
prefix="score_9,score_6,@2025,@candid photo,newest,HDR, photography, (dramatic lighting), very aesthetic",
|
| 209 |
+
default_negative=(
|
| 210 |
+
"missing finger,mutation,censor,censored,high contrast, harsh lighting, "
|
| 211 |
+
"cel shading, linear hatching,cartoon,toon,2D,CGI, comic, empty background, "
|
| 212 |
+
"monotone background, plastic skin, bad hands, blurry details,ugly face,"
|
| 213 |
+
"ugly woman,mutation,censor,filter,skinny female,vintage,wood,old background,"
|
| 214 |
+
"ulgly face,perspective default,fake breasts,breasts implants,title,logo,watermark"),
|
| 215 |
),
|
| 216 |
}
|
| 217 |
|
|
|
|
| 223 |
return MODEL_BY_LABEL.get(model_name, {})
|
| 224 |
|
| 225 |
|
| 226 |
+
def _resolve_negative(entry, negative_prompt, use_negative_prompt, model_name):
|
| 227 |
+
"""The negative prompt to actually use: the caller's (when they enabled it and
|
| 228 |
+
this model honors negatives), else the model's `default_negative`. Disabled or
|
| 229 |
+
unsupported -> empty."""
|
| 230 |
+
if not (use_negative_prompt and _supports_negative(model_name)):
|
| 231 |
+
return ""
|
| 232 |
+
return (negative_prompt or "").strip() or entry.get("default_negative", "")
|
| 233 |
+
|
| 234 |
+
|
| 235 |
# Which models to load this boot. Unknown keys are ignored; an empty / all-invalid
|
| 236 |
# selection falls back to the first registered model so the Space always boots.
|
| 237 |
DEFAULT_IMAGE_MODELS = "one-obsession,moody-pro-mix"
|
|
|
|
| 870 |
requires_pooled=[False, True],
|
| 871 |
truncate_long_prompts=False,
|
| 872 |
)
|
| 873 |
+
# Per-model quality prefix (skipping tags already in the prompt) + the
|
| 874 |
+
# model's default negative when the caller supplied none.
|
| 875 |
prompt = _apply_prefix(prompt, entry.get("prefix", ""))
|
| 876 |
+
negative_prompt = _resolve_negative(entry, negative_prompt, use_negative_prompt, model_name)
|
|
|
|
|
|
|
|
|
|
| 877 |
conv_prompt = get_embed_new(prompt, pipe, compel, only_convert_string=True)
|
| 878 |
conv_negative = get_embed_new(negative_prompt, pipe, compel, only_convert_string=True)
|
| 879 |
# Encode prompt and negative separately, then pad to equal length. The
|
|
|
|
| 911 |
# manages guidance internally (no `guidance_scale` input) but does honor a
|
| 912 |
# negative prompt. The modular call returns the requested `output` value.
|
| 913 |
generator = torch.Generator("cuda").manual_seed(seed)
|
| 914 |
+
prompt = _apply_prefix(prompt, entry.get("prefix", ""))
|
| 915 |
+
negative_prompt = _resolve_negative(entry, negative_prompt, use_negative_prompt, model_name)
|
| 916 |
images = pipe(
|
| 917 |
prompt=prompt,
|
| 918 |
negative_prompt=negative_prompt or None,
|
|
|
|
| 1562 |
)
|
| 1563 |
negative_prompt = gr.Textbox(
|
| 1564 |
label="π« Negative Prompt",
|
| 1565 |
+
value=_first_entry.get("default_negative", ""),
|
| 1566 |
lines=3,
|
| 1567 |
max_lines=6,
|
| 1568 |
interactive=_default_supports_neg,
|