Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- .claude/settings.local.json +16 -1
- auto_diffusers.log +0 -0
- gradio_app.py +340 -224
.claude/settings.local.json
CHANGED
@@ -57,7 +57,22 @@
|
|
57 |
"Bash(grep -n \"\\\"\\\"\\\"\" /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
58 |
"Bash(grep -n '\"\"\"' /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
59 |
"Bash(timeout 15s python gradio_app.py)",
|
60 |
-
"Bash(grep -n \"gpu_name_custom\" gradio_app.py)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
],
|
62 |
"deny": []
|
63 |
},
|
|
|
57 |
"Bash(grep -n \"\\\"\\\"\\\"\" /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
58 |
"Bash(grep -n '\"\"\"' /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
59 |
"Bash(timeout 15s python gradio_app.py)",
|
60 |
+
"Bash(grep -n \"gpu_name_custom\" gradio_app.py)",
|
61 |
+
"Bash(grep -n \"Modal overlay for prompt display\" /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
62 |
+
"Bash(grep -n -A 15 \"Modal Overlay\" /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
63 |
+
"Bash(grep -n -A 3 \"close_modal_btn.click\" /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
64 |
+
"Bash(sed -n '1576p' /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
65 |
+
"Bash(grep -n -A 3 -B 3 \") as interface:\" /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
66 |
+
"Bash(grep -n -A 10 \"prompt-modal\" /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
67 |
+
"Bash(grep -n \"prompt_display = gr.State\" /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
68 |
+
"Bash(grep -n -A 10 \"view_prompt_btn.click\" /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
69 |
+
"Bash(grep -n \"close_modal_btn\" /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
70 |
+
"Bash(grep -n -A 2 \"def hide_modal\" /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
71 |
+
"Bash(sed -n '1540p' /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
72 |
+
"Bash(sed -i '' '1540s/.*/ print(\"Close modal button clicked!\") # Debug/' /Users/deep-diver/Developers/auto-diffusers/gradio_app.py)",
|
73 |
+
"Bash(GRADIO_SERVER_PORT=7861 python gradio_app.py)",
|
74 |
+
"Bash(lsof -ti:7860)",
|
75 |
+
"Bash(kill 46516 80145)"
|
76 |
],
|
77 |
"deny": []
|
78 |
},
|
auto_diffusers.log
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
gradio_app.py
CHANGED
@@ -198,73 +198,50 @@ def create_gradio_interface():
|
|
198 |
css="""
|
199 |
/* Global Styles */
|
200 |
.gradio-container {
|
201 |
-
background:
|
202 |
-
#667eea 0%,
|
203 |
-
#764ba2 25%,
|
204 |
-
#f093fb 50%,
|
205 |
-
#f5576c 75%,
|
206 |
-
#4facfe 100%) !important;
|
207 |
min-height: 100vh;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
}
|
209 |
|
210 |
.main-container {
|
211 |
max-width: 1400px;
|
212 |
margin: 0 auto;
|
213 |
-
padding: 1rem;
|
214 |
/* Removed position: relative that can interfere with dropdown positioning */
|
215 |
}
|
216 |
|
217 |
-
/* Floating Background Elements */
|
218 |
-
.main-container::before {
|
219 |
-
content: '';
|
220 |
-
position: fixed;
|
221 |
-
top: 0;
|
222 |
-
left: 0;
|
223 |
-
right: 0;
|
224 |
-
bottom: 0;
|
225 |
-
background:
|
226 |
-
radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
|
227 |
-
radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
|
228 |
-
radial-gradient(circle at 40% 70%, rgba(124, 58, 237, 0.1) 0%, transparent 50%);
|
229 |
-
pointer-events: none;
|
230 |
-
z-index: -1;
|
231 |
-
}
|
232 |
|
233 |
-
/*
|
234 |
.glass-card {
|
235 |
-
background:
|
236 |
-
border: 1px solid
|
237 |
-
border-radius:
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
margin-bottom: 1rem !important;
|
242 |
-
/* Removed backdrop-filter and transforms that break dropdown positioning */
|
243 |
}
|
244 |
|
245 |
.ultra-glass {
|
246 |
-
background:
|
247 |
-
border: 1px solid
|
248 |
-
border-radius:
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
margin-bottom: 1rem !important;
|
253 |
-
/* Removed backdrop-filter that interferes with dropdown positioning */
|
254 |
}
|
255 |
|
256 |
-
/*
|
257 |
.hero-header {
|
258 |
-
background:
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
backdrop-filter: blur(20px) !important;
|
263 |
-
border: 1px solid rgba(255, 255, 255, 0.2) !important;
|
264 |
-
border-radius: 10px !important;
|
265 |
-
box-shadow:
|
266 |
-
0 20px 60px rgba(124, 58, 237, 0.3),
|
267 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
|
268 |
position: relative;
|
269 |
overflow: hidden;
|
270 |
width: 100% !important;
|
@@ -272,110 +249,146 @@ def create_gradio_interface():
|
|
272 |
box-sizing: border-box !important;
|
273 |
}
|
274 |
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
|
|
287 |
}
|
288 |
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
}
|
294 |
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
font-weight: 700 !important;
|
304 |
-
font-size: 1.
|
305 |
-
padding:
|
306 |
-
border-radius:
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
position: relative;
|
312 |
-
overflow: hidden;
|
313 |
}
|
314 |
|
315 |
-
.
|
316 |
-
|
317 |
-
position: absolute;
|
318 |
-
top: 0;
|
319 |
-
left: -100%;
|
320 |
-
width: 100%;
|
321 |
-
height: 100%;
|
322 |
-
background: linear-gradient(90deg,
|
323 |
-
transparent,
|
324 |
-
rgba(255, 255, 255, 0.3),
|
325 |
-
transparent);
|
326 |
-
transition: left 0.5s;
|
327 |
}
|
328 |
|
329 |
-
|
330 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
}
|
332 |
|
|
|
|
|
333 |
.generate-btn:hover {
|
334 |
-
|
335 |
-
|
336 |
-
0 16px 48px rgba(102, 126, 234, 0.6),
|
337 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
|
338 |
}
|
339 |
|
340 |
.generate-btn:active {
|
341 |
-
transform: translateY(
|
342 |
}
|
343 |
|
344 |
-
/* Section Headers */
|
345 |
.section-header {
|
346 |
-
background:
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
border-radius: 16px !important;
|
352 |
-
padding: 1.5rem !important;
|
353 |
-
margin-bottom: 1.5rem !important;
|
354 |
-
box-shadow:
|
355 |
-
0 4px 20px rgba(0, 0, 0, 0.08),
|
356 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
|
357 |
}
|
358 |
|
359 |
-
/*
|
360 |
input[type="text"],
|
361 |
input[type="number"],
|
362 |
textarea {
|
363 |
-
background:
|
364 |
-
border:
|
365 |
-
border-radius:
|
366 |
-
padding: 0.
|
367 |
font-weight: 500 !important;
|
368 |
-
|
|
|
|
|
369 |
}
|
370 |
|
371 |
input[type="text"]:focus,
|
372 |
input[type="number"]:focus,
|
373 |
textarea:focus {
|
374 |
-
background:
|
375 |
-
border-color:
|
376 |
-
|
377 |
-
0 0 0 4px rgba(124, 58, 237, 0.1),
|
378 |
-
0 4px 20px rgba(124, 58, 237, 0.2) !important;
|
379 |
}
|
380 |
|
381 |
/* CRITICAL: Reset all problematic CSS for dropdowns */
|
@@ -500,12 +513,11 @@ def create_gradio_interface():
|
|
500 |
}
|
501 |
|
502 |
|
503 |
-
/* Code Areas
|
504 |
.code-container {
|
505 |
-
background:
|
506 |
-
border: 1px solid
|
507 |
-
border-radius:
|
508 |
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
|
509 |
overflow: hidden !important;
|
510 |
}
|
511 |
|
@@ -522,7 +534,9 @@ def create_gradio_interface():
|
|
522 |
.code-container .cm-content {
|
523 |
white-space: pre-wrap !important;
|
524 |
padding: 1.5rem !important;
|
525 |
-
color: #
|
|
|
|
|
526 |
}
|
527 |
|
528 |
.code-container .cm-focused {
|
@@ -581,17 +595,18 @@ def create_gradio_interface():
|
|
581 |
.code-container .cm-function { color: #7c2d12 !important; }
|
582 |
.code-container .cm-operator { color: #374151 !important; }
|
583 |
|
584 |
-
/* Code header
|
585 |
.code-container label {
|
586 |
-
background:
|
587 |
-
color: #
|
588 |
padding: 0.75rem 1.25rem !important;
|
589 |
-
border-radius:
|
590 |
-
font-weight:
|
591 |
-
font-size:
|
592 |
margin: 0 !important;
|
593 |
border: none !important;
|
594 |
-
border-bottom: 1px solid
|
|
|
595 |
}
|
596 |
|
597 |
|
@@ -615,67 +630,36 @@ def create_gradio_interface():
|
|
615 |
background: rgba(107, 114, 128, 0.9) !important;
|
616 |
}
|
617 |
|
618 |
-
/* Line numbers
|
619 |
.code-container .cm-lineNumbers {
|
620 |
-
background:
|
621 |
-
color:
|
622 |
-
border-right: 1px solid
|
623 |
padding-right: 0.5rem !important;
|
624 |
}
|
625 |
|
626 |
.code-container .cm-lineNumbers .cm-gutterElement {
|
627 |
-
color:
|
628 |
font-weight: 400 !important;
|
629 |
}
|
630 |
|
631 |
-
/* Memory
|
632 |
.memory-card {
|
633 |
-
background:
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
border:
|
638 |
-
border-radius: 16px !important;
|
639 |
-
padding: 1.5rem !important;
|
640 |
-
box-shadow:
|
641 |
-
0 8px 32px rgba(245, 158, 11, 0.1),
|
642 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
|
643 |
}
|
644 |
|
645 |
-
/* Labels
|
646 |
label {
|
647 |
font-weight: 600 !important;
|
648 |
-
color:
|
649 |
-
font-size:
|
650 |
-
|
651 |
-
|
652 |
-
/* Floating Animation */
|
653 |
-
@keyframes float {
|
654 |
-
0%, 100% { transform: translateY(0px); }
|
655 |
-
50% { transform: translateY(-10px); }
|
656 |
-
}
|
657 |
-
|
658 |
-
.floating {
|
659 |
-
animation: float 6s ease-in-out infinite;
|
660 |
-
}
|
661 |
-
|
662 |
-
/* Pulse Effect */
|
663 |
-
@keyframes pulse-glow {
|
664 |
-
0%, 100% {
|
665 |
-
box-shadow:
|
666 |
-
0 8px 32px rgba(102, 126, 234, 0.4),
|
667 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.2);
|
668 |
-
}
|
669 |
-
50% {
|
670 |
-
box-shadow:
|
671 |
-
0 12px 48px rgba(102, 126, 234, 0.6),
|
672 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.3);
|
673 |
-
}
|
674 |
}
|
675 |
|
676 |
-
.pulse-glow {
|
677 |
-
animation: pulse-glow 3s ease-in-out infinite;
|
678 |
-
}
|
679 |
|
680 |
/* FINAL OVERRIDE: Nuclear option for dropdown transparency */
|
681 |
[role="listbox"] {
|
@@ -705,28 +689,98 @@ def create_gradio_interface():
|
|
705 |
background: #ffffff !important;
|
706 |
}
|
707 |
|
708 |
-
/* Accordion title styling */
|
709 |
-
.
|
710 |
-
|
711 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
712 |
}
|
713 |
|
714 |
-
|
715 |
-
|
716 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
717 |
}
|
718 |
|
719 |
/* Mobile Responsive Styles */
|
720 |
@media (max-width: 768px) {
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
max-width: calc(100% - 2px) !important;
|
725 |
}
|
726 |
|
727 |
.gradio-container {
|
728 |
-
|
729 |
-
|
730 |
}
|
731 |
|
732 |
/* Set left/right margins to 1px for mobile */
|
@@ -808,23 +862,16 @@ def create_gradio_interface():
|
|
808 |
with gr.Column(elem_classes="main-container"):
|
809 |
# Ultra Premium Header
|
810 |
gr.HTML("""
|
811 |
-
<div class="hero-header
|
812 |
-
<
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
</p>
|
822 |
-
<div style="margin-top: 1rem;">
|
823 |
-
<span style="display: inline-block; background: rgba(255,255,255,0.2); padding: 0.5rem 1rem; border-radius: 20px; color: white; font-size: 0.9rem; backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.3);">
|
824 |
-
π€ Powered by Google Gemini 2.5
|
825 |
-
</span>
|
826 |
-
</div>
|
827 |
-
</div>
|
828 |
</div>
|
829 |
""")
|
830 |
|
@@ -835,7 +882,7 @@ def create_gradio_interface():
|
|
835 |
with gr.Accordion("βοΈ Hardware Specifications", open=False) as hardware_accordion:
|
836 |
gr.HTML("""
|
837 |
<div class="section-header" style="text-align: center;">
|
838 |
-
<p style="margin: 0; color: #
|
839 |
Configure your system hardware for optimal code generation
|
840 |
</p>
|
841 |
</div>
|
@@ -907,7 +954,7 @@ def create_gradio_interface():
|
|
907 |
with gr.Accordion("π€ Model Configuration", open=False) as model_accordion:
|
908 |
gr.HTML("""
|
909 |
<div class="section-header" style="text-align: center;">
|
910 |
-
<p style="margin: 0; color: #
|
911 |
Configure the AI model and generation parameters
|
912 |
</p>
|
913 |
</div>
|
@@ -978,11 +1025,21 @@ def create_gradio_interface():
|
|
978 |
"β¨ Generate Optimized Code",
|
979 |
variant="primary",
|
980 |
size="lg",
|
981 |
-
elem_classes="generate-btn
|
982 |
)
|
983 |
|
984 |
# Generated Code Section
|
985 |
with gr.Group(elem_classes="ultra-glass"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
986 |
# Code Output
|
987 |
code_output = gr.Code(
|
988 |
label="Generated Code",
|
@@ -994,6 +1051,22 @@ def create_gradio_interface():
|
|
994 |
show_line_numbers=False,
|
995 |
value="# Your optimized diffusion code will appear here after generation\n# Click 'Generate Optimized Code' to create hardware-specific Python code\n\nprint('Ready to generate AI art with optimized performance!')"
|
996 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
997 |
|
998 |
def on_gpu_vendor_change(vendor):
|
999 |
"""Handle GPU vendor selection and update series dropdown."""
|
@@ -1412,40 +1485,83 @@ def create_gradio_interface():
|
|
1412 |
|
1413 |
"""
|
1414 |
|
1415 |
-
# STEP 2:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1416 |
generated_code = app.generate_code_with_manual_specs(
|
1417 |
final_gpu_name, vram_gb, ram_gb, platform,
|
1418 |
model_name, prompt_text, dtype_selection, width, height, inference_steps,
|
1419 |
memory_analysis_data
|
1420 |
)
|
1421 |
|
1422 |
-
# STEP
|
1423 |
final_code = memory_header + generated_code if memory_header and not generated_code.startswith("Error") else generated_code
|
1424 |
|
1425 |
-
# STEP
|
1426 |
summary = create_code_summary(generated_code, model_name, final_gpu_name, vram_gb)
|
1427 |
|
1428 |
-
return summary, final_code
|
1429 |
|
1430 |
# Add states for tracking code view and storing full code
|
1431 |
code_collapsed = gr.State(value=False)
|
1432 |
full_code_storage = gr.State(value="")
|
|
|
1433 |
|
1434 |
def generate_and_store_code(gpu_vendor, gpu_series, gpu_model, vram_gb, ram_gb, platform, model_name, dtype_selection, width, height, inference_steps):
|
1435 |
"""Generate code and return code for display and full code for storage."""
|
1436 |
-
summary, full_code = generate_with_combined_gpu_name(
|
1437 |
gpu_vendor, gpu_series, gpu_model, vram_gb, ram_gb, platform,
|
1438 |
model_name, dtype_selection, width, height, inference_steps
|
1439 |
)
|
1440 |
-
|
|
|
|
|
|
|
|
|
|
|
1441 |
|
|
|
|
|
|
|
|
|
|
|
1442 |
generate_btn.click(
|
1443 |
generate_and_store_code,
|
1444 |
inputs=[
|
1445 |
gpu_vendor, gpu_series, gpu_model, vram_gb, ram_gb, platform,
|
1446 |
model_name, dtype_selection, width, height, inference_steps
|
1447 |
],
|
1448 |
-
outputs=[code_output, full_code_storage, code_collapsed]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1449 |
)
|
1450 |
|
1451 |
|
|
|
198 |
css="""
|
199 |
/* Global Styles */
|
200 |
.gradio-container {
|
201 |
+
background: #fef7f5 !important;
|
|
|
|
|
|
|
|
|
|
|
202 |
min-height: 100vh;
|
203 |
+
font-family: 'Georgia', 'Times New Roman', serif !important;
|
204 |
+
}
|
205 |
+
|
206 |
+
/* Remove main tag margin and center */
|
207 |
+
main {
|
208 |
+
margin: 0 auto !important;
|
209 |
+
max-width: 100% !important;
|
210 |
}
|
211 |
|
212 |
.main-container {
|
213 |
max-width: 1400px;
|
214 |
margin: 0 auto;
|
215 |
+
padding: 0.5rem 0.1rem;
|
216 |
/* Removed position: relative that can interfere with dropdown positioning */
|
217 |
}
|
218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
|
220 |
+
/* Paper Card Effects */
|
221 |
.glass-card {
|
222 |
+
background: #fefcfa !important;
|
223 |
+
border: 1px solid #f4e6e1 !important;
|
224 |
+
border-radius: 12px !important;
|
225 |
+
margin-bottom: 0.5rem !important;
|
226 |
+
padding: 0.5rem !important;
|
227 |
+
border-top: 3px solid #f0c5b8 !important;
|
|
|
|
|
228 |
}
|
229 |
|
230 |
.ultra-glass {
|
231 |
+
background: #fefcfa !important;
|
232 |
+
border: 1px solid #f4e6e1 !important;
|
233 |
+
border-radius: 12px !important;
|
234 |
+
margin-bottom: 0.5rem !important;
|
235 |
+
padding: 0.5rem !important;
|
236 |
+
border-left: 4px solid #f0c5b8 !important;
|
|
|
|
|
237 |
}
|
238 |
|
239 |
+
/* Paper Header */
|
240 |
.hero-header {
|
241 |
+
background: #fdf5f3 !important;
|
242 |
+
border: 2px solid #f4e6e1 !important;
|
243 |
+
border-radius: 16px !important;
|
244 |
+
margin-bottom: 1rem !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
position: relative;
|
246 |
overflow: hidden;
|
247 |
width: 100% !important;
|
|
|
249 |
box-sizing: border-box !important;
|
250 |
}
|
251 |
|
252 |
+
|
253 |
+
/* Paper Buttons */
|
254 |
+
.generate-btn {
|
255 |
+
background: #e67e5a !important;
|
256 |
+
border: 2px solid #d96b47 !important;
|
257 |
+
color: #fefcfa !important;
|
258 |
+
font-weight: 600 !important;
|
259 |
+
font-size: 1.3rem !important;
|
260 |
+
padding: 1.2rem 2.5rem !important;
|
261 |
+
border-radius: 12px !important;
|
262 |
+
transition: all 0.3s ease !important;
|
263 |
+
font-family: 'Georgia', serif !important;
|
264 |
+
letter-spacing: 0.5px !important;
|
265 |
}
|
266 |
|
267 |
+
/* View Prompt Button */
|
268 |
+
.view-prompt-btn {
|
269 |
+
background: #f4e6e1 !important;
|
270 |
+
border: 1px solid #e8a491 !important;
|
271 |
+
color: #5a3a2a !important;
|
272 |
+
font-weight: 500 !important;
|
273 |
+
font-size: 0.9rem !important;
|
274 |
+
padding: 0.5rem 1rem !important;
|
275 |
+
border-radius: 8px !important;
|
276 |
+
transition: all 0.2s ease !important;
|
277 |
+
font-family: 'Georgia', serif !important;
|
278 |
+
margin-bottom: 0.5rem !important;
|
279 |
}
|
280 |
|
281 |
+
.view-prompt-btn:hover {
|
282 |
+
background: #f0c5b8 !important;
|
283 |
+
}
|
284 |
+
|
285 |
+
/* Modal Overlay - NO display property to avoid conflict */
|
286 |
+
.modal-overlay {
|
287 |
+
position: fixed !important;
|
288 |
+
top: 0 !important;
|
289 |
+
left: 0 !important;
|
290 |
+
width: 100vw !important;
|
291 |
+
height: 100vh !important;
|
292 |
+
background: rgba(0, 0, 0, 0.5) !important;
|
293 |
+
z-index: 9999 !important;
|
294 |
+
justify-content: center !important;
|
295 |
+
align-items: center !important;
|
296 |
+
padding: 2rem !important;
|
297 |
+
box-sizing: border-box !important;
|
298 |
+
}
|
299 |
+
|
300 |
+
/* Modal Content */
|
301 |
+
.modal-content {
|
302 |
+
background: #fefcfa !important;
|
303 |
+
border: 2px solid #f0c5b8 !important;
|
304 |
+
border-radius: 16px !important;
|
305 |
+
max-width: 90vw !important;
|
306 |
+
max-height: 80vh !important;
|
307 |
+
width: 800px !important;
|
308 |
+
padding: 2rem !important;
|
309 |
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
|
310 |
+
overflow: hidden !important;
|
311 |
+
flex-direction: column !important;
|
312 |
+
}
|
313 |
+
|
314 |
+
/* Modal Header */
|
315 |
+
.modal-header {
|
316 |
+
justify-content: space-between !important;
|
317 |
+
align-items: center !important;
|
318 |
+
margin-bottom: 1rem !important;
|
319 |
+
padding-bottom: 1rem !important;
|
320 |
+
border-bottom: 1px solid #f0c5b8 !important;
|
321 |
+
}
|
322 |
+
|
323 |
+
/* Modal Close Button */
|
324 |
+
.modal-close-btn {
|
325 |
+
background: #f4e6e1 !important;
|
326 |
+
border: 1px solid #e8a491 !important;
|
327 |
+
color: #5a3a2a !important;
|
328 |
font-weight: 700 !important;
|
329 |
+
font-size: 1.2rem !important;
|
330 |
+
padding: 0.4rem 0.6rem !important;
|
331 |
+
border-radius: 6px !important;
|
332 |
+
min-width: 2rem !important;
|
333 |
+
height: 2rem !important;
|
334 |
+
align-items: center !important;
|
335 |
+
justify-content: center !important;
|
|
|
|
|
336 |
}
|
337 |
|
338 |
+
.modal-close-btn:hover {
|
339 |
+
background: #f0c5b8 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
}
|
341 |
|
342 |
+
/* Prompt Container */
|
343 |
+
.prompt-container {
|
344 |
+
background: #fcf3f0 !important;
|
345 |
+
border: 1px solid #f0c5b8 !important;
|
346 |
+
border-radius: 8px !important;
|
347 |
+
max-height: 400px !important;
|
348 |
+
overflow-y: auto !important;
|
349 |
+
flex: 1 !important;
|
350 |
}
|
351 |
|
352 |
+
|
353 |
+
|
354 |
.generate-btn:hover {
|
355 |
+
background: #d96b47 !important;
|
356 |
+
transform: translateY(-1px) !important;
|
|
|
|
|
357 |
}
|
358 |
|
359 |
.generate-btn:active {
|
360 |
+
transform: translateY(0px) !important;
|
361 |
}
|
362 |
|
363 |
+
/* Paper Section Headers */
|
364 |
.section-header {
|
365 |
+
background: #f9f0ec !important;
|
366 |
+
border: 1px solid #f0c5b8 !important;
|
367 |
+
border-radius: 8px !important;
|
368 |
+
padding: 0.7rem !important;
|
369 |
+
margin-bottom: 0.5rem !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
}
|
371 |
|
372 |
+
/* Paper Inputs */
|
373 |
input[type="text"],
|
374 |
input[type="number"],
|
375 |
textarea {
|
376 |
+
background: #fefcfa !important;
|
377 |
+
border: 2px solid #f4e6e1 !important;
|
378 |
+
border-radius: 8px !important;
|
379 |
+
padding: 0.8rem 1.2rem !important;
|
380 |
font-weight: 500 !important;
|
381 |
+
color: #5a3a2a !important;
|
382 |
+
font-family: 'Georgia', serif !important;
|
383 |
+
font-size: 1rem !important;
|
384 |
}
|
385 |
|
386 |
input[type="text"]:focus,
|
387 |
input[type="number"]:focus,
|
388 |
textarea:focus {
|
389 |
+
background: #fefcfa !important;
|
390 |
+
border-color: #e8a491 !important;
|
391 |
+
outline: none !important;
|
|
|
|
|
392 |
}
|
393 |
|
394 |
/* CRITICAL: Reset all problematic CSS for dropdowns */
|
|
|
513 |
}
|
514 |
|
515 |
|
516 |
+
/* Paper Code Areas */
|
517 |
.code-container {
|
518 |
+
background: #f9f0ec !important;
|
519 |
+
border: 1px solid #f0c5b8 !important;
|
520 |
+
border-radius: 8px !important;
|
|
|
521 |
overflow: hidden !important;
|
522 |
}
|
523 |
|
|
|
534 |
.code-container .cm-content {
|
535 |
white-space: pre-wrap !important;
|
536 |
padding: 1.5rem !important;
|
537 |
+
color: #5a3a2a !important;
|
538 |
+
font-size: 14px !important;
|
539 |
+
font-weight: 500 !important;
|
540 |
}
|
541 |
|
542 |
.code-container .cm-focused {
|
|
|
595 |
.code-container .cm-function { color: #7c2d12 !important; }
|
596 |
.code-container .cm-operator { color: #374151 !important; }
|
597 |
|
598 |
+
/* Paper Code header */
|
599 |
.code-container label {
|
600 |
+
background: #f5e6e0 !important;
|
601 |
+
color: #5a3a2a !important;
|
602 |
padding: 0.75rem 1.25rem !important;
|
603 |
+
border-radius: 8px 8px 0 0 !important;
|
604 |
+
font-weight: 700 !important;
|
605 |
+
font-size: 1.1rem !important;
|
606 |
margin: 0 !important;
|
607 |
border: none !important;
|
608 |
+
border-bottom: 1px solid #f0c5b8 !important;
|
609 |
+
font-family: 'Georgia', serif !important;
|
610 |
}
|
611 |
|
612 |
|
|
|
630 |
background: rgba(107, 114, 128, 0.9) !important;
|
631 |
}
|
632 |
|
633 |
+
/* Paper Line numbers */
|
634 |
.code-container .cm-lineNumbers {
|
635 |
+
background: #f5e6e0 !important;
|
636 |
+
color: #b8847a !important;
|
637 |
+
border-right: 1px solid #f0c5b8 !important;
|
638 |
padding-right: 0.5rem !important;
|
639 |
}
|
640 |
|
641 |
.code-container .cm-lineNumbers .cm-gutterElement {
|
642 |
+
color: #b8847a !important;
|
643 |
font-weight: 400 !important;
|
644 |
}
|
645 |
|
646 |
+
/* Paper Memory Cards */
|
647 |
.memory-card {
|
648 |
+
background: #fcf3f0 !important;
|
649 |
+
border: 1px solid #f4e6e1 !important;
|
650 |
+
border-radius: 12px !important;
|
651 |
+
padding: 0.7rem !important;
|
652 |
+
border-left: 4px solid #e8a491 !important;
|
|
|
|
|
|
|
|
|
|
|
653 |
}
|
654 |
|
655 |
+
/* Paper Labels */
|
656 |
label {
|
657 |
font-weight: 600 !important;
|
658 |
+
color: #5a3a2a !important;
|
659 |
+
font-size: 1.1rem !important;
|
660 |
+
font-family: 'Georgia', serif !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
661 |
}
|
662 |
|
|
|
|
|
|
|
663 |
|
664 |
/* FINAL OVERRIDE: Nuclear option for dropdown transparency */
|
665 |
[role="listbox"] {
|
|
|
689 |
background: #ffffff !important;
|
690 |
}
|
691 |
|
692 |
+
/* Accordion title styling - target the actual Gradio accordion elements */
|
693 |
+
button.label-wrap > span:first-child,
|
694 |
+
.label-wrap > span:first-child,
|
695 |
+
button.label-wrap span {
|
696 |
+
font-size: 1.1rem !important;
|
697 |
+
font-weight: 900 !important;
|
698 |
+
color: #4a2818 !important;
|
699 |
+
font-family: 'Georgia', serif !important;
|
700 |
+
line-height: 1.3 !important;
|
701 |
+
text-shadow: 0 1px 2px rgba(0,0,0,0.1) !important;
|
702 |
+
letter-spacing: 0.5px !important;
|
703 |
+
text-transform: none !important;
|
704 |
}
|
705 |
|
706 |
+
/* Additional targeting for accordion buttons */
|
707 |
+
button.label-wrap {
|
708 |
+
background: #f9f0ec !important;
|
709 |
+
padding: 0.7rem 1rem !important;
|
710 |
+
border-radius: 8px !important;
|
711 |
+
border: 1px solid #f0c5b8 !important;
|
712 |
+
}
|
713 |
+
|
714 |
+
button.label-wrap:hover {
|
715 |
+
background: #f5e6e0 !important;
|
716 |
+
}
|
717 |
+
|
718 |
+
/* Accordion title styling - focus on readability */
|
719 |
+
.gradio-accordion .label-wrap,
|
720 |
+
.gradio-accordion summary,
|
721 |
+
.gradio-accordion details summary,
|
722 |
+
details summary,
|
723 |
+
details > summary,
|
724 |
+
[data-testid="accordion"] summary,
|
725 |
+
[data-testid="accordion"] .label-wrap {
|
726 |
+
font-weight: 900 !important;
|
727 |
+
color: #2d1810 !important;
|
728 |
+
font-family: 'Georgia', serif !important;
|
729 |
+
line-height: 1.3 !important;
|
730 |
+
text-shadow: 0 1px 2px rgba(0,0,0,0.1) !important;
|
731 |
+
padding: 1rem 1.5rem !important;
|
732 |
+
background: #f5f1e8 !important;
|
733 |
+
border-radius: 8px !important;
|
734 |
+
letter-spacing: 0.5px !important;
|
735 |
+
text-transform: none !important;
|
736 |
+
}
|
737 |
+
|
738 |
+
/* Even more specific accordion targeting */
|
739 |
+
.gradio-container details summary,
|
740 |
+
.gradio-container .gradio-accordion summary,
|
741 |
+
.gradio-container [role="button"] {
|
742 |
+
font-weight: 900 !important;
|
743 |
+
color: #2d1810 !important;
|
744 |
+
font-family: 'Georgia', serif !important;
|
745 |
+
text-shadow: 0 1px 2px rgba(0,0,0,0.1) !important;
|
746 |
+
background: #f5f1e8 !important;
|
747 |
+
padding: 1rem 1.5rem !important;
|
748 |
+
border-radius: 8px !important;
|
749 |
+
letter-spacing: 0.5px !important;
|
750 |
+
}
|
751 |
+
|
752 |
+
/* Accordion hover states for better interaction */
|
753 |
+
.gradio-accordion summary:hover,
|
754 |
+
details summary:hover {
|
755 |
+
background: #f0ead7 !important;
|
756 |
+
color: #1a0f08 !important;
|
757 |
+
}
|
758 |
+
|
759 |
+
/* Accordion container styling */
|
760 |
+
.gradio-accordion,
|
761 |
+
details {
|
762 |
+
background: #fefdfb !important;
|
763 |
+
border: 2px solid #f0ede6 !important;
|
764 |
+
border-radius: 12px !important;
|
765 |
+
margin-bottom: 1rem !important;
|
766 |
+
}
|
767 |
+
|
768 |
+
.gradio-accordion[open],
|
769 |
+
details[open] {
|
770 |
+
border-color: #e8dcc6 !important;
|
771 |
+
background: #fefdfb !important;
|
772 |
}
|
773 |
|
774 |
/* Mobile Responsive Styles */
|
775 |
@media (max-width: 768px) {
|
776 |
+
body, html, main {
|
777 |
+
padding: 5px !important;
|
778 |
+
margin: 0 !important;
|
|
|
779 |
}
|
780 |
|
781 |
.gradio-container {
|
782 |
+
padding: 5px !important;
|
783 |
+
margin: 0 !important;
|
784 |
}
|
785 |
|
786 |
/* Set left/right margins to 1px for mobile */
|
|
|
862 |
with gr.Column(elem_classes="main-container"):
|
863 |
# Ultra Premium Header
|
864 |
gr.HTML("""
|
865 |
+
<div class="hero-header" style="text-align: center; padding: 1rem;">
|
866 |
+
<h1 style="color: #5a3a2a; font-size: 2rem; margin: 0 0 0.2rem 0; font-weight: 600; font-family: 'Georgia', serif;">
|
867 |
+
β¨ Auto Diffusers Config
|
868 |
+
</h1>
|
869 |
+
<h2 style="color: #8b5a4f; font-size: 1rem; margin: 0 0 0.5rem 0; font-weight: 500; font-style: italic; font-family: 'Georgia', serif;">
|
870 |
+
Hardware-Optimized Code Generator
|
871 |
+
</h2>
|
872 |
+
<span style="display: inline-block; background: #fefcfa; padding: 0.3rem 0.8rem; border-radius: 8px; color: #5a3a2a; font-size: 0.85rem; border: 1px solid #f4e6e1; font-family: 'Georgia', serif; font-style: italic; font-weight: 500;">
|
873 |
+
π€ Powered by Google Gemini 2.5
|
874 |
+
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
875 |
</div>
|
876 |
""")
|
877 |
|
|
|
882 |
with gr.Accordion("βοΈ Hardware Specifications", open=False) as hardware_accordion:
|
883 |
gr.HTML("""
|
884 |
<div class="section-header" style="text-align: center;">
|
885 |
+
<p style="margin: 0; color: #6a443a; font-size: 1.1rem; font-weight: 600; font-family: 'Georgia', serif;">
|
886 |
Configure your system hardware for optimal code generation
|
887 |
</p>
|
888 |
</div>
|
|
|
954 |
with gr.Accordion("π€ Model Configuration", open=False) as model_accordion:
|
955 |
gr.HTML("""
|
956 |
<div class="section-header" style="text-align: center;">
|
957 |
+
<p style="margin: 0; color: #6a443a; font-size: 1.1rem; font-weight: 600; font-family: 'Georgia', serif;">
|
958 |
Configure the AI model and generation parameters
|
959 |
</p>
|
960 |
</div>
|
|
|
1025 |
"β¨ Generate Optimized Code",
|
1026 |
variant="primary",
|
1027 |
size="lg",
|
1028 |
+
elem_classes="generate-btn"
|
1029 |
)
|
1030 |
|
1031 |
# Generated Code Section
|
1032 |
with gr.Group(elem_classes="ultra-glass"):
|
1033 |
+
# Hidden button to show prompt (only visible after generation)
|
1034 |
+
with gr.Row():
|
1035 |
+
view_prompt_btn = gr.Button(
|
1036 |
+
"π View Actual Prompt Sent to Gemini",
|
1037 |
+
variant="secondary",
|
1038 |
+
size="sm",
|
1039 |
+
visible=False,
|
1040 |
+
elem_classes="view-prompt-btn"
|
1041 |
+
)
|
1042 |
+
|
1043 |
# Code Output
|
1044 |
code_output = gr.Code(
|
1045 |
label="Generated Code",
|
|
|
1051 |
show_line_numbers=False,
|
1052 |
value="# Your optimized diffusion code will appear here after generation\n# Click 'Generate Optimized Code' to create hardware-specific Python code\n\nprint('Ready to generate AI art with optimized performance!')"
|
1053 |
)
|
1054 |
+
|
1055 |
+
# Modal with CSS styling
|
1056 |
+
with gr.Group(visible=False, elem_classes="modal-overlay") as prompt_modal:
|
1057 |
+
with gr.Column(elem_classes="modal-content"):
|
1058 |
+
with gr.Row(elem_classes="modal-header"):
|
1059 |
+
gr.Markdown("### π Actual Prompt Sent to Gemini API")
|
1060 |
+
close_modal_btn = gr.Button("Γ", variant="secondary", size="sm", elem_classes="modal-close-btn")
|
1061 |
+
prompt_display = gr.Code(
|
1062 |
+
label="Full Prompt",
|
1063 |
+
language="markdown",
|
1064 |
+
lines=20,
|
1065 |
+
interactive=False,
|
1066 |
+
show_label=False,
|
1067 |
+
elem_classes="prompt-container",
|
1068 |
+
value=""
|
1069 |
+
)
|
1070 |
|
1071 |
def on_gpu_vendor_change(vendor):
|
1072 |
"""Handle GPU vendor selection and update series dropdown."""
|
|
|
1485 |
|
1486 |
"""
|
1487 |
|
1488 |
+
# STEP 2: Get the actual prompt that will be sent to Gemini
|
1489 |
+
actual_prompt = app.get_generation_prompt(
|
1490 |
+
model_name, prompt_text, (int(height), int(width)), int(inference_steps),
|
1491 |
+
{
|
1492 |
+
'platform': platform,
|
1493 |
+
'architecture': 'manual_input',
|
1494 |
+
'cpu_count': 8,
|
1495 |
+
'python_version': '3.11',
|
1496 |
+
'cuda_available': 'nvidia' in final_gpu_name.lower() if final_gpu_name else False,
|
1497 |
+
'mps_available': platform == 'Darwin' and 'apple' in final_gpu_name.lower() if final_gpu_name else False,
|
1498 |
+
'torch_version': '2.0+',
|
1499 |
+
'manual_input': True,
|
1500 |
+
'ram_gb': int(ram_gb) if ram_gb else 16,
|
1501 |
+
'user_dtype': f"torch.{dtype_selection}" if dtype_selection != "Auto" else None,
|
1502 |
+
'gpu_info': [{'name': final_gpu_name, 'memory_mb': int(vram_gb) * 1024}] if final_gpu_name and vram_gb else None
|
1503 |
+
},
|
1504 |
+
optimization_profile="balanced"
|
1505 |
+
)
|
1506 |
+
|
1507 |
+
# STEP 3: Generate the optimized code WITH memory analysis information
|
1508 |
generated_code = app.generate_code_with_manual_specs(
|
1509 |
final_gpu_name, vram_gb, ram_gb, platform,
|
1510 |
model_name, prompt_text, dtype_selection, width, height, inference_steps,
|
1511 |
memory_analysis_data
|
1512 |
)
|
1513 |
|
1514 |
+
# STEP 4: Prepend memory analysis header to the generated code
|
1515 |
final_code = memory_header + generated_code if memory_header and not generated_code.startswith("Error") else generated_code
|
1516 |
|
1517 |
+
# STEP 5: Create code summary
|
1518 |
summary = create_code_summary(generated_code, model_name, final_gpu_name, vram_gb)
|
1519 |
|
1520 |
+
return summary, final_code, actual_prompt
|
1521 |
|
1522 |
# Add states for tracking code view and storing full code
|
1523 |
code_collapsed = gr.State(value=False)
|
1524 |
full_code_storage = gr.State(value="")
|
1525 |
+
prompt_storage = gr.State(value="")
|
1526 |
|
1527 |
def generate_and_store_code(gpu_vendor, gpu_series, gpu_model, vram_gb, ram_gb, platform, model_name, dtype_selection, width, height, inference_steps):
|
1528 |
"""Generate code and return code for display and full code for storage."""
|
1529 |
+
summary, full_code, actual_prompt = generate_with_combined_gpu_name(
|
1530 |
gpu_vendor, gpu_series, gpu_model, vram_gb, ram_gb, platform,
|
1531 |
model_name, dtype_selection, width, height, inference_steps
|
1532 |
)
|
1533 |
+
# Show the view prompt button after generation
|
1534 |
+
return full_code, full_code, False, gr.update(visible=True), actual_prompt # display_code, stored_code, reset_collapsed_state, show_button, prompt
|
1535 |
+
|
1536 |
+
# Modal functions
|
1537 |
+
def show_modal(prompt):
|
1538 |
+
return gr.update(visible=True), prompt
|
1539 |
|
1540 |
+
def hide_modal():
|
1541 |
+
print("Close modal button clicked!") # Debug
|
1542 |
+
return gr.update(visible=False), ""
|
1543 |
+
|
1544 |
+
# Generate button click
|
1545 |
generate_btn.click(
|
1546 |
generate_and_store_code,
|
1547 |
inputs=[
|
1548 |
gpu_vendor, gpu_series, gpu_model, vram_gb, ram_gb, platform,
|
1549 |
model_name, dtype_selection, width, height, inference_steps
|
1550 |
],
|
1551 |
+
outputs=[code_output, full_code_storage, code_collapsed, view_prompt_btn, prompt_storage]
|
1552 |
+
)
|
1553 |
+
|
1554 |
+
# View prompt button click
|
1555 |
+
view_prompt_btn.click(
|
1556 |
+
show_modal,
|
1557 |
+
inputs=[prompt_storage],
|
1558 |
+
outputs=[prompt_modal, prompt_display]
|
1559 |
+
)
|
1560 |
+
|
1561 |
+
# Close modal button click
|
1562 |
+
close_modal_btn.click(
|
1563 |
+
hide_modal,
|
1564 |
+
outputs=[prompt_modal, prompt_display]
|
1565 |
)
|
1566 |
|
1567 |
|