Spaces:
Sleeping
Sleeping
updated the Ui
Browse files
app.py
CHANGED
|
@@ -294,24 +294,108 @@ def generate_and_score(query: str):
|
|
| 294 |
score = eval_resp.choices[0].message.content.strip()
|
| 295 |
|
| 296 |
return post, score
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
|
| 298 |
-
# Build Gradio
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
gr.Markdown("## iboothme Instagram Caption Generator & Evaluator")
|
| 303 |
with gr.Row():
|
| 304 |
query_input = gr.Textbox(
|
| 305 |
label="Enter your post brief or query",
|
| 306 |
placeholder="e.g. Client: NAOS… Challenge: Engage attendees at…",
|
| 307 |
lines=4
|
| 308 |
)
|
|
|
|
| 309 |
with gr.Row():
|
| 310 |
-
generate_btn = gr.Button("Generate & Score", variant="primary")
|
|
|
|
| 311 |
with gr.Row():
|
| 312 |
post_output = gr.Textbox(label="Generated Instagram Caption", lines=10)
|
| 313 |
score_output = gr.Textbox(label="Quality Score (1–10)", lines=1)
|
| 314 |
-
|
| 315 |
generate_btn.click(
|
| 316 |
fn=generate_and_score,
|
| 317 |
inputs=[query_input],
|
|
@@ -319,4 +403,4 @@ with gr.Blocks(title="iboothme Instagram Post Generator", theme=theme) as demo:
|
|
| 319 |
)
|
| 320 |
|
| 321 |
if __name__ == "__main__":
|
| 322 |
-
demo.launch()
|
|
|
|
| 294 |
score = eval_resp.choices[0].message.content.strip()
|
| 295 |
|
| 296 |
return post, score
|
| 297 |
+
# Custom CSS for Instagram‑inspired gradient, typography, and layout
|
| 298 |
+
custom_css = """
|
| 299 |
+
/* Background gradient */
|
| 300 |
+
body {
|
| 301 |
+
background: linear-gradient(135deg, #FDF2F8 0%, #F3E8FF 50%, #FFFFFF 100%);
|
| 302 |
+
height: 100vh;
|
| 303 |
+
margin: 0;
|
| 304 |
+
font-family: 'Poppins', sans-serif;
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
/* Main title styling */
|
| 308 |
+
h1, h2, h3 {
|
| 309 |
+
background: linear-gradient(90deg, #8B5CF6, #EC4899);
|
| 310 |
+
-webkit-background-clip: text;
|
| 311 |
+
-webkit-text-fill-color: transparent;
|
| 312 |
+
font-weight: 800 !important;
|
| 313 |
+
text-align: center;
|
| 314 |
+
margin-bottom: 1rem;
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
/* Section headers */
|
| 318 |
+
.gr-textbox label, .gr-button, .gr-textbox-output label {
|
| 319 |
+
font-weight: 600 !important;
|
| 320 |
+
font-size: 1.2rem !important;
|
| 321 |
+
color: #374151 !important;
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
/* Input and output boxes */
|
| 325 |
+
textarea, input {
|
| 326 |
+
border-radius: 16px !important;
|
| 327 |
+
border: 2px solid transparent !important;
|
| 328 |
+
background: rgba(255,255,255,0.8) !important;
|
| 329 |
+
padding: 12px !important;
|
| 330 |
+
font-size: 1rem !important;
|
| 331 |
+
font-weight: 400 !important;
|
| 332 |
+
color: #1F2937 !important;
|
| 333 |
+
}
|
| 334 |
+
textarea:focus, input:focus {
|
| 335 |
+
outline: none !important;
|
| 336 |
+
border: 2px solid #8B5CF6 !important;
|
| 337 |
+
box-shadow: 0 0 10px rgba(139,92,246,0.5) !important;
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
/* Generate button */
|
| 341 |
+
button {
|
| 342 |
+
background: linear-gradient(90deg, #8B5CF6, #EC4899) !important;
|
| 343 |
+
color: #FFFFFF !important;
|
| 344 |
+
border: none !important;
|
| 345 |
+
border-radius: 16px !important;
|
| 346 |
+
font-size: 1.1rem !important;
|
| 347 |
+
font-weight: 700 !important;
|
| 348 |
+
padding: 14px 24px !important;
|
| 349 |
+
transition: all 0.3s ease !important;
|
| 350 |
+
}
|
| 351 |
+
button:hover {
|
| 352 |
+
background: linear-gradient(90deg, #EC4899, #8B5CF6) !important;
|
| 353 |
+
transform: translateY(-2px) !important;
|
| 354 |
+
box-shadow: 0 4px 20px rgba(236,72,153,0.4) !important;
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
/* Output caption box larger */
|
| 358 |
+
.gr-textbox-output textarea {
|
| 359 |
+
min-height: 200px !important;
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
/* Score display styling */
|
| 363 |
+
.score-box {
|
| 364 |
+
display: flex;
|
| 365 |
+
align-items: center;
|
| 366 |
+
justify-content: center;
|
| 367 |
+
background: linear-gradient(90deg, #3B82F6, #8B5CF6) !important;
|
| 368 |
+
border-radius: 50%;
|
| 369 |
+
width: 80px;
|
| 370 |
+
height: 80px;
|
| 371 |
+
margin: auto;
|
| 372 |
+
}
|
| 373 |
+
.score-box p {
|
| 374 |
+
color: #FFFFFF;
|
| 375 |
+
font-size: 2rem;
|
| 376 |
+
font-weight: 800;
|
| 377 |
+
margin: 0;
|
| 378 |
+
}
|
| 379 |
+
"""
|
| 380 |
|
| 381 |
+
# Build the Gradio app
|
| 382 |
+
with gr.Blocks(css=custom_css, title="iboothme Instagram Post Generator") as demo:
|
| 383 |
+
gr.Markdown("<h1>📸 iboothme Instagram Caption Generator & Evaluator</h1>")
|
| 384 |
+
|
|
|
|
| 385 |
with gr.Row():
|
| 386 |
query_input = gr.Textbox(
|
| 387 |
label="Enter your post brief or query",
|
| 388 |
placeholder="e.g. Client: NAOS… Challenge: Engage attendees at…",
|
| 389 |
lines=4
|
| 390 |
)
|
| 391 |
+
|
| 392 |
with gr.Row():
|
| 393 |
+
generate_btn = gr.Button("🚀 Generate & Score", variant="primary")
|
| 394 |
+
|
| 395 |
with gr.Row():
|
| 396 |
post_output = gr.Textbox(label="Generated Instagram Caption", lines=10)
|
| 397 |
score_output = gr.Textbox(label="Quality Score (1–10)", lines=1)
|
| 398 |
+
|
| 399 |
generate_btn.click(
|
| 400 |
fn=generate_and_score,
|
| 401 |
inputs=[query_input],
|
|
|
|
| 403 |
)
|
| 404 |
|
| 405 |
if __name__ == "__main__":
|
| 406 |
+
demo.launch(share=True)
|