Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -92,12 +92,12 @@ def get_stats_info() -> str:
|
|
92 |
def create_interface():
|
93 |
"""Create the main Gradio interface"""
|
94 |
|
95 |
-
#
|
96 |
css = """
|
97 |
-
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
|
98 |
|
99 |
.gradio-container {
|
100 |
-
max-width:
|
101 |
margin: 0 auto !important;
|
102 |
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
|
103 |
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
|
@@ -115,124 +115,92 @@ def create_interface():
|
|
115 |
.prose h1, .prose h2, .prose h3,
|
116 |
.gr-markdown h1, .gr-markdown h2, .gr-markdown h3 {
|
117 |
color: #111827 !important;
|
118 |
-
font-weight:
|
119 |
}
|
120 |
|
121 |
-
.markdown-text p, .markdown-text li,
|
122 |
-
.prose p, .prose li,
|
123 |
-
.gr-markdown p, .gr-markdown li {
|
124 |
color: #374151 !important;
|
125 |
}
|
126 |
|
127 |
.markdown-text strong, .prose strong, .gr-markdown strong {
|
128 |
color: #111827 !important;
|
129 |
-
font-weight:
|
130 |
}
|
131 |
|
132 |
/* Header styling */
|
133 |
.main-header {
|
134 |
text-align: center;
|
135 |
-
padding:
|
136 |
-
background: linear-gradient(135deg, #
|
137 |
color: white;
|
138 |
-
margin: -2rem -2rem
|
139 |
-
border-radius: 0 0
|
140 |
-
box-shadow: 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
}
|
142 |
|
143 |
.main-title {
|
144 |
-
font-size:
|
145 |
-
font-weight:
|
146 |
-
margin: 0 0
|
147 |
-
letter-spacing: -0.
|
148 |
-
|
|
|
|
|
|
|
|
|
|
|
149 |
}
|
150 |
|
151 |
.subtitle {
|
152 |
-
font-size: 1.
|
153 |
-
font-weight:
|
154 |
-
opacity: 0.
|
155 |
margin: 0 !important;
|
156 |
-
|
|
|
|
|
157 |
}
|
158 |
|
159 |
-
/* Prompt output styling */
|
160 |
.prompt-output {
|
161 |
-
font-family: 'SF Mono', 'Monaco', '
|
162 |
-
font-size:
|
163 |
-
line-height: 1.
|
164 |
background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%) !important;
|
165 |
border: 2px solid #e2e8f0 !important;
|
166 |
-
border-radius:
|
167 |
-
padding:
|
168 |
-
box-shadow: 0
|
169 |
transition: all 0.3s ease !important;
|
170 |
color: #1f2937 !important;
|
171 |
}
|
172 |
|
173 |
.prompt-output:hover {
|
174 |
-
box-shadow: 0
|
175 |
-
transform: translateY(-
|
176 |
-
}
|
177 |
-
|
178 |
-
/* Button styling */
|
179 |
-
.gr-button-primary {
|
180 |
-
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
|
181 |
-
border: none !important;
|
182 |
-
color: white !important;
|
183 |
-
font-weight: 500 !important;
|
184 |
-
padding: 0.75rem 1.5rem !important;
|
185 |
-
border-radius: 8px !important;
|
186 |
-
transition: all 0.2s ease !important;
|
187 |
-
}
|
188 |
-
|
189 |
-
.gr-button-primary:hover {
|
190 |
-
background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
|
191 |
-
transform: translateY(-1px) !important;
|
192 |
-
box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3) !important;
|
193 |
-
}
|
194 |
-
|
195 |
-
.gr-button-secondary {
|
196 |
-
background: #f1f5f9 !important;
|
197 |
-
border: 1px solid #cbd5e1 !important;
|
198 |
-
color: #475569 !important;
|
199 |
-
font-weight: 500 !important;
|
200 |
-
border-radius: 8px !important;
|
201 |
-
}
|
202 |
-
|
203 |
-
.gr-button-secondary:hover {
|
204 |
-
background: #e2e8f0 !important;
|
205 |
-
border-color: #94a3b8 !important;
|
206 |
-
}
|
207 |
-
|
208 |
-
/* Image upload area */
|
209 |
-
.gr-file-upload {
|
210 |
-
border: 2px dashed #cbd5e1 !important;
|
211 |
-
border-radius: 12px !important;
|
212 |
-
background: #f8fafc !important;
|
213 |
-
}
|
214 |
-
|
215 |
-
/* Info boxes */
|
216 |
-
.info-box {
|
217 |
-
background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
|
218 |
-
border: 1px solid #0284c7;
|
219 |
-
border-radius: 12px;
|
220 |
-
padding: 1rem;
|
221 |
-
margin: 1rem 0;
|
222 |
}
|
223 |
"""
|
224 |
|
225 |
with gr.Blocks(
|
226 |
-
theme=gr.themes.Soft(
|
227 |
-
primary_hue="blue",
|
228 |
-
secondary_hue="slate",
|
229 |
-
neutral_hue="slate"
|
230 |
-
),
|
231 |
title="Frame 0 Laboratory for MIA",
|
232 |
css=css
|
233 |
) as interface:
|
234 |
|
235 |
-
# Header
|
236 |
gr.HTML("""
|
237 |
<div class="main-header">
|
238 |
<div class="main-title">Frame 0 Laboratory for MIA</div>
|
@@ -240,32 +208,22 @@ def create_interface():
|
|
240 |
</div>
|
241 |
""")
|
242 |
|
243 |
-
# Main interface
|
244 |
with gr.Row():
|
245 |
-
# Left column - Input
|
246 |
with gr.Column(scale=1):
|
247 |
gr.Markdown("## Image Analysis")
|
248 |
|
249 |
image_input = gr.Image(
|
250 |
-
label="Upload
|
251 |
type="pil",
|
252 |
-
height=
|
253 |
)
|
254 |
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
)
|
261 |
-
|
262 |
-
clear_btn = gr.Button(
|
263 |
-
"🗑️ Clear",
|
264 |
-
variant="secondary",
|
265 |
-
size="lg"
|
266 |
-
)
|
267 |
|
268 |
-
# Information panel
|
269 |
gr.Markdown("""
|
270 |
### How it works:
|
271 |
|
@@ -278,38 +236,29 @@ def create_interface():
|
|
278 |
**Supported formats:** JPG, PNG, WebP up to 1024px
|
279 |
""")
|
280 |
|
281 |
-
# Statistics
|
282 |
with gr.Accordion("📊 Processing Stats", open=False):
|
283 |
stats_output = gr.Markdown(value="No processing completed yet.")
|
284 |
-
|
285 |
refresh_stats_btn = gr.Button("Refresh Stats", size="sm")
|
286 |
-
refresh_stats_btn.click(
|
287 |
-
fn=get_stats_info,
|
288 |
-
outputs=stats_output
|
289 |
-
)
|
290 |
|
291 |
-
# Right column - Output
|
292 |
with gr.Column(scale=1):
|
293 |
gr.Markdown("## Results")
|
294 |
|
295 |
-
# Score display
|
296 |
score_output = gr.HTML(
|
297 |
value='<div style="text-align: center; padding: 1rem;"><div style="font-size: 2rem; color: #ccc;">--</div><div style="font-size: 0.875rem; color: #999;">Quality Score</div></div>'
|
298 |
)
|
299 |
|
300 |
-
# Optimized prompt
|
301 |
prompt_output = gr.Textbox(
|
302 |
label="🎯 Optimized FLUX Prompt",
|
303 |
placeholder="Upload an image to generate an optimized prompt...",
|
304 |
-
lines=
|
305 |
-
max_lines=
|
306 |
-
elem_classes=["prompt-output"],
|
307 |
show_copy_button=True
|
308 |
)
|
309 |
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
|
314 |
# Event handlers
|
315 |
analyze_btn.click(
|
@@ -323,14 +272,20 @@ def create_interface():
|
|
323 |
outputs=[prompt_output, info_output, score_output]
|
324 |
)
|
325 |
|
326 |
-
|
|
|
|
|
|
|
|
|
327 |
gr.Markdown("""
|
328 |
---
|
329 |
-
|
|
|
|
|
|
|
|
|
330 |
|
331 |
-
|
332 |
-
for FLUX image generation. The system applies proven optimization rules including camera configurations,
|
333 |
-
lighting setups, and technical parameters for best results.
|
334 |
""")
|
335 |
|
336 |
return interface
|
@@ -343,20 +298,13 @@ def main():
|
|
343 |
# Create and launch interface
|
344 |
demo = create_interface()
|
345 |
|
346 |
-
#
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
server_name="0.0.0.0",
|
354 |
-
server_port=7860,
|
355 |
-
share=True,
|
356 |
-
show_error=True
|
357 |
-
)
|
358 |
-
|
359 |
-
logger.info("Application launched successfully")
|
360 |
|
361 |
|
362 |
if __name__ == "__main__":
|
|
|
92 |
def create_interface():
|
93 |
"""Create the main Gradio interface"""
|
94 |
|
95 |
+
# Simplified CSS based on original
|
96 |
css = """
|
97 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');
|
98 |
|
99 |
.gradio-container {
|
100 |
+
max-width: 1600px !important;
|
101 |
margin: 0 auto !important;
|
102 |
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
|
103 |
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
|
|
|
115 |
.prose h1, .prose h2, .prose h3,
|
116 |
.gr-markdown h1, .gr-markdown h2, .gr-markdown h3 {
|
117 |
color: #111827 !important;
|
118 |
+
font-weight: 700 !important;
|
119 |
}
|
120 |
|
121 |
+
.markdown-text p, .markdown-text li, .markdown-text ul, .markdown-text ol,
|
122 |
+
.prose p, .prose li, .prose ul, .prose ol,
|
123 |
+
.gr-markdown p, .gr-markdown li, .gr-markdown ul, .gr-markdown ol {
|
124 |
color: #374151 !important;
|
125 |
}
|
126 |
|
127 |
.markdown-text strong, .prose strong, .gr-markdown strong {
|
128 |
color: #111827 !important;
|
129 |
+
font-weight: 700 !important;
|
130 |
}
|
131 |
|
132 |
/* Header styling */
|
133 |
.main-header {
|
134 |
text-align: center;
|
135 |
+
padding: 3rem 0 4rem 0;
|
136 |
+
background: linear-gradient(135deg, #0c0a09 0%, #1c1917 30%, #292524 60%, #44403c 100%);
|
137 |
color: white;
|
138 |
+
margin: -2rem -2rem 3rem -2rem;
|
139 |
+
border-radius: 0 0 32px 32px;
|
140 |
+
box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.25);
|
141 |
+
position: relative;
|
142 |
+
overflow: hidden;
|
143 |
+
}
|
144 |
+
|
145 |
+
.main-header::before {
|
146 |
+
content: '';
|
147 |
+
position: absolute;
|
148 |
+
top: 0;
|
149 |
+
left: 0;
|
150 |
+
right: 0;
|
151 |
+
bottom: 0;
|
152 |
+
background: linear-gradient(45deg, rgba(59, 130, 246, 0.1) 0%, rgba(147, 51, 234, 0.1) 50%, rgba(236, 72, 153, 0.1) 100%);
|
153 |
+
z-index: 1;
|
154 |
}
|
155 |
|
156 |
.main-title {
|
157 |
+
font-size: 4rem !important;
|
158 |
+
font-weight: 900 !important;
|
159 |
+
margin: 0 0 1rem 0 !important;
|
160 |
+
letter-spacing: -0.05em !important;
|
161 |
+
background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 25%, #8b5cf6 50%, #a855f7 75%, #ec4899 100%);
|
162 |
+
-webkit-background-clip: text;
|
163 |
+
-webkit-text-fill-color: transparent;
|
164 |
+
background-clip: text;
|
165 |
+
position: relative;
|
166 |
+
z-index: 2;
|
167 |
}
|
168 |
|
169 |
.subtitle {
|
170 |
+
font-size: 1.5rem !important;
|
171 |
+
font-weight: 500 !important;
|
172 |
+
opacity: 0.95 !important;
|
173 |
margin: 0 !important;
|
174 |
+
position: relative;
|
175 |
+
z-index: 2;
|
176 |
+
color: #ffffff !important;
|
177 |
}
|
178 |
|
|
|
179 |
.prompt-output {
|
180 |
+
font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace !important;
|
181 |
+
font-size: 15px !important;
|
182 |
+
line-height: 1.8 !important;
|
183 |
background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%) !important;
|
184 |
border: 2px solid #e2e8f0 !important;
|
185 |
+
border-radius: 20px !important;
|
186 |
+
padding: 2.5rem !important;
|
187 |
+
box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.1) !important;
|
188 |
transition: all 0.3s ease !important;
|
189 |
color: #1f2937 !important;
|
190 |
}
|
191 |
|
192 |
.prompt-output:hover {
|
193 |
+
box-shadow: 0 25px 60px -5px rgba(0, 0, 0, 0.15) !important;
|
194 |
+
transform: translateY(-2px) !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
}
|
196 |
"""
|
197 |
|
198 |
with gr.Blocks(
|
199 |
+
theme=gr.themes.Soft(),
|
|
|
|
|
|
|
|
|
200 |
title="Frame 0 Laboratory for MIA",
|
201 |
css=css
|
202 |
) as interface:
|
203 |
|
|
|
204 |
gr.HTML("""
|
205 |
<div class="main-header">
|
206 |
<div class="main-title">Frame 0 Laboratory for MIA</div>
|
|
|
208 |
</div>
|
209 |
""")
|
210 |
|
|
|
211 |
with gr.Row():
|
|
|
212 |
with gr.Column(scale=1):
|
213 |
gr.Markdown("## Image Analysis")
|
214 |
|
215 |
image_input = gr.Image(
|
216 |
+
label="Upload image for analysis",
|
217 |
type="pil",
|
218 |
+
height=500
|
219 |
)
|
220 |
|
221 |
+
analyze_btn = gr.Button(
|
222 |
+
"🔍 Analyze Image",
|
223 |
+
variant="primary",
|
224 |
+
size="lg"
|
225 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
|
|
|
227 |
gr.Markdown("""
|
228 |
### How it works:
|
229 |
|
|
|
236 |
**Supported formats:** JPG, PNG, WebP up to 1024px
|
237 |
""")
|
238 |
|
239 |
+
# Statistics
|
240 |
with gr.Accordion("📊 Processing Stats", open=False):
|
241 |
stats_output = gr.Markdown(value="No processing completed yet.")
|
|
|
242 |
refresh_stats_btn = gr.Button("Refresh Stats", size="sm")
|
|
|
|
|
|
|
|
|
243 |
|
|
|
244 |
with gr.Column(scale=1):
|
245 |
gr.Markdown("## Results")
|
246 |
|
|
|
247 |
score_output = gr.HTML(
|
248 |
value='<div style="text-align: center; padding: 1rem;"><div style="font-size: 2rem; color: #ccc;">--</div><div style="font-size: 0.875rem; color: #999;">Quality Score</div></div>'
|
249 |
)
|
250 |
|
|
|
251 |
prompt_output = gr.Textbox(
|
252 |
label="🎯 Optimized FLUX Prompt",
|
253 |
placeholder="Upload an image to generate an optimized prompt...",
|
254 |
+
lines=12,
|
255 |
+
max_lines=20,
|
|
|
256 |
show_copy_button=True
|
257 |
)
|
258 |
|
259 |
+
info_output = gr.Markdown(value="")
|
260 |
+
|
261 |
+
clear_btn = gr.Button("🗑️ Clear Analysis", size="sm")
|
262 |
|
263 |
# Event handlers
|
264 |
analyze_btn.click(
|
|
|
272 |
outputs=[prompt_output, info_output, score_output]
|
273 |
)
|
274 |
|
275 |
+
refresh_stats_btn.click(
|
276 |
+
fn=get_stats_info,
|
277 |
+
outputs=stats_output
|
278 |
+
)
|
279 |
+
|
280 |
gr.Markdown("""
|
281 |
---
|
282 |
+
### Frame 0 Laboratory for MIA
|
283 |
+
|
284 |
+
This system uses state-of-the-art vision-language models to analyze images and generate optimized
|
285 |
+
prompts for FLUX image generation. The system applies proven optimization rules including camera
|
286 |
+
configurations, lighting setups, and technical parameters for best results.
|
287 |
|
288 |
+
**Frame 0 Laboratory for MIA** • Advanced AI Research & Development
|
|
|
|
|
289 |
""")
|
290 |
|
291 |
return interface
|
|
|
298 |
# Create and launch interface
|
299 |
demo = create_interface()
|
300 |
|
301 |
+
# Launch with proper configuration
|
302 |
+
demo.launch(
|
303 |
+
server_name="0.0.0.0",
|
304 |
+
server_port=7860,
|
305 |
+
share=True,
|
306 |
+
show_error=True
|
307 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
|
309 |
|
310 |
if __name__ == "__main__":
|