Spaces:
Running on Zero
Running on Zero
Prevent sprite generations from becoming texture maps
Browse files
app.py
CHANGED
|
@@ -196,10 +196,23 @@ def interpret_style_hint(style_hint: str) -> StylePlan:
|
|
| 196 |
|
| 197 |
def build_asset_prompt(role: str, prompt: str, style_hint: str) -> str:
|
| 198 |
plan = interpret_style_hint(style_hint)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
return (
|
| 200 |
f"{role} asset: {prompt}. Style interpretation: {plan.medium}; {plan.palette}; "
|
| 201 |
f"{plan.texture}; {plan.lighting}; {plan.linework}; {plan.camera}. "
|
| 202 |
-
"
|
| 203 |
"Game asset, readable at small size, no text, no watermark."
|
| 204 |
)
|
| 205 |
|
|
@@ -1045,8 +1058,14 @@ def free_diffusion_png(spec: AssetSpec, index: int, run_id: int) -> tuple[bytes
|
|
| 1045 |
width, height = diffusion_dimensions(spec)
|
| 1046 |
seed = abs(hash(f"{spec.role}|{spec.prompt}|{index}|{run_id}")) % 2147483647
|
| 1047 |
generator = torch.Generator(device="cpu").manual_seed(seed)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1048 |
image = FREE_DIFFUSION_PIPE(
|
| 1049 |
spec.prompt,
|
|
|
|
| 1050 |
width=width,
|
| 1051 |
height=height,
|
| 1052 |
num_inference_steps=FREE_IMAGE_STEPS,
|
|
|
|
| 196 |
|
| 197 |
def build_asset_prompt(role: str, prompt: str, style_hint: str) -> str:
|
| 198 |
plan = interpret_style_hint(style_hint)
|
| 199 |
+
slug = slugify(role)
|
| 200 |
+
is_background = any(word in slug for word in ("background", "backdrop", "scene", "map", "level"))
|
| 201 |
+
if is_background:
|
| 202 |
+
asset_instruction = (
|
| 203 |
+
"Create one complete 2D game background scene, not a texture tile, not a material sample, "
|
| 204 |
+
"not a UV map. Full scene composition for a canvas game."
|
| 205 |
+
)
|
| 206 |
+
else:
|
| 207 |
+
asset_instruction = (
|
| 208 |
+
"Create one complete standalone 2D sprite of the whole subject, centered, full body or full vehicle, "
|
| 209 |
+
"single object, transparent or plain background, readable silhouette. Not a texture map, not a tiled "
|
| 210 |
+
"pattern, not a material swatch, not a UV unwrap, not a 3D model skin."
|
| 211 |
+
)
|
| 212 |
return (
|
| 213 |
f"{role} asset: {prompt}. Style interpretation: {plan.medium}; {plan.palette}; "
|
| 214 |
f"{plan.texture}; {plan.lighting}; {plan.linework}; {plan.camera}. "
|
| 215 |
+
f"{asset_instruction} "
|
| 216 |
"Game asset, readable at small size, no text, no watermark."
|
| 217 |
)
|
| 218 |
|
|
|
|
| 1058 |
width, height = diffusion_dimensions(spec)
|
| 1059 |
seed = abs(hash(f"{spec.role}|{spec.prompt}|{index}|{run_id}")) % 2147483647
|
| 1060 |
generator = torch.Generator(device="cpu").manual_seed(seed)
|
| 1061 |
+
negative_prompt = (
|
| 1062 |
+
"texture map, material texture, seamless texture, tiled pattern, uv map, uv unwrap, "
|
| 1063 |
+
"skin texture, 3d model texture, normal map, roughness map, diffuse map, sprite sheet, "
|
| 1064 |
+
"atlas, multiple objects, cropped subject, close-up surface, fabric swatch, text, watermark"
|
| 1065 |
+
)
|
| 1066 |
image = FREE_DIFFUSION_PIPE(
|
| 1067 |
spec.prompt,
|
| 1068 |
+
negative_prompt=negative_prompt,
|
| 1069 |
width=width,
|
| 1070 |
height=height,
|
| 1071 |
num_inference_steps=FREE_IMAGE_STEPS,
|