Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,9 +7,79 @@ from io import BytesIO
|
|
7 |
import time
|
8 |
import tempfile
|
9 |
import base64
|
|
|
10 |
|
11 |
-
# Set up
|
12 |
os.environ['REPLICATE_API_TOKEN'] = os.getenv('REPLICATE_API_TOKEN')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
def upload_image_to_hosting(image):
|
15 |
"""
|
@@ -58,17 +128,22 @@ def upload_image_to_hosting(image):
|
|
58 |
img_base64 = base64.b64encode(buffered.getvalue()).decode()
|
59 |
return f"data:image/png;base64,{img_base64}"
|
60 |
|
61 |
-
def process_images(prompt, image1, image2=None):
|
62 |
"""
|
63 |
-
Process with
|
64 |
"""
|
65 |
if not os.getenv('REPLICATE_API_TOKEN'):
|
66 |
-
return None, "Please set REPLICATE_API_TOKEN"
|
67 |
|
68 |
try:
|
69 |
-
#
|
|
|
|
|
|
|
|
|
|
|
70 |
model_input = {
|
71 |
-
"prompt":
|
72 |
}
|
73 |
|
74 |
# Only add image_input if images are provided
|
@@ -84,26 +159,26 @@ def process_images(prompt, image1, image2=None):
|
|
84 |
image_urls.append(url2)
|
85 |
|
86 |
model_input["image_input"] = image_urls
|
87 |
-
status_msg = "✨
|
88 |
else:
|
89 |
-
# No images - text-only generation
|
90 |
-
status_msg = "✨
|
91 |
|
92 |
-
# Run
|
93 |
output = replicate.run(
|
94 |
"google/nano-banana",
|
95 |
input=model_input
|
96 |
)
|
97 |
|
98 |
if output is None:
|
99 |
-
return None, "No output received"
|
100 |
|
101 |
# Get the generated image
|
102 |
try:
|
103 |
if hasattr(output, 'read'):
|
104 |
img_data = output.read()
|
105 |
img = Image.open(BytesIO(img_data))
|
106 |
-
return img, status_msg
|
107 |
except:
|
108 |
pass
|
109 |
|
@@ -113,7 +188,7 @@ def process_images(prompt, image1, image2=None):
|
|
113 |
response = requests.get(output_url, timeout=30)
|
114 |
if response.status_code == 200:
|
115 |
img = Image.open(BytesIO(response.content))
|
116 |
-
return img, status_msg
|
117 |
except:
|
118 |
pass
|
119 |
|
@@ -127,67 +202,67 @@ def process_images(prompt, image1, image2=None):
|
|
127 |
response = requests.get(output_url, timeout=30)
|
128 |
if response.status_code == 200:
|
129 |
img = Image.open(BytesIO(response.content))
|
130 |
-
return img, status_msg
|
131 |
|
132 |
-
return None, "Could not process output"
|
133 |
|
134 |
except Exception as e:
|
135 |
error_msg = str(e)
|
136 |
if "image_input" in error_msg.lower():
|
137 |
-
|
138 |
-
|
139 |
-
return None, f"Error: {error_msg[:100]}"
|
140 |
|
141 |
-
# Enhanced CSS with
|
142 |
css = """
|
143 |
.gradio-container {
|
144 |
-
background: linear-gradient(135deg, #
|
145 |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
146 |
min-height: 100vh;
|
147 |
}
|
148 |
.header-container {
|
149 |
-
background: linear-gradient(135deg, #
|
150 |
padding: 2.5rem;
|
151 |
border-radius: 24px;
|
152 |
margin-bottom: 2.5rem;
|
153 |
-
box-shadow: 0 20px 60px rgba(
|
154 |
}
|
155 |
.logo-text {
|
156 |
font-size: 3.5rem;
|
157 |
font-weight: 900;
|
158 |
-
color:
|
159 |
text-align: center;
|
160 |
margin: 0;
|
161 |
letter-spacing: -2px;
|
|
|
162 |
}
|
163 |
.subtitle {
|
164 |
-
color:
|
165 |
text-align: center;
|
166 |
-
font-size: 1rem;
|
167 |
margin-top: 0.5rem;
|
168 |
-
opacity: 0.
|
169 |
}
|
170 |
.mode-indicator {
|
171 |
-
background: rgba(255, 255, 255, 0.
|
172 |
backdrop-filter: blur(10px);
|
173 |
border-radius: 12px;
|
174 |
-
padding: 0.
|
175 |
margin-top: 1rem;
|
176 |
text-align: center;
|
177 |
font-weight: 600;
|
178 |
-
color:
|
179 |
}
|
180 |
.main-content {
|
181 |
-
background: rgba(255, 255, 255, 0.
|
182 |
backdrop-filter: blur(20px);
|
183 |
border-radius: 24px;
|
184 |
padding: 2.5rem;
|
185 |
-
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.
|
186 |
}
|
187 |
.gr-button-primary {
|
188 |
-
background: linear-gradient(135deg, #
|
189 |
border: none !important;
|
190 |
-
color:
|
191 |
font-weight: 700 !important;
|
192 |
font-size: 1.1rem !important;
|
193 |
padding: 1.2rem 2rem !important;
|
@@ -200,7 +275,7 @@ css = """
|
|
200 |
}
|
201 |
.gr-button-primary:hover {
|
202 |
transform: translateY(-3px) !important;
|
203 |
-
box-shadow: 0 15px 40px rgba(
|
204 |
}
|
205 |
.gr-input, .gr-textarea {
|
206 |
background: #ffffff !important;
|
@@ -211,8 +286,8 @@ css = """
|
|
211 |
padding: 0.8rem 1rem !important;
|
212 |
}
|
213 |
.gr-input:focus, .gr-textarea:focus {
|
214 |
-
border-color: #
|
215 |
-
box-shadow: 0 0 0 4px rgba(
|
216 |
}
|
217 |
.gr-form {
|
218 |
background: transparent !important;
|
@@ -250,7 +325,6 @@ label {
|
|
250 |
footer {
|
251 |
display: none !important;
|
252 |
}
|
253 |
-
/* Equal sizing for all image containers */
|
254 |
.image-upload {
|
255 |
min-height: 200px !important;
|
256 |
max-height: 200px !important;
|
@@ -259,7 +333,6 @@ footer {
|
|
259 |
min-height: 420px !important;
|
260 |
max-height: 420px !important;
|
261 |
}
|
262 |
-
/* Ensure consistent spacing */
|
263 |
.gr-row {
|
264 |
gap: 1rem !important;
|
265 |
}
|
@@ -267,37 +340,48 @@ footer {
|
|
267 |
gap: 1rem !important;
|
268 |
}
|
269 |
.info-box {
|
270 |
-
background: linear-gradient(135deg, #
|
271 |
border-radius: 12px;
|
272 |
padding: 1rem;
|
273 |
margin-bottom: 1rem;
|
274 |
-
border-left: 4px solid #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
}
|
276 |
"""
|
277 |
|
278 |
with gr.Blocks(css=css, theme=gr.themes.Base()) as demo:
|
279 |
with gr.Column(elem_classes="header-container"):
|
280 |
gr.HTML("""
|
281 |
-
<h1 class="logo-text"
|
282 |
-
<p class="subtitle">AI-Powered
|
283 |
<div class="mode-indicator">
|
284 |
-
💡
|
285 |
</div>
|
286 |
<div style="display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 20px;">
|
287 |
<a href="https://huggingface.co/spaces/ginigen/Nano-Banana-PRO" target="_blank">
|
288 |
-
<img src="https://img.shields.io/static/v1?label=
|
289 |
</a>
|
290 |
<a href="https://huggingface.co/spaces/openfree/Nano-Banana-Upscale" target="_blank">
|
291 |
-
<img src="https://img.shields.io/static/v1?label=
|
292 |
</a>
|
293 |
<a href="https://huggingface.co/spaces/aiqtech/Nano-Banana-API" target="_blank">
|
294 |
-
<img src="https://img.shields.io/static/v1?label=
|
295 |
</a>
|
296 |
<a href="https://huggingface.co/spaces/ginigen/Nano-Banana-Video" target="_blank">
|
297 |
-
<img src="https://img.shields.io/static/v1?label=
|
298 |
</a>
|
299 |
<a href="https://discord.gg/openfreeai" target="_blank">
|
300 |
-
<img src="https://img.shields.io/static/v1?label=Discord&message=Openfree%20AI&color=%
|
301 |
</a>
|
302 |
</div>
|
303 |
""")
|
@@ -306,10 +390,11 @@ with gr.Blocks(css=css, theme=gr.themes.Base()) as demo:
|
|
306 |
# Info box
|
307 |
gr.HTML("""
|
308 |
<div class="info-box">
|
309 |
-
<strong
|
310 |
-
• <b>
|
311 |
-
• <b>
|
312 |
-
•
|
|
|
313 |
</div>
|
314 |
""")
|
315 |
|
@@ -317,29 +402,35 @@ with gr.Blocks(css=css, theme=gr.themes.Base()) as demo:
|
|
317 |
# Left Column - Inputs
|
318 |
with gr.Column(scale=1):
|
319 |
prompt = gr.Textbox(
|
320 |
-
label="
|
321 |
-
placeholder="
|
322 |
lines=3,
|
323 |
-
value="
|
324 |
elem_classes="prompt-input"
|
325 |
)
|
326 |
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
with gr.Row(equal_height=True):
|
328 |
image1 = gr.Image(
|
329 |
-
label="
|
330 |
type="pil",
|
331 |
height=200,
|
332 |
elem_classes="image-container image-upload"
|
333 |
)
|
334 |
image2 = gr.Image(
|
335 |
-
label="
|
336 |
type="pil",
|
337 |
height=200,
|
338 |
elem_classes="image-container image-upload"
|
339 |
)
|
340 |
|
341 |
generate_btn = gr.Button(
|
342 |
-
"
|
343 |
variant="primary",
|
344 |
size="lg"
|
345 |
)
|
@@ -347,38 +438,50 @@ with gr.Blocks(css=css, theme=gr.themes.Base()) as demo:
|
|
347 |
# Right Column - Output
|
348 |
with gr.Column(scale=1):
|
349 |
output_image = gr.Image(
|
350 |
-
label="Generated
|
351 |
type="pil",
|
352 |
height=420,
|
353 |
elem_classes="image-container output-image"
|
354 |
)
|
355 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
status = gr.Textbox(
|
357 |
label="Status",
|
358 |
interactive=False,
|
359 |
lines=1,
|
360 |
elem_classes="status-text",
|
361 |
-
value="Ready to
|
362 |
)
|
363 |
|
364 |
# Event handler
|
365 |
generate_btn.click(
|
366 |
fn=process_images,
|
367 |
-
inputs=[prompt, image1, image2],
|
368 |
-
outputs=[output_image, status]
|
369 |
)
|
370 |
|
371 |
-
#
|
372 |
gr.Examples(
|
373 |
examples=[
|
374 |
-
["
|
375 |
-
["
|
376 |
-
["
|
377 |
-
["
|
378 |
-
["
|
|
|
|
|
|
|
379 |
],
|
380 |
-
inputs=[prompt, image1, image2],
|
381 |
-
label="
|
382 |
)
|
383 |
|
384 |
# Launch
|
|
|
7 |
import time
|
8 |
import tempfile
|
9 |
import base64
|
10 |
+
import json
|
11 |
|
12 |
+
# Set up API keys from environment variables
|
13 |
os.environ['REPLICATE_API_TOKEN'] = os.getenv('REPLICATE_API_TOKEN')
|
14 |
+
FIREWORKS_API_KEY = os.getenv('FIREWORKS_API_KEY', '')
|
15 |
+
|
16 |
+
def enhance_prompt(user_input):
|
17 |
+
"""
|
18 |
+
Enhance user prompt using Fireworks AI to create detailed creative design prompts
|
19 |
+
"""
|
20 |
+
if not FIREWORKS_API_KEY:
|
21 |
+
# If no API key, return the original prompt
|
22 |
+
return user_input
|
23 |
+
|
24 |
+
try:
|
25 |
+
url = "https://api.fireworks.ai/inference/v1/chat/completions"
|
26 |
+
|
27 |
+
system_prompt = """You are a creative design prompt engineer. Transform user input into detailed, creative design prompts.
|
28 |
+
Format your response as a structured design concept following this pattern:
|
29 |
+
- Start with a clear main concept description
|
30 |
+
- Include specific design elements with bullet points
|
31 |
+
- Mention materials, textures, or finishes
|
32 |
+
- Specify artistic style or rendering technique
|
33 |
+
- Add atmospheric or contextual details
|
34 |
+
|
35 |
+
Example format:
|
36 |
+
"A sleek industrial design concept for [object]:
|
37 |
+
- Curved metallic body with minimal bezel
|
38 |
+
- Touchscreen panel for settings
|
39 |
+
- Modern matte black finish
|
40 |
+
- Hand-drawn concept sketch style"
|
41 |
+
|
42 |
+
Be creative, detailed, and specific. Focus on visual design elements."""
|
43 |
+
|
44 |
+
payload = {
|
45 |
+
"model": "accounts/fireworks/models/qwen3-235b-a22b-instruct-2507",
|
46 |
+
"max_tokens": 300,
|
47 |
+
"top_p": 1,
|
48 |
+
"top_k": 40,
|
49 |
+
"presence_penalty": 0,
|
50 |
+
"frequency_penalty": 0,
|
51 |
+
"temperature": 0.7,
|
52 |
+
"messages": [
|
53 |
+
{
|
54 |
+
"role": "system",
|
55 |
+
"content": system_prompt
|
56 |
+
},
|
57 |
+
{
|
58 |
+
"role": "user",
|
59 |
+
"content": f"Create a detailed creative design prompt for: {user_input}"
|
60 |
+
}
|
61 |
+
]
|
62 |
+
}
|
63 |
+
|
64 |
+
headers = {
|
65 |
+
"Accept": "application/json",
|
66 |
+
"Content-Type": "application/json",
|
67 |
+
"Authorization": f"Bearer {FIREWORKS_API_KEY}"
|
68 |
+
}
|
69 |
+
|
70 |
+
response = requests.post(url, headers=headers, data=json.dumps(payload), timeout=10)
|
71 |
+
|
72 |
+
if response.status_code == 200:
|
73 |
+
result = response.json()
|
74 |
+
enhanced = result.get('choices', [{}])[0].get('message', {}).get('content', '')
|
75 |
+
if enhanced:
|
76 |
+
return enhanced
|
77 |
+
|
78 |
+
return user_input
|
79 |
+
|
80 |
+
except Exception as e:
|
81 |
+
print(f"Prompt enhancement error: {str(e)}")
|
82 |
+
return user_input
|
83 |
|
84 |
def upload_image_to_hosting(image):
|
85 |
"""
|
|
|
128 |
img_base64 = base64.b64encode(buffered.getvalue()).decode()
|
129 |
return f"data:image/png;base64,{img_base64}"
|
130 |
|
131 |
+
def process_images(prompt, enhance_prompt_flag, image1, image2=None):
|
132 |
"""
|
133 |
+
Process with Creative Design - works with or without images
|
134 |
"""
|
135 |
if not os.getenv('REPLICATE_API_TOKEN'):
|
136 |
+
return None, prompt, "Please set REPLICATE_API_TOKEN"
|
137 |
|
138 |
try:
|
139 |
+
# Enhance prompt if requested
|
140 |
+
final_prompt = prompt
|
141 |
+
if enhance_prompt_flag:
|
142 |
+
final_prompt = enhance_prompt(prompt)
|
143 |
+
|
144 |
+
# Prepare input for model
|
145 |
model_input = {
|
146 |
+
"prompt": final_prompt
|
147 |
}
|
148 |
|
149 |
# Only add image_input if images are provided
|
|
|
159 |
image_urls.append(url2)
|
160 |
|
161 |
model_input["image_input"] = image_urls
|
162 |
+
status_msg = "✨ Creative design generated with style transfer!"
|
163 |
else:
|
164 |
+
# No images - text-only generation
|
165 |
+
status_msg = "✨ Creative design generated from text!"
|
166 |
|
167 |
+
# Run model
|
168 |
output = replicate.run(
|
169 |
"google/nano-banana",
|
170 |
input=model_input
|
171 |
)
|
172 |
|
173 |
if output is None:
|
174 |
+
return None, final_prompt, "No output received"
|
175 |
|
176 |
# Get the generated image
|
177 |
try:
|
178 |
if hasattr(output, 'read'):
|
179 |
img_data = output.read()
|
180 |
img = Image.open(BytesIO(img_data))
|
181 |
+
return img, final_prompt, status_msg
|
182 |
except:
|
183 |
pass
|
184 |
|
|
|
188 |
response = requests.get(output_url, timeout=30)
|
189 |
if response.status_code == 200:
|
190 |
img = Image.open(BytesIO(response.content))
|
191 |
+
return img, final_prompt, status_msg
|
192 |
except:
|
193 |
pass
|
194 |
|
|
|
202 |
response = requests.get(output_url, timeout=30)
|
203 |
if response.status_code == 200:
|
204 |
img = Image.open(BytesIO(response.content))
|
205 |
+
return img, final_prompt, status_msg
|
206 |
|
207 |
+
return None, final_prompt, "Could not process output"
|
208 |
|
209 |
except Exception as e:
|
210 |
error_msg = str(e)
|
211 |
if "image_input" in error_msg.lower():
|
212 |
+
return None, prompt, "Note: This model may require at least one image. Try uploading an image or check the error: " + error_msg[:100]
|
213 |
+
return None, prompt, f"Error: {error_msg[:100]}"
|
|
|
214 |
|
215 |
+
# Enhanced CSS with Creative Design theme
|
216 |
css = """
|
217 |
.gradio-container {
|
218 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
219 |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
220 |
min-height: 100vh;
|
221 |
}
|
222 |
.header-container {
|
223 |
+
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
|
224 |
padding: 2.5rem;
|
225 |
border-radius: 24px;
|
226 |
margin-bottom: 2.5rem;
|
227 |
+
box-shadow: 0 20px 60px rgba(240, 147, 251, 0.35);
|
228 |
}
|
229 |
.logo-text {
|
230 |
font-size: 3.5rem;
|
231 |
font-weight: 900;
|
232 |
+
color: white;
|
233 |
text-align: center;
|
234 |
margin: 0;
|
235 |
letter-spacing: -2px;
|
236 |
+
text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
|
237 |
}
|
238 |
.subtitle {
|
239 |
+
color: white;
|
240 |
text-align: center;
|
241 |
+
font-size: 1.1rem;
|
242 |
margin-top: 0.5rem;
|
243 |
+
opacity: 0.95;
|
244 |
}
|
245 |
.mode-indicator {
|
246 |
+
background: rgba(255, 255, 255, 0.25);
|
247 |
backdrop-filter: blur(10px);
|
248 |
border-radius: 12px;
|
249 |
+
padding: 0.6rem 1.2rem;
|
250 |
margin-top: 1rem;
|
251 |
text-align: center;
|
252 |
font-weight: 600;
|
253 |
+
color: white;
|
254 |
}
|
255 |
.main-content {
|
256 |
+
background: rgba(255, 255, 255, 0.97);
|
257 |
backdrop-filter: blur(20px);
|
258 |
border-radius: 24px;
|
259 |
padding: 2.5rem;
|
260 |
+
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
|
261 |
}
|
262 |
.gr-button-primary {
|
263 |
+
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%) !important;
|
264 |
border: none !important;
|
265 |
+
color: white !important;
|
266 |
font-weight: 700 !important;
|
267 |
font-size: 1.1rem !important;
|
268 |
padding: 1.2rem 2rem !important;
|
|
|
275 |
}
|
276 |
.gr-button-primary:hover {
|
277 |
transform: translateY(-3px) !important;
|
278 |
+
box-shadow: 0 15px 40px rgba(245, 87, 108, 0.4) !important;
|
279 |
}
|
280 |
.gr-input, .gr-textarea {
|
281 |
background: #ffffff !important;
|
|
|
286 |
padding: 0.8rem 1rem !important;
|
287 |
}
|
288 |
.gr-input:focus, .gr-textarea:focus {
|
289 |
+
border-color: #f093fb !important;
|
290 |
+
box-shadow: 0 0 0 4px rgba(240, 147, 251, 0.15) !important;
|
291 |
}
|
292 |
.gr-form {
|
293 |
background: transparent !important;
|
|
|
325 |
footer {
|
326 |
display: none !important;
|
327 |
}
|
|
|
328 |
.image-upload {
|
329 |
min-height: 200px !important;
|
330 |
max-height: 200px !important;
|
|
|
333 |
min-height: 420px !important;
|
334 |
max-height: 420px !important;
|
335 |
}
|
|
|
336 |
.gr-row {
|
337 |
gap: 1rem !important;
|
338 |
}
|
|
|
340 |
gap: 1rem !important;
|
341 |
}
|
342 |
.info-box {
|
343 |
+
background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
|
344 |
border-radius: 12px;
|
345 |
padding: 1rem;
|
346 |
margin-bottom: 1rem;
|
347 |
+
border-left: 4px solid #f5576c;
|
348 |
+
color: #2d3436;
|
349 |
+
}
|
350 |
+
.enhanced-prompt-box {
|
351 |
+
background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
|
352 |
+
border-radius: 12px;
|
353 |
+
padding: 1rem;
|
354 |
+
margin-top: 1rem;
|
355 |
+
border-left: 4px solid #f093fb;
|
356 |
+
}
|
357 |
+
.gr-checkbox {
|
358 |
+
background: white !important;
|
359 |
}
|
360 |
"""
|
361 |
|
362 |
with gr.Blocks(css=css, theme=gr.themes.Base()) as demo:
|
363 |
with gr.Column(elem_classes="header-container"):
|
364 |
gr.HTML("""
|
365 |
+
<h1 class="logo-text">🎨 Creative Design</h1>
|
366 |
+
<p class="subtitle">AI-Powered Creative Design Generation & Style Transfer</p>
|
367 |
<div class="mode-indicator">
|
368 |
+
💡 Intelligent prompt enhancement for stunning creative designs!
|
369 |
</div>
|
370 |
<div style="display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 20px;">
|
371 |
<a href="https://huggingface.co/spaces/ginigen/Nano-Banana-PRO" target="_blank">
|
372 |
+
<img src="https://img.shields.io/static/v1?label=CREATIVE%20DESIGN&message=PRO&color=%23f093fb&labelColor=%23764ba2&logo=HUGGINGFACE&logoColor=white&style=for-the-badge" alt="badge">
|
373 |
</a>
|
374 |
<a href="https://huggingface.co/spaces/openfree/Nano-Banana-Upscale" target="_blank">
|
375 |
+
<img src="https://img.shields.io/static/v1?label=CREATIVE%20DESIGN&message=UPSCALE&color=%23f093fb&labelColor=%23764ba2&logo=GOOGLE&logoColor=white&style=for-the-badge" alt="Creative Design Upscale">
|
376 |
</a>
|
377 |
<a href="https://huggingface.co/spaces/aiqtech/Nano-Banana-API" target="_blank">
|
378 |
+
<img src="https://img.shields.io/static/v1?label=CREATIVE%20DESIGN&message=API&color=%23f093fb&labelColor=%23764ba2&logo=GOOGLE&logoColor=white&style=for-the-badge" alt="Creative Design API">
|
379 |
</a>
|
380 |
<a href="https://huggingface.co/spaces/ginigen/Nano-Banana-Video" target="_blank">
|
381 |
+
<img src="https://img.shields.io/static/v1?label=CREATIVE%20DESIGN&message=VIDEO&color=%23f093fb&labelColor=%23764ba2&logo=GOOGLE&logoColor=white&style=for-the-badge" alt="Creative Design VIDEO">
|
382 |
</a>
|
383 |
<a href="https://discord.gg/openfreeai" target="_blank">
|
384 |
+
<img src="https://img.shields.io/static/v1?label=Discord&message=Openfree%20AI&color=%23f093fb&labelColor=%23764ba2&logo=discord&logoColor=white&style=for-the-badge" alt="Discord Openfree AI">
|
385 |
</a>
|
386 |
</div>
|
387 |
""")
|
|
|
390 |
# Info box
|
391 |
gr.HTML("""
|
392 |
<div class="info-box">
|
393 |
+
<strong>🚀 How to use Creative Design:</strong><br>
|
394 |
+
• <b>Simple Input:</b> Enter a basic idea or concept<br>
|
395 |
+
• <b>AI Enhancement:</b> Enable prompt enhancement for detailed creative designs<br>
|
396 |
+
• <b>Style Transfer:</b> Add images to apply specific visual styles<br>
|
397 |
+
• The AI transforms simple ideas into professional design concepts!
|
398 |
</div>
|
399 |
""")
|
400 |
|
|
|
402 |
# Left Column - Inputs
|
403 |
with gr.Column(scale=1):
|
404 |
prompt = gr.Textbox(
|
405 |
+
label="Design Concept / Idea",
|
406 |
+
placeholder="e.g., 'modern coffee machine', 'futuristic chair', 'minimalist lamp'...",
|
407 |
lines=3,
|
408 |
+
value="sleek smartphone design",
|
409 |
elem_classes="prompt-input"
|
410 |
)
|
411 |
|
412 |
+
enhance_prompt_checkbox = gr.Checkbox(
|
413 |
+
label="🎨 Enhance Prompt with AI (Create detailed design prompt)",
|
414 |
+
value=True,
|
415 |
+
info="Transform simple ideas into professional design prompts"
|
416 |
+
)
|
417 |
+
|
418 |
with gr.Row(equal_height=True):
|
419 |
image1 = gr.Image(
|
420 |
+
label="Style Reference 1 (Optional)",
|
421 |
type="pil",
|
422 |
height=200,
|
423 |
elem_classes="image-container image-upload"
|
424 |
)
|
425 |
image2 = gr.Image(
|
426 |
+
label="Style Reference 2 (Optional)",
|
427 |
type="pil",
|
428 |
height=200,
|
429 |
elem_classes="image-container image-upload"
|
430 |
)
|
431 |
|
432 |
generate_btn = gr.Button(
|
433 |
+
"Create Design ✨",
|
434 |
variant="primary",
|
435 |
size="lg"
|
436 |
)
|
|
|
438 |
# Right Column - Output
|
439 |
with gr.Column(scale=1):
|
440 |
output_image = gr.Image(
|
441 |
+
label="Generated Design",
|
442 |
type="pil",
|
443 |
height=420,
|
444 |
elem_classes="image-container output-image"
|
445 |
)
|
446 |
|
447 |
+
enhanced_prompt_display = gr.Textbox(
|
448 |
+
label="Enhanced Creative Prompt",
|
449 |
+
interactive=False,
|
450 |
+
lines=4,
|
451 |
+
elem_classes="enhanced-prompt-box",
|
452 |
+
visible=True,
|
453 |
+
value="Your enhanced prompt will appear here..."
|
454 |
+
)
|
455 |
+
|
456 |
status = gr.Textbox(
|
457 |
label="Status",
|
458 |
interactive=False,
|
459 |
lines=1,
|
460 |
elem_classes="status-text",
|
461 |
+
value="Ready to create amazing designs..."
|
462 |
)
|
463 |
|
464 |
# Event handler
|
465 |
generate_btn.click(
|
466 |
fn=process_images,
|
467 |
+
inputs=[prompt, enhance_prompt_checkbox, image1, image2],
|
468 |
+
outputs=[output_image, enhanced_prompt_display, status]
|
469 |
)
|
470 |
|
471 |
+
# Creative Design Examples
|
472 |
gr.Examples(
|
473 |
examples=[
|
474 |
+
["minimalist desk lamp", True, None, None],
|
475 |
+
["futuristic motorcycle", True, None, None],
|
476 |
+
["organic architecture building", True, None, None],
|
477 |
+
["smart home assistant device", True, None, None],
|
478 |
+
["eco-friendly water bottle", True, None, None],
|
479 |
+
["modular furniture system", True, None, None],
|
480 |
+
["wearable health monitor", True, None, None],
|
481 |
+
["urban electric scooter", True, None, None],
|
482 |
],
|
483 |
+
inputs=[prompt, enhance_prompt_checkbox, image1, image2],
|
484 |
+
label="Creative Design Examples (AI will enhance these into detailed prompts!)"
|
485 |
)
|
486 |
|
487 |
# Launch
|