Spaces:
Paused
Paused
Update app.py
Browse filesadding prompt varistions
app.py
CHANGED
@@ -43,6 +43,36 @@ def generate_canny_map(image: Image.Image) -> Image.Image:
|
|
43 |
canny_image = Image.fromarray(edges).convert("RGB")
|
44 |
return canny_image
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
# ----------------------------
|
47 |
# 🎨 Image Generation Function
|
48 |
# ----------------------------
|
|
|
43 |
canny_image = Image.fromarray(edges).convert("RGB")
|
44 |
return canny_image
|
45 |
|
46 |
+
|
47 |
+
# ----------------------------
|
48 |
+
# 🧠 Generate Prompt Variations from Scene Plan
|
49 |
+
# ----------------------------
|
50 |
+
def generate_prompt_variations(base_prompt: str, scene_plan: dict, num_variations: int) -> list:
|
51 |
+
variations = []
|
52 |
+
scene = scene_plan.get("scene", {})
|
53 |
+
subject = scene_plan.get("subject", {})
|
54 |
+
layout = scene_plan.get("layout", {})
|
55 |
+
|
56 |
+
for i in range(num_variations):
|
57 |
+
enriched = f"{base_prompt}, in a {scene.get('environment', '')} setting with {scene.get('setting', '')}, featuring {subject.get('main_actor', '')}, layout includes"
|
58 |
+
|
59 |
+
# Foreground
|
60 |
+
fg = layout.get("foreground", {}).get("elements", [])
|
61 |
+
fg_text = ", ".join([f"{el['type']} at {el['position']}" for el in fg if 'type' in el and 'position' in el])
|
62 |
+
enriched += f" {fg_text} in foreground,"
|
63 |
+
|
64 |
+
# Background
|
65 |
+
bg = layout.get("background", {}).get("elements", [])
|
66 |
+
bg_text = ", ".join([f"{el['type']} at {el['position']}" for el in bg if 'type' in el and 'position' in el])
|
67 |
+
enriched += f" {bg_text} in background"
|
68 |
+
|
69 |
+
enriched += f", style variation {i+1}"
|
70 |
+
variations.append(enriched.strip())
|
71 |
+
|
72 |
+
return variations
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
# ----------------------------
|
77 |
# 🎨 Image Generation Function
|
78 |
# ----------------------------
|