Spaces:
Running on Zero
Running on Zero
Strengthen strict overhead sprite prompting
Browse files
app.py
CHANGED
|
@@ -1947,6 +1947,61 @@ def neural_foreground_cutout(image: Image.Image) -> Image.Image:
|
|
| 1947 |
return cutout
|
| 1948 |
|
| 1949 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1950 |
def primary_diffusion_prompt(spec: AssetSpec) -> str:
|
| 1951 |
camera = primary_camera_phrase(spec.camera, is_background_spec(spec))
|
| 1952 |
if spec.camera == "auto" and spec.camera_instruction and spec.camera_instruction.lower() != "auto":
|
|
@@ -1957,12 +2012,11 @@ def primary_diffusion_prompt(spec: AssetSpec) -> str:
|
|
| 1957 |
variation = f"Variation: {compact_prompt_words(spec.variation, 4)}. " if spec.variation else ""
|
| 1958 |
subject = (spec.group or spec.role).replace("_", " ")
|
| 1959 |
if spec.camera == "top_down":
|
|
|
|
| 1960 |
return compact_prompt_words(
|
| 1961 |
-
f"Strict orthographic top-down game sprite
|
| 1962 |
-
"
|
| 1963 |
-
"
|
| 1964 |
-
f"{description}. Exactly one complete isolated subject, centered on uniform white. "
|
| 1965 |
-
f"{variation}Crisp game-ready details. No scene.",
|
| 1966 |
55,
|
| 1967 |
)
|
| 1968 |
return (
|
|
|
|
| 1947 |
return cutout
|
| 1948 |
|
| 1949 |
|
| 1950 |
+
def top_down_subject_contract(spec: AssetSpec) -> str:
|
| 1951 |
+
"""Describe visible overhead anatomy without drawing or reshaping model artwork."""
|
| 1952 |
+
# Classify only from the user's visual description. Custom IDs such as
|
| 1953 |
+
# ``player`` or ``enemy`` are integration hooks, not reliable anatomy.
|
| 1954 |
+
description = f"{spec.description} {spec.prompt}".lower()
|
| 1955 |
+
humanoid_terms = (
|
| 1956 |
+
"humanoid",
|
| 1957 |
+
"character",
|
| 1958 |
+
"player",
|
| 1959 |
+
"person",
|
| 1960 |
+
"human",
|
| 1961 |
+
"astronaut",
|
| 1962 |
+
"soldier",
|
| 1963 |
+
"warrior",
|
| 1964 |
+
"ranger",
|
| 1965 |
+
)
|
| 1966 |
+
radial_terms = (
|
| 1967 |
+
"radial",
|
| 1968 |
+
"six-legged",
|
| 1969 |
+
"six legged",
|
| 1970 |
+
"multi-legged",
|
| 1971 |
+
"multi legged",
|
| 1972 |
+
"spider",
|
| 1973 |
+
"crab",
|
| 1974 |
+
"quadruped",
|
| 1975 |
+
)
|
| 1976 |
+
vehicle_terms = (
|
| 1977 |
+
"vehicle",
|
| 1978 |
+
"rover",
|
| 1979 |
+
"car",
|
| 1980 |
+
"truck",
|
| 1981 |
+
"tank",
|
| 1982 |
+
"motorcycle",
|
| 1983 |
+
"spaceship",
|
| 1984 |
+
"spacecraft",
|
| 1985 |
+
)
|
| 1986 |
+
|
| 1987 |
+
if contains_any_term(description, radial_terms):
|
| 1988 |
+
return (
|
| 1989 |
+
"Top of body dominates; splayed limbs radiate in image plane; "
|
| 1990 |
+
"no upright torso or side elevation."
|
| 1991 |
+
)
|
| 1992 |
+
if contains_any_term(description, vehicle_terms):
|
| 1993 |
+
return (
|
| 1994 |
+
"Roof and chassis top dominate; wheel footprints flank both sides; "
|
| 1995 |
+
"no grille or side elevation."
|
| 1996 |
+
)
|
| 1997 |
+
if spec.silhouette == "humanoid" or contains_any_term(description, humanoid_terms):
|
| 1998 |
+
return (
|
| 1999 |
+
"Full body overhead: head crown, shoulders and back visible; "
|
| 2000 |
+
"face and chest invisible; limbs foreshortened."
|
| 2001 |
+
)
|
| 2002 |
+
return "Flattened overhead footprint with top surfaces dominant; no upright or eye-level presentation."
|
| 2003 |
+
|
| 2004 |
+
|
| 2005 |
def primary_diffusion_prompt(spec: AssetSpec) -> str:
|
| 2006 |
camera = primary_camera_phrase(spec.camera, is_background_spec(spec))
|
| 2007 |
if spec.camera == "auto" and spec.camera_instruction and spec.camera_instruction.lower() != "auto":
|
|
|
|
| 2012 |
variation = f"Variation: {compact_prompt_words(spec.variation, 4)}. " if spec.variation else ""
|
| 2013 |
subject = (spec.group or spec.role).replace("_", " ")
|
| 2014 |
if spec.camera == "top_down":
|
| 2015 |
+
overhead_contract = top_down_subject_contract(spec)
|
| 2016 |
return compact_prompt_words(
|
| 2017 |
+
f"Strict orthographic top-down game sprite of {description}. "
|
| 2018 |
+
f"Camera exactly 90 degrees above, looking straight down. {overhead_contract} "
|
| 2019 |
+
f"Exactly one complete isolated subject on uniform white. {variation}No scene.",
|
|
|
|
|
|
|
| 2020 |
55,
|
| 2021 |
)
|
| 2022 |
return (
|