Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -89,6 +89,7 @@ def enhance_prompt_with_team(user_input):
|
|
| 89 |
- Creates detailed visual specifications
|
| 90 |
- Specifies exact materials, finishes, colors
|
| 91 |
- Defines rendering style and atmosphere
|
|
|
|
| 92 |
|
| 93 |
## OUTPUT FORMAT:
|
| 94 |
|
|
@@ -99,9 +100,14 @@ def enhance_prompt_with_team(user_input):
|
|
| 99 |
[Based on search data, provide 3-4 technical recommendations]
|
| 100 |
|
| 101 |
**DESIGNER'S FINAL PROMPT:**
|
| 102 |
-
[Detailed visual description
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
-
Keep responses concise but specific. Focus on PHYSICAL PRODUCTS only."""
|
| 105 |
|
| 106 |
# Create collaborative prompt with search results
|
| 107 |
user_prompt = f"""Product concept: {user_input}
|
|
@@ -112,9 +118,9 @@ ENGINEER'S RESEARCH DATA:
|
|
| 112 |
Based on this input and research, execute the team collaboration:
|
| 113 |
1. Director establishes vision (brief)
|
| 114 |
2. Engineer uses the research data above to recommend features
|
| 115 |
-
3. Designer creates a detailed visual prompt
|
| 116 |
|
| 117 |
-
Focus on creating a manufacturable, innovative product design."""
|
| 118 |
|
| 119 |
payload = {
|
| 120 |
"model": "accounts/fireworks/models/qwen3-235b-a22b-instruct-2507", # Original model maintained
|
|
@@ -165,17 +171,24 @@ Focus on creating a manufacturable, innovative product design."""
|
|
| 165 |
|
| 166 |
def create_basic_design_prompt(user_input):
|
| 167 |
"""
|
| 168 |
-
Fallback function for basic design prompt generation
|
| 169 |
"""
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
-
|
| 173 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
- Photorealistic rendering with studio lighting
|
| 175 |
-
-
|
| 176 |
-
-
|
| 177 |
-
- High
|
| 178 |
-
- Shown from 3/4 perspective
|
| 179 |
|
| 180 |
def upload_image_to_hosting(image):
|
| 181 |
"""
|
|
@@ -259,10 +272,13 @@ def process_product_design(prompt, enhance_prompt_flag, image1, image2=None):
|
|
| 259 |
|
| 260 |
# Generate image with Replicate
|
| 261 |
try:
|
|
|
|
|
|
|
|
|
|
| 262 |
output = replicate.run(
|
| 263 |
"black-forest-labs/flux-schnell", # Alternative model that works better
|
| 264 |
input={
|
| 265 |
-
"prompt":
|
| 266 |
"num_outputs": 1,
|
| 267 |
"aspect_ratio": "1:1",
|
| 268 |
"output_format": "webp",
|
|
@@ -270,12 +286,14 @@ def process_product_design(prompt, enhance_prompt_flag, image1, image2=None):
|
|
| 270 |
}
|
| 271 |
)
|
| 272 |
except:
|
| 273 |
-
# Fallback to original model
|
|
|
|
|
|
|
| 274 |
output = replicate.run(
|
| 275 |
"stability-ai/sdxl:39ed52f2a78e934b3ba6e2a89f5b1c712de7dfea535525255b1aa35c5565e08b",
|
| 276 |
input={
|
| 277 |
-
"prompt":
|
| 278 |
-
"negative_prompt": "low quality, blurry, distorted",
|
| 279 |
"width": 1024,
|
| 280 |
"height": 1024,
|
| 281 |
"num_outputs": 1
|
|
@@ -431,20 +449,21 @@ with gr.Blocks(css=css, theme=gr.themes.Base()) as demo:
|
|
| 431 |
with gr.Column(elem_classes="header-container"):
|
| 432 |
gr.HTML("""
|
| 433 |
<h1 class="logo-text">π PRODUCT DESIGN STUDIO</h1>
|
| 434 |
-
<p class="subtitle">AI-Powered Industrial
|
| 435 |
<div class="mode-indicator">
|
| 436 |
-
π₯ Director β π Engineer (
|
| 437 |
</div>
|
| 438 |
""")
|
| 439 |
|
| 440 |
with gr.Column(elem_classes="main-content"):
|
| 441 |
gr.HTML("""
|
| 442 |
<div class="info-box">
|
| 443 |
-
<strong>π― Professional Product Design Process:</strong><br>
|
| 444 |
β’ <b>Director:</b> Establishes vision and requirements<br>
|
| 445 |
β’ <b>Engineer:</b> Searches current trends & technologies via Brave API<br>
|
| 446 |
-
β’ <b>Designer:</b> Creates
|
| 447 |
-
β’ <b>
|
|
|
|
| 448 |
</div>
|
| 449 |
""")
|
| 450 |
|
|
|
|
| 89 |
- Creates detailed visual specifications
|
| 90 |
- Specifies exact materials, finishes, colors
|
| 91 |
- Defines rendering style and atmosphere
|
| 92 |
+
- MUST include text labels and annotations in the design
|
| 93 |
|
| 94 |
## OUTPUT FORMAT:
|
| 95 |
|
|
|
|
| 100 |
[Based on search data, provide 3-4 technical recommendations]
|
| 101 |
|
| 102 |
**DESIGNER'S FINAL PROMPT:**
|
| 103 |
+
[Detailed visual description INCLUDING text labels and annotations. MUST specify:
|
| 104 |
+
- Product name/model as title text
|
| 105 |
+
- Key feature callouts with arrow annotations
|
| 106 |
+
- Technical specifications as overlay text
|
| 107 |
+
- Material/component labels
|
| 108 |
+
Example: "with text overlay showing 'MODEL X-500' at top, feature callouts pointing to 'Titanium Frame', 'OLED Display', '5000mAh Battery' with arrows"]
|
| 109 |
|
| 110 |
+
Keep responses concise but specific. Focus on PHYSICAL PRODUCTS only with TEXT ANNOTATIONS."""
|
| 111 |
|
| 112 |
# Create collaborative prompt with search results
|
| 113 |
user_prompt = f"""Product concept: {user_input}
|
|
|
|
| 118 |
Based on this input and research, execute the team collaboration:
|
| 119 |
1. Director establishes vision (brief)
|
| 120 |
2. Engineer uses the research data above to recommend features
|
| 121 |
+
3. Designer creates a detailed visual prompt WITH TEXT LABELS AND ANNOTATIONS
|
| 122 |
|
| 123 |
+
Focus on creating a manufacturable, innovative product design with clear text overlays showing key features, specifications, and component labels."""
|
| 124 |
|
| 125 |
payload = {
|
| 126 |
"model": "accounts/fireworks/models/qwen3-235b-a22b-instruct-2507", # Original model maintained
|
|
|
|
| 171 |
|
| 172 |
def create_basic_design_prompt(user_input):
|
| 173 |
"""
|
| 174 |
+
Fallback function for basic design prompt generation with text annotations
|
| 175 |
"""
|
| 176 |
+
product_name = user_input.upper().replace(" ", "-")
|
| 177 |
+
return f"""A professional product design concept for {user_input} with detailed text annotations:
|
| 178 |
+
- Product title text overlay: "{product_name} PRO 2025" in bold modern font at top
|
| 179 |
+
- Feature callout labels with arrows pointing to key components:
|
| 180 |
+
* "Premium Materials" β body
|
| 181 |
+
* "Ergonomic Design" β form factor
|
| 182 |
+
* "Smart Integration" β control panel
|
| 183 |
+
* "Sustainable Manufacturing" β eco-friendly elements
|
| 184 |
+
- Technical specifications text overlay in corner:
|
| 185 |
+
* Dimensions, weight, power specs
|
| 186 |
+
- Clean industrial design with annotations
|
| 187 |
- Photorealistic rendering with studio lighting
|
| 188 |
+
- Professional product photography style with infographic elements
|
| 189 |
+
- Text labels in clean sans-serif font (Helvetica/Arial style)
|
| 190 |
+
- High contrast text for readability
|
| 191 |
+
- Shown from 3/4 perspective with all labels clearly visible"""
|
| 192 |
|
| 193 |
def upload_image_to_hosting(image):
|
| 194 |
"""
|
|
|
|
| 272 |
|
| 273 |
# Generate image with Replicate
|
| 274 |
try:
|
| 275 |
+
# Add text annotation emphasis to the prompt
|
| 276 |
+
annotated_prompt = f"{final_prompt}. Include clear text labels, feature callouts with arrows, product name/model as title, technical specifications overlay, component annotations in clean modern typography"
|
| 277 |
+
|
| 278 |
output = replicate.run(
|
| 279 |
"black-forest-labs/flux-schnell", # Alternative model that works better
|
| 280 |
input={
|
| 281 |
+
"prompt": annotated_prompt,
|
| 282 |
"num_outputs": 1,
|
| 283 |
"aspect_ratio": "1:1",
|
| 284 |
"output_format": "webp",
|
|
|
|
| 286 |
}
|
| 287 |
)
|
| 288 |
except:
|
| 289 |
+
# Fallback to original model with text annotations
|
| 290 |
+
annotated_prompt = f"{final_prompt}. With text overlays showing product name, key features with arrow callouts, specifications, and component labels in professional typography"
|
| 291 |
+
|
| 292 |
output = replicate.run(
|
| 293 |
"stability-ai/sdxl:39ed52f2a78e934b3ba6e2a89f5b1c712de7dfea535525255b1aa35c5565e08b",
|
| 294 |
input={
|
| 295 |
+
"prompt": annotated_prompt,
|
| 296 |
+
"negative_prompt": "low quality, blurry, distorted, unreadable text, messy labels",
|
| 297 |
"width": 1024,
|
| 298 |
"height": 1024,
|
| 299 |
"num_outputs": 1
|
|
|
|
| 449 |
with gr.Column(elem_classes="header-container"):
|
| 450 |
gr.HTML("""
|
| 451 |
<h1 class="logo-text">π PRODUCT DESIGN STUDIO</h1>
|
| 452 |
+
<p class="subtitle">AI-Powered Industrial Design with Annotated Feature Guides</p>
|
| 453 |
<div class="mode-indicator">
|
| 454 |
+
π₯ Director β π Engineer (Research) β π¨ Designer (with Text Annotations)
|
| 455 |
</div>
|
| 456 |
""")
|
| 457 |
|
| 458 |
with gr.Column(elem_classes="main-content"):
|
| 459 |
gr.HTML("""
|
| 460 |
<div class="info-box">
|
| 461 |
+
<strong>π― Professional Product Design Process with Annotations:</strong><br>
|
| 462 |
β’ <b>Director:</b> Establishes vision and requirements<br>
|
| 463 |
β’ <b>Engineer:</b> Searches current trends & technologies via Brave API<br>
|
| 464 |
+
β’ <b>Designer:</b> Creates visual specs with <b>text labels & feature callouts</b><br>
|
| 465 |
+
β’ <b>Output:</b> Annotated product designs with key features highlighted<br>
|
| 466 |
+
β’ <b>Focus:</b> Physical products with infographic-style annotations
|
| 467 |
</div>
|
| 468 |
""")
|
| 469 |
|