Spaces:
Sleeping
Sleeping
Lcmind commited on
Commit ·
0dc7e5f
1
Parent(s): 0e36c16
refactor: apply Minimalist Brand Director prompt with Hero Object and category-based styling
Browse files- app/services/flux.py +38 -17
- app/services/gemini.py +20 -19
app/services/flux.py
CHANGED
|
@@ -21,39 +21,60 @@ async def generate_poster(analysis: dict) -> str:
|
|
| 21 |
"""
|
| 22 |
# Construct detailed prompt for Flux
|
| 23 |
title = analysis.get('title', 'Brand')
|
|
|
|
|
|
|
| 24 |
atmosphere = analysis.get('atmosphere', 'modern and clean aesthetic')
|
| 25 |
primary_color = analysis.get('primary_color', '#000000')
|
| 26 |
accent_color = analysis.get('accent_color', '#FFFFFF')
|
| 27 |
keywords = ', '.join(analysis.get('keywords', ['modern', 'minimal']))
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
prompt = f"""
|
| 30 |
-
A high-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
-
|
| 34 |
-
-
|
| 35 |
-
-
|
| 36 |
-
- NO buttons, NO browser elements, NO screenshots
|
| 37 |
|
| 38 |
-
|
| 39 |
-
-
|
| 40 |
-
-
|
| 41 |
-
- Position:
|
| 42 |
- ENGLISH ONLY (no Korean characters)
|
| 43 |
|
| 44 |
-
COLOR PALETTE:
|
| 45 |
- Primary: {primary_color}
|
| 46 |
- Accent: {accent_color}
|
| 47 |
-
-
|
| 48 |
|
| 49 |
-
STYLE
|
| 50 |
-
-
|
| 51 |
- Keywords: {keywords}
|
| 52 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
- Cinematic composition, award-winning design
|
| 54 |
-
|
|
|
|
| 55 |
"""
|
| 56 |
-
|
|
|
|
| 57 |
|
| 58 |
# Use new HF router endpoint directly
|
| 59 |
headers = {
|
|
|
|
| 21 |
"""
|
| 22 |
# Construct detailed prompt for Flux
|
| 23 |
title = analysis.get('title', 'Brand')
|
| 24 |
+
category = analysis.get('category', 'Productivity')
|
| 25 |
+
hero_object = analysis.get('hero_object', 'a floating glass cube')
|
| 26 |
atmosphere = analysis.get('atmosphere', 'modern and clean aesthetic')
|
| 27 |
primary_color = analysis.get('primary_color', '#000000')
|
| 28 |
accent_color = analysis.get('accent_color', '#FFFFFF')
|
| 29 |
keywords = ', '.join(analysis.get('keywords', ['modern', 'minimal']))
|
| 30 |
|
| 31 |
+
# Category-specific style rules
|
| 32 |
+
if category == 'Productivity':
|
| 33 |
+
style_keywords = "Apple Style, Dieter Rams, Frosted Glass, Soft Studio Lighting, Minimalist, Zen, Spacious, Air"
|
| 34 |
+
negative_additions = "NO cluttered elements, NO complex machinery, NO glitch effects, NO random messy lines"
|
| 35 |
+
elif category == 'Dev':
|
| 36 |
+
style_keywords = "Matrix style, Clean dark mode, Terminal aesthetic, Code-inspired"
|
| 37 |
+
negative_additions = ""
|
| 38 |
+
elif category == 'Creative':
|
| 39 |
+
style_keywords = "Colorful, Abstract, Artistic, Expressive"
|
| 40 |
+
negative_additions = ""
|
| 41 |
+
else:
|
| 42 |
+
style_keywords = "Modern, Professional, Clean"
|
| 43 |
+
negative_additions = ""
|
| 44 |
+
|
| 45 |
prompt = f"""
|
| 46 |
+
A high-end vertical commercial poster design (9:16 aspect ratio, 768x1344px).
|
| 47 |
|
| 48 |
+
COMPOSITION (MANDATORY):
|
| 49 |
+
- **Center Composition:** Place '{hero_object}' in the center
|
| 50 |
+
- **Negative Space:** Leave 40% of the image empty (clean background) to symbolize calmness
|
| 51 |
+
- **Hero Object:** {hero_object}
|
|
|
|
| 52 |
|
| 53 |
+
BRAND TEXT:
|
| 54 |
+
- The word '{title}' formed by a 3D object (glowing neon tube floating in air, or engraved in metal)
|
| 55 |
+
- Font style: Swiss Typography, Clean Sans-serif
|
| 56 |
+
- Position: Top-center or integrated with hero object
|
| 57 |
- ENGLISH ONLY (no Korean characters)
|
| 58 |
|
| 59 |
+
COLOR PALETTE (STRICT):
|
| 60 |
- Primary: {primary_color}
|
| 61 |
- Accent: {accent_color}
|
| 62 |
+
- Use gradients or solid backgrounds only
|
| 63 |
|
| 64 |
+
STYLE ENFORCERS:
|
| 65 |
+
- {style_keywords}
|
| 66 |
- Keywords: {keywords}
|
| 67 |
+
- Atmosphere: {atmosphere}
|
| 68 |
+
|
| 69 |
+
QUALITY BOOSTERS:
|
| 70 |
+
- Unreal Engine 5, 8K, Octane Render, Ray Tracing
|
| 71 |
+
- Super-Resolution, Anti-Aliasing
|
| 72 |
- Cinematic composition, award-winning design
|
| 73 |
+
|
| 74 |
+
CATEGORY: {category}
|
| 75 |
"""
|
| 76 |
+
|
| 77 |
+
negative_prompt = f"text, letters, words, typography, watermark, signature, blurry, low quality, photograph, realistic, 3d render, {negative_additions}"
|
| 78 |
|
| 79 |
# Use new HF router endpoint directly
|
| 80 |
headers = {
|
app/services/gemini.py
CHANGED
|
@@ -27,33 +27,34 @@ async def analyze_with_gemini(screenshot_path: str) -> dict:
|
|
| 27 |
img = Image.open(screenshot_path)
|
| 28 |
|
| 29 |
prompt = """
|
| 30 |
-
You are
|
| 31 |
-
Your mission is to
|
| 32 |
|
| 33 |
-
***
|
| 34 |
-
Do not just look at the colors. You must **READ the text (OCR)** and **INTERPRET the purpose**.
|
| 35 |
|
| 36 |
-
1. **
|
| 37 |
-
-
|
| 38 |
-
- **
|
| 39 |
-
-
|
| 40 |
-
-
|
| 41 |
-
- *
|
| 42 |
|
| 43 |
-
2. **
|
| 44 |
-
-
|
| 45 |
-
-
|
|
|
|
| 46 |
|
| 47 |
-
3. **
|
| 48 |
-
- **Name:**
|
| 49 |
-
|
| 50 |
-
- **Color Psychology:** What mood do the colors convey? (Trust, Passion, Calm).
|
| 51 |
|
| 52 |
*** OUTPUT FORMAT (JSON ONLY) ***
|
| 53 |
{
|
| 54 |
"title": "Core brand keyword in 1-2 words (ENGLISH ONLY)",
|
| 55 |
-
"
|
| 56 |
-
"
|
|
|
|
|
|
|
| 57 |
"accent_color": "Accent color hex code",
|
| 58 |
"keywords": ["keyword1", "keyword2", "keyword3", "keyword4", "keyword5"]
|
| 59 |
}
|
|
|
|
| 27 |
img = Image.open(screenshot_path)
|
| 28 |
|
| 29 |
prompt = """
|
| 30 |
+
You are a **Minimalist Brand Director** (think Apple or Dieter Rams style).
|
| 31 |
+
Your mission is to analyze the website screenshot and extract its "Visual Soul" for a high-end poster.
|
| 32 |
|
| 33 |
+
*** CRITICAL ANALYSIS PROTOCOL ***
|
|
|
|
| 34 |
|
| 35 |
+
1. **READ THE TEXT & CONTEXT (OCR):**
|
| 36 |
+
- Look for keywords: "Focus", "Task", "Simple", "Flow", "Team".
|
| 37 |
+
- **JUDGMENT:**
|
| 38 |
+
- If it's a **Productivity/Tool** (like FocusHub): The visual MUST be **Clean, Organized, Zen, Glass-like**. (FORBIDDEN: Chaos, messy wires, glitch art).
|
| 39 |
+
- If it's **Creative/Art**: Colorful and abstract is okay.
|
| 40 |
+
- If it's **Dev/Code**: Matrix style or clean dark mode is okay.
|
| 41 |
|
| 42 |
+
2. **VISUAL ANCHOR (The Main Subject):**
|
| 43 |
+
- Don't just say "abstract background". Define a **Single "Hero Object"**.
|
| 44 |
+
- *Good Examples:* "A single perfect crystal cube", "A glowing ring of light", "A floating glass sheet".
|
| 45 |
+
- *Bad Examples:* "Complex city", "Random shapes", "Circuit board patterns".
|
| 46 |
|
| 47 |
+
3. **BRAND IDENTITY:**
|
| 48 |
+
- **Name:** If Korean detected, Romanize it (e.g., '집중' -> 'FOCUS').
|
| 49 |
+
- **Color:** Strict adherence to the site's dominant color (e.g., Deep Blue -> keep it Blue/Indigo, don't add random Pink/Purple).
|
|
|
|
| 50 |
|
| 51 |
*** OUTPUT FORMAT (JSON ONLY) ***
|
| 52 |
{
|
| 53 |
"title": "Core brand keyword in 1-2 words (ENGLISH ONLY)",
|
| 54 |
+
"category": "One of: Productivity, Creative, Dev, Commerce, Social",
|
| 55 |
+
"hero_object": "Single concrete visual element for the poster (e.g., 'floating glass cube')",
|
| 56 |
+
"atmosphere": "Visual mood description in 20 words (ENGLISH)",
|
| 57 |
+
"primary_color": "Main color hex code (from website)",
|
| 58 |
"accent_color": "Accent color hex code",
|
| 59 |
"keywords": ["keyword1", "keyword2", "keyword3", "keyword4", "keyword5"]
|
| 60 |
}
|