Spaces:
Running
on
Zero
Running
on
Zero
Update app.py from anycoder
Browse files
app.py
CHANGED
|
@@ -152,213 +152,266 @@ def read_file(path: str) -> str:
|
|
| 152 |
content = f.read()
|
| 153 |
return content
|
| 154 |
|
| 155 |
-
# Apple-style CSS
|
| 156 |
css = """
|
| 157 |
-
/* Apple
|
| 158 |
.gradio-container {
|
| 159 |
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
|
| 160 |
-
background:
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
| 162 |
}
|
| 163 |
|
| 164 |
#col-container {
|
| 165 |
margin: 0 auto;
|
| 166 |
-
max-width:
|
| 167 |
-
padding: 20px;
|
| 168 |
}
|
| 169 |
|
| 170 |
-
/*
|
| 171 |
.gradio-container .gr-block-header {
|
| 172 |
-
background:
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
padding: 30px !important;
|
| 178 |
-
margin-bottom: 30px !important;
|
| 179 |
-
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1) !important;
|
| 180 |
}
|
| 181 |
|
| 182 |
.gradio-container h1 {
|
| 183 |
-
font-weight:
|
| 184 |
-
font-size:
|
| 185 |
-
|
| 186 |
-
-
|
| 187 |
-
-
|
| 188 |
-
|
| 189 |
-
margin-bottom: 10px !important;
|
| 190 |
}
|
| 191 |
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
}
|
| 203 |
|
| 204 |
-
/*
|
| 205 |
.gradio-container .gr-button {
|
| 206 |
-
background:
|
| 207 |
border: none !important;
|
| 208 |
-
border-radius:
|
| 209 |
color: white !important;
|
| 210 |
-
font-weight:
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
| 214 |
}
|
| 215 |
|
| 216 |
.gradio-container .gr-button:hover {
|
| 217 |
-
|
| 218 |
-
|
|
|
|
| 219 |
}
|
| 220 |
|
| 221 |
.gradio-container .gr-button:active {
|
| 222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
}
|
| 224 |
|
| 225 |
/* Gallery styling */
|
| 226 |
.gradio-container .gr-gallery {
|
| 227 |
-
border-radius:
|
|
|
|
|
|
|
| 228 |
overflow: hidden !important;
|
| 229 |
-
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
|
| 230 |
}
|
| 231 |
|
| 232 |
-
/*
|
| 233 |
-
.gradio-container .gr-
|
| 234 |
-
.gradio-container .gr-slider,
|
| 235 |
-
.gradio-container .gr-checkbox {
|
| 236 |
border-radius: 12px !important;
|
| 237 |
-
border: 1px solid
|
| 238 |
-
background:
|
| 239 |
-
|
| 240 |
-
-webkit-backdrop-filter: blur(10px) !important;
|
| 241 |
}
|
| 242 |
|
| 243 |
-
|
| 244 |
-
.gradio-container .gr-
|
| 245 |
-
|
| 246 |
-
|
|
|
|
|
|
|
|
|
|
| 247 |
}
|
| 248 |
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
border
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
-webkit-backdrop-filter: blur(10px) !important;
|
| 256 |
}
|
| 257 |
|
| 258 |
-
/*
|
| 259 |
-
.gradio-container .gr-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
}
|
| 264 |
|
| 265 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
.gradio-container .gr-examples {
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
}
|
| 273 |
|
| 274 |
/* Mobile responsiveness */
|
| 275 |
@media (max-width: 768px) {
|
| 276 |
#col-container {
|
| 277 |
-
padding:
|
| 278 |
max-width: 100% !important;
|
| 279 |
}
|
| 280 |
|
| 281 |
-
.gradio-container
|
| 282 |
-
|
| 283 |
-
margin-bottom:
|
| 284 |
}
|
| 285 |
|
| 286 |
-
.gradio-container
|
| 287 |
-
font-size: 1.
|
| 288 |
}
|
| 289 |
|
| 290 |
-
.
|
| 291 |
-
padding:
|
| 292 |
-
margin-bottom:
|
| 293 |
}
|
| 294 |
|
| 295 |
.gradio-container .gr-button {
|
| 296 |
-
padding:
|
| 297 |
-
font-size:
|
| 298 |
}
|
| 299 |
|
| 300 |
.gradio-container .gr-gallery {
|
| 301 |
-
height:
|
|
|
|
| 302 |
}
|
| 303 |
|
| 304 |
.gradio-container .gr-row {
|
| 305 |
flex-direction: column !important;
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
.gradio-container .gr-slider,
|
| 309 |
-
.gradio-container .gr-textbox {
|
| 310 |
-
margin-bottom: 10px !important;
|
| 311 |
}
|
| 312 |
}
|
| 313 |
|
| 314 |
@media (max-width: 480px) {
|
| 315 |
.gradio-container h1 {
|
| 316 |
-
font-size: 1.
|
| 317 |
-
}
|
| 318 |
-
|
| 319 |
-
.gradio-container .gr-block-header {
|
| 320 |
-
padding: 15px !important;
|
| 321 |
}
|
| 322 |
|
| 323 |
-
.
|
| 324 |
-
padding:
|
| 325 |
}
|
| 326 |
|
| 327 |
.gradio-container .gr-gallery {
|
| 328 |
-
height:
|
| 329 |
columns: 1 !important;
|
| 330 |
}
|
| 331 |
}
|
| 332 |
|
| 333 |
-
/*
|
| 334 |
.gradio-container * {
|
| 335 |
-
transition:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
}
|
| 337 |
|
| 338 |
-
/*
|
| 339 |
.gradio-container ::-webkit-scrollbar {
|
| 340 |
-
width:
|
| 341 |
}
|
| 342 |
|
| 343 |
.gradio-container ::-webkit-scrollbar-track {
|
| 344 |
-
background:
|
| 345 |
-
border-radius: 10px !important;
|
| 346 |
}
|
| 347 |
|
| 348 |
.gradio-container ::-webkit-scrollbar-thumb {
|
| 349 |
-
background:
|
| 350 |
-
border-radius:
|
| 351 |
}
|
| 352 |
|
| 353 |
.gradio-container ::-webkit-scrollbar-thumb:hover {
|
| 354 |
-
background:
|
| 355 |
-
}
|
| 356 |
-
|
| 357 |
-
/* Loading states */
|
| 358 |
-
.gradio-container .gr-loading {
|
| 359 |
-
background: rgba(255, 255, 255, 0.95) !important;
|
| 360 |
-
backdrop-filter: blur(20px) !important;
|
| 361 |
-
-webkit-backdrop-filter: blur(20px) !important;
|
| 362 |
}
|
| 363 |
"""
|
| 364 |
|
|
@@ -368,77 +421,68 @@ with open('examples/0_examples.json', 'r') as file: examples = json.load(file)
|
|
| 368 |
print(examples)
|
| 369 |
|
| 370 |
# Gradio 6 syntax - no parameters in Blocks()
|
| 371 |
-
with gr.Blocks() as demo:
|
| 372 |
with gr.Column(elem_id="col-container"):
|
| 373 |
with gr.Column():
|
| 374 |
-
#
|
| 375 |
gr.HTML("""
|
| 376 |
<div style="text-align: center; max-width: 600px; margin: 0 auto;">
|
| 377 |
-
<h1
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
<
|
| 382 |
-
|
| 383 |
-
</p>
|
| 384 |
-
<p style="font-size: 0.9rem; color: #666;">
|
| 385 |
-
Demo by <a href="https://aisudo.com/" target="_blank" style="color: #667eea; text-decoration: none; font-weight: 600;">AiSudo</a> 😊
|
| 386 |
-
<br>
|
| 387 |
-
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" style="color: #667eea; text-decoration: none; font-size: 0.8rem;">Built with anycoder</a>
|
| 388 |
-
</p>
|
| 389 |
-
</div>
|
| 390 |
</div>
|
| 391 |
""")
|
| 392 |
|
| 393 |
with gr.Row():
|
| 394 |
-
with gr.Column():
|
| 395 |
input_images = gr.Gallery(
|
| 396 |
-
label="
|
| 397 |
file_types=["image"],
|
| 398 |
show_label=True,
|
| 399 |
-
elem_id="gallery",
|
| 400 |
columns=2,
|
| 401 |
object_fit="cover",
|
| 402 |
-
height=
|
| 403 |
|
| 404 |
-
lora_button = gr.Button("
|
| 405 |
|
| 406 |
-
with gr.Column():
|
| 407 |
lora_name = gr.Textbox(
|
| 408 |
-
label="
|
| 409 |
lines=2,
|
| 410 |
interactive=False,
|
| 411 |
-
placeholder="LoRA will appear here
|
| 412 |
)
|
| 413 |
lora_download = gr.DownloadButton(
|
| 414 |
-
label="
|
| 415 |
interactive=False,
|
| 416 |
size="lg"
|
| 417 |
)
|
| 418 |
|
| 419 |
-
with gr.Column(
|
| 420 |
-
gr.Markdown("###
|
| 421 |
with gr.Row():
|
| 422 |
with gr.Column():
|
| 423 |
prompt = gr.Textbox(
|
| 424 |
-
label="
|
| 425 |
-
show_label=True,
|
| 426 |
lines=2,
|
| 427 |
-
placeholder="
|
| 428 |
-
value="a
|
| 429 |
)
|
| 430 |
|
| 431 |
-
imagen_button = gr.Button("
|
| 432 |
|
| 433 |
-
with gr.Accordion("
|
| 434 |
negative_prompt = gr.Textbox(
|
| 435 |
-
label="
|
| 436 |
-
lines=
|
| 437 |
-
placeholder="
|
| 438 |
-
value="blurry
|
| 439 |
)
|
| 440 |
num_inference_steps = gr.Slider(
|
| 441 |
-
label="
|
| 442 |
minimum=1,
|
| 443 |
maximum=50,
|
| 444 |
step=1,
|
|
@@ -446,48 +490,38 @@ with gr.Blocks() as demo:
|
|
| 446 |
)
|
| 447 |
with gr.Row():
|
| 448 |
width = gr.Slider(
|
| 449 |
-
label="
|
| 450 |
minimum=512,
|
| 451 |
maximum=1280,
|
| 452 |
step=32,
|
| 453 |
value=768,
|
| 454 |
)
|
| 455 |
-
|
| 456 |
height = gr.Slider(
|
| 457 |
-
label="
|
| 458 |
minimum=512,
|
| 459 |
maximum=1280,
|
| 460 |
step=32,
|
| 461 |
value=1024,
|
| 462 |
)
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
guidance_scale = gr.Slider(
|
| 472 |
-
label="🎯 Guidance scale",
|
| 473 |
-
minimum=0.0,
|
| 474 |
-
maximum=10.0,
|
| 475 |
-
step=0.1,
|
| 476 |
-
value=3.5,
|
| 477 |
-
)
|
| 478 |
-
randomize_seed = gr.Checkbox(label="🔀 Randomize seed", value=False)
|
| 479 |
|
| 480 |
with gr.Column():
|
| 481 |
output_image = gr.Image(
|
| 482 |
-
label="
|
| 483 |
-
|
| 484 |
-
height=400
|
| 485 |
)
|
| 486 |
|
| 487 |
gr.Examples(
|
| 488 |
examples=examples,
|
| 489 |
inputs=[input_images],
|
| 490 |
-
label="
|
| 491 |
)
|
| 492 |
gr.Markdown(read_file("static/footer.md"))
|
| 493 |
|
|
@@ -521,27 +555,53 @@ if __name__ == "__main__":
|
|
| 521 |
# Gradio 6 syntax - all launch parameters go here
|
| 522 |
demo.launch(
|
| 523 |
mcp_server=True,
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 533 |
).set(
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 543 |
),
|
| 544 |
footer_links=[
|
| 545 |
{"label": "Built with anycoder", "url": "https://huggingface.co/spaces/akhaliq/anycoder"}
|
| 546 |
]
|
| 547 |
-
)
|
|
|
|
| 152 |
content = f.read()
|
| 153 |
return content
|
| 154 |
|
| 155 |
+
# Enhanced Apple-style CSS - more minimalist and clean
|
| 156 |
css = """
|
| 157 |
+
/* Pure Apple Design System */
|
| 158 |
.gradio-container {
|
| 159 |
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
|
| 160 |
+
background: #ffffff !important;
|
| 161 |
+
color: #1d1d1f !important;
|
| 162 |
+
line-height: 1.47059 !important;
|
| 163 |
+
font-weight: 400 !important;
|
| 164 |
+
letter-spacing: -.022em !important;
|
| 165 |
}
|
| 166 |
|
| 167 |
#col-container {
|
| 168 |
margin: 0 auto;
|
| 169 |
+
max-width: 980px;
|
| 170 |
+
padding: 40px 20px;
|
| 171 |
}
|
| 172 |
|
| 173 |
+
/* Ultra-minimalist header */
|
| 174 |
.gradio-container .gr-block-header {
|
| 175 |
+
background: transparent !important;
|
| 176 |
+
border: none !important;
|
| 177 |
+
padding: 0 !important;
|
| 178 |
+
margin-bottom: 60px !important;
|
| 179 |
+
box-shadow: none !important;
|
|
|
|
|
|
|
|
|
|
| 180 |
}
|
| 181 |
|
| 182 |
.gradio-container h1 {
|
| 183 |
+
font-weight: 600 !important;
|
| 184 |
+
font-size: 3rem !important;
|
| 185 |
+
color: #1d1d1f !important;
|
| 186 |
+
text-align: center !important;
|
| 187 |
+
margin-bottom: 16px !important;
|
| 188 |
+
letter-spacing: -.003em !important;
|
|
|
|
| 189 |
}
|
| 190 |
|
| 191 |
+
.gradio-container .subtitle {
|
| 192 |
+
font-size: 1.25rem !important;
|
| 193 |
+
font-weight: 400 !important;
|
| 194 |
+
color: #6e6e73 !important;
|
| 195 |
+
text-align: center !important;
|
| 196 |
+
margin-bottom: 8px !important;
|
| 197 |
+
line-height: 1.4 !important;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
/* Clean card sections */
|
| 201 |
+
.section-card {
|
| 202 |
+
background: #f2f2f7 !important;
|
| 203 |
+
border-radius: 18px !important;
|
| 204 |
+
padding: 32px !important;
|
| 205 |
+
margin-bottom: 32px !important;
|
| 206 |
+
border: none !important;
|
| 207 |
+
box-shadow: none !important;
|
| 208 |
}
|
| 209 |
|
| 210 |
+
/* Apple-style buttons */
|
| 211 |
.gradio-container .gr-button {
|
| 212 |
+
background: #007aff !important;
|
| 213 |
border: none !important;
|
| 214 |
+
border-radius: 8px !important;
|
| 215 |
color: white !important;
|
| 216 |
+
font-weight: 500 !important;
|
| 217 |
+
font-size: 17px !important;
|
| 218 |
+
padding: 16px 32px !important;
|
| 219 |
+
min-height: 44px !important;
|
| 220 |
+
transition: all 0.15s ease !important;
|
| 221 |
+
box-shadow: none !important;
|
| 222 |
+
letter-spacing: -.022em !important;
|
| 223 |
}
|
| 224 |
|
| 225 |
.gradio-container .gr-button:hover {
|
| 226 |
+
background: #0051d5 !important;
|
| 227 |
+
transform: none !important;
|
| 228 |
+
box-shadow: none !important;
|
| 229 |
}
|
| 230 |
|
| 231 |
.gradio-container .gr-button:active {
|
| 232 |
+
background: #004bb8 !important;
|
| 233 |
+
transform: scale(0.98) !important;
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
/* Clean input fields */
|
| 237 |
+
.gradio-container .gr-textbox,
|
| 238 |
+
.gradio-container .gr-slider {
|
| 239 |
+
background: #ffffff !important;
|
| 240 |
+
border: 1px solid #d2d2d7 !important;
|
| 241 |
+
border-radius: 10px !important;
|
| 242 |
+
padding: 12px 16px !important;
|
| 243 |
+
font-size: 17px !important;
|
| 244 |
+
color: #1d1d1f !important;
|
| 245 |
+
transition: all 0.15s ease !important;
|
| 246 |
+
min-height: 44px !important;
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
.gradio-container .gr-textbox:focus,
|
| 250 |
+
.gradio-container .gr-slider:focus {
|
| 251 |
+
border-color: #007aff !important;
|
| 252 |
+
box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1) !important;
|
| 253 |
+
outline: none !important;
|
| 254 |
}
|
| 255 |
|
| 256 |
/* Gallery styling */
|
| 257 |
.gradio-container .gr-gallery {
|
| 258 |
+
border-radius: 12px !important;
|
| 259 |
+
border: 1px solid #d2d2d7 !important;
|
| 260 |
+
background: #ffffff !important;
|
| 261 |
overflow: hidden !important;
|
|
|
|
| 262 |
}
|
| 263 |
|
| 264 |
+
/* Image output */
|
| 265 |
+
.gradio-container .gr-image {
|
|
|
|
|
|
|
| 266 |
border-radius: 12px !important;
|
| 267 |
+
border: 1px solid #d2d2d7 !important;
|
| 268 |
+
background: #ffffff !important;
|
| 269 |
+
overflow: hidden !important;
|
|
|
|
| 270 |
}
|
| 271 |
|
| 272 |
+
/* Accordion - Apple style */
|
| 273 |
+
.gradio-container .gr-accordion {
|
| 274 |
+
background: #f2f2f7 !important;
|
| 275 |
+
border: none !important;
|
| 276 |
+
border-radius: 12px !important;
|
| 277 |
+
padding: 0 !important;
|
| 278 |
+
margin-top: 24px !important;
|
| 279 |
}
|
| 280 |
|
| 281 |
+
.gradio-container .gr-accordion .gr-accordion-button {
|
| 282 |
+
background: transparent !important;
|
| 283 |
+
border: none !important;
|
| 284 |
+
padding: 16px !important;
|
| 285 |
+
font-weight: 500 !important;
|
| 286 |
+
color: #1d1d1f !important;
|
|
|
|
| 287 |
}
|
| 288 |
|
| 289 |
+
/* Download button */
|
| 290 |
+
.gradio-container .gr-download-button {
|
| 291 |
+
background: #34c759 !important;
|
| 292 |
+
border: none !important;
|
| 293 |
+
border-radius: 8px !important;
|
| 294 |
+
color: white !important;
|
| 295 |
+
font-weight: 500 !important;
|
| 296 |
+
font-size: 17px !important;
|
| 297 |
+
padding: 16px 32px !important;
|
| 298 |
+
min-height: 44px !important;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
.gradio-container .gr-download-button:hover {
|
| 302 |
+
background: #30a14a !important;
|
| 303 |
}
|
| 304 |
|
| 305 |
+
/* Checkbox styling */
|
| 306 |
+
.gradio-container .gr-checkbox {
|
| 307 |
+
background: #ffffff !important;
|
| 308 |
+
border: 2px solid #d2d2d7 !important;
|
| 309 |
+
border-radius: 6px !important;
|
| 310 |
+
width: 24px !important;
|
| 311 |
+
height: 24px !important;
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
.gradio-container .gr-checkbox.checked {
|
| 315 |
+
background: #007aff !important;
|
| 316 |
+
border-color: #007aff !important;
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
/* Examples section */
|
| 320 |
.gradio-container .gr-examples {
|
| 321 |
+
background: #f2f2f7 !important;
|
| 322 |
+
border-radius: 18px !important;
|
| 323 |
+
padding: 24px !important;
|
| 324 |
+
border: none !important;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
/* Label styling */
|
| 328 |
+
.gradio-container .gr-label {
|
| 329 |
+
font-weight: 600 !important;
|
| 330 |
+
color: #1d1d1f !important;
|
| 331 |
+
font-size: 17px !important;
|
| 332 |
+
margin-bottom: 8px !important;
|
| 333 |
+
letter-spacing: -.022em !important;
|
| 334 |
}
|
| 335 |
|
| 336 |
/* Mobile responsiveness */
|
| 337 |
@media (max-width: 768px) {
|
| 338 |
#col-container {
|
| 339 |
+
padding: 20px 16px !important;
|
| 340 |
max-width: 100% !important;
|
| 341 |
}
|
| 342 |
|
| 343 |
+
.gradio-container h1 {
|
| 344 |
+
font-size: 2rem !important;
|
| 345 |
+
margin-bottom: 12px !important;
|
| 346 |
}
|
| 347 |
|
| 348 |
+
.gradio-container .subtitle {
|
| 349 |
+
font-size: 1.1rem !important;
|
| 350 |
}
|
| 351 |
|
| 352 |
+
.section-card {
|
| 353 |
+
padding: 24px !important;
|
| 354 |
+
margin-bottom: 24px !important;
|
| 355 |
}
|
| 356 |
|
| 357 |
.gradio-container .gr-button {
|
| 358 |
+
padding: 14px 28px !important;
|
| 359 |
+
font-size: 16px !important;
|
| 360 |
}
|
| 361 |
|
| 362 |
.gradio-container .gr-gallery {
|
| 363 |
+
height: 200px !important;
|
| 364 |
+
columns: 2 !important;
|
| 365 |
}
|
| 366 |
|
| 367 |
.gradio-container .gr-row {
|
| 368 |
flex-direction: column !important;
|
| 369 |
+
gap: 20px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
}
|
| 371 |
}
|
| 372 |
|
| 373 |
@media (max-width: 480px) {
|
| 374 |
.gradio-container h1 {
|
| 375 |
+
font-size: 1.75rem !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
}
|
| 377 |
|
| 378 |
+
.section-card {
|
| 379 |
+
padding: 20px !important;
|
| 380 |
}
|
| 381 |
|
| 382 |
.gradio-container .gr-gallery {
|
| 383 |
+
height: 180px !important;
|
| 384 |
columns: 1 !important;
|
| 385 |
}
|
| 386 |
}
|
| 387 |
|
| 388 |
+
/* Remove all animations for Apple-like snappiness */
|
| 389 |
.gradio-container * {
|
| 390 |
+
transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease !important;
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
/* Hide unnecessary elements */
|
| 394 |
+
.gradio-container .gr-footer,
|
| 395 |
+
.gradio-container .gr-header {
|
| 396 |
+
display: none !important;
|
| 397 |
}
|
| 398 |
|
| 399 |
+
/* Clean scrollbar */
|
| 400 |
.gradio-container ::-webkit-scrollbar {
|
| 401 |
+
width: 3px !important;
|
| 402 |
}
|
| 403 |
|
| 404 |
.gradio-container ::-webkit-scrollbar-track {
|
| 405 |
+
background: transparent !important;
|
|
|
|
| 406 |
}
|
| 407 |
|
| 408 |
.gradio-container ::-webkit-scrollbar-thumb {
|
| 409 |
+
background: #d2d2d7 !important;
|
| 410 |
+
border-radius: 3px !important;
|
| 411 |
}
|
| 412 |
|
| 413 |
.gradio-container ::-webkit-scrollbar-thumb:hover {
|
| 414 |
+
background: #007aff !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 415 |
}
|
| 416 |
"""
|
| 417 |
|
|
|
|
| 421 |
print(examples)
|
| 422 |
|
| 423 |
# Gradio 6 syntax - no parameters in Blocks()
|
| 424 |
+
with gr.Blocks(css=css) as demo:
|
| 425 |
with gr.Column(elem_id="col-container"):
|
| 426 |
with gr.Column():
|
| 427 |
+
# Ultra-minimalist Apple-style header
|
| 428 |
gr.HTML("""
|
| 429 |
<div style="text-align: center; max-width: 600px; margin: 0 auto;">
|
| 430 |
+
<h1>Qwen Image to LoRA</h1>
|
| 431 |
+
<p class="subtitle">Generate custom LoRA models from your images</p>
|
| 432 |
+
<p style="font-size: 14px; color: #86868b; margin-top: 16px;">
|
| 433 |
+
Demo by <a href="https://aisudo.com/" target="_blank" style="color: #007aff; text-decoration: none;">AiSudo</a> •
|
| 434 |
+
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" style="color: #007aff; text-decoration: none;">Built with anycoder</a>
|
| 435 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 436 |
</div>
|
| 437 |
""")
|
| 438 |
|
| 439 |
with gr.Row():
|
| 440 |
+
with gr.Column(elem_classes=["section-card"]):
|
| 441 |
input_images = gr.Gallery(
|
| 442 |
+
label="Input Images",
|
| 443 |
file_types=["image"],
|
| 444 |
show_label=True,
|
|
|
|
| 445 |
columns=2,
|
| 446 |
object_fit="cover",
|
| 447 |
+
height=250)
|
| 448 |
|
| 449 |
+
lora_button = gr.Button("Generate LoRA", size="lg")
|
| 450 |
|
| 451 |
+
with gr.Column(elem_classes=["section-card"]):
|
| 452 |
lora_name = gr.Textbox(
|
| 453 |
+
label="Generated LoRA",
|
| 454 |
lines=2,
|
| 455 |
interactive=False,
|
| 456 |
+
placeholder="Your LoRA will appear here..."
|
| 457 |
)
|
| 458 |
lora_download = gr.DownloadButton(
|
| 459 |
+
label="Download LoRA",
|
| 460 |
interactive=False,
|
| 461 |
size="lg"
|
| 462 |
)
|
| 463 |
|
| 464 |
+
with gr.Column(elem_classes=["section-card"]) as imagen_container:
|
| 465 |
+
gr.Markdown("### Generate Images")
|
| 466 |
with gr.Row():
|
| 467 |
with gr.Column():
|
| 468 |
prompt = gr.Textbox(
|
| 469 |
+
label="Prompt",
|
|
|
|
| 470 |
lines=2,
|
| 471 |
+
placeholder="Describe what you want to generate...",
|
| 472 |
+
value="a person in a fishing boat.",
|
| 473 |
)
|
| 474 |
|
| 475 |
+
imagen_button = gr.Button("Generate Image", interactive=False, size="lg")
|
| 476 |
|
| 477 |
+
with gr.Accordion("Settings", open=False):
|
| 478 |
negative_prompt = gr.Textbox(
|
| 479 |
+
label="Negative Prompt",
|
| 480 |
+
lines=1,
|
| 481 |
+
placeholder="What to avoid...",
|
| 482 |
+
value="blurry, low quality"
|
| 483 |
)
|
| 484 |
num_inference_steps = gr.Slider(
|
| 485 |
+
label="Steps",
|
| 486 |
minimum=1,
|
| 487 |
maximum=50,
|
| 488 |
step=1,
|
|
|
|
| 490 |
)
|
| 491 |
with gr.Row():
|
| 492 |
width = gr.Slider(
|
| 493 |
+
label="Width",
|
| 494 |
minimum=512,
|
| 495 |
maximum=1280,
|
| 496 |
step=32,
|
| 497 |
value=768,
|
| 498 |
)
|
|
|
|
| 499 |
height = gr.Slider(
|
| 500 |
+
label="Height",
|
| 501 |
minimum=512,
|
| 502 |
maximum=1280,
|
| 503 |
step=32,
|
| 504 |
value=1024,
|
| 505 |
)
|
| 506 |
+
seed = gr.Slider(
|
| 507 |
+
label="Seed",
|
| 508 |
+
minimum=0,
|
| 509 |
+
maximum=MAX_SEED,
|
| 510 |
+
step=1,
|
| 511 |
+
value=42,
|
| 512 |
+
)
|
| 513 |
+
randomize_seed = gr.Checkbox(label="Randomize Seed", value=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 514 |
|
| 515 |
with gr.Column():
|
| 516 |
output_image = gr.Image(
|
| 517 |
+
label="Generated Image",
|
| 518 |
+
height=350
|
|
|
|
| 519 |
)
|
| 520 |
|
| 521 |
gr.Examples(
|
| 522 |
examples=examples,
|
| 523 |
inputs=[input_images],
|
| 524 |
+
label="Examples"
|
| 525 |
)
|
| 526 |
gr.Markdown(read_file("static/footer.md"))
|
| 527 |
|
|
|
|
| 555 |
# Gradio 6 syntax - all launch parameters go here
|
| 556 |
demo.launch(
|
| 557 |
mcp_server=True,
|
| 558 |
+
theme=gr.themes.Base(
|
| 559 |
+
primary_hue="blue",
|
| 560 |
+
secondary_hue="gray",
|
| 561 |
+
neutral_hue="gray",
|
| 562 |
+
font=[
|
| 563 |
+
gr.themes.GoogleFont("Inter"),
|
| 564 |
+
"ui-sans-serif",
|
| 565 |
+
"system-ui",
|
| 566 |
+
"sans-serif"
|
| 567 |
+
],
|
| 568 |
+
font_mono=[
|
| 569 |
+
gr.themes.GoogleFont("JetBrains Mono"),
|
| 570 |
+
"ui-monospace",
|
| 571 |
+
"Consolas",
|
| 572 |
+
"monospace"
|
| 573 |
+
]
|
| 574 |
).set(
|
| 575 |
+
body_background_fill="white",
|
| 576 |
+
body_background_fill_dark="#000000",
|
| 577 |
+
button_primary_background_fill="#007aff",
|
| 578 |
+
button_primary_background_fill_hover="#0051d5",
|
| 579 |
+
button_primary_background_fill_active="#004bb8",
|
| 580 |
+
button_primary_text_color="white",
|
| 581 |
+
button_secondary_background_fill="#f2f2f7",
|
| 582 |
+
button_secondary_background_fill_hover="#e5e5ea",
|
| 583 |
+
block_background_fill="white",
|
| 584 |
+
block_background_fill_dark="#1c1c1e",
|
| 585 |
+
block_border_width="0px",
|
| 586 |
+
block_border_color="#d2d2d7",
|
| 587 |
+
block_border_color_dark="#38383a",
|
| 588 |
+
block_radius="18px",
|
| 589 |
+
block_shadow="none",
|
| 590 |
+
block_label_text_color="#1d1d1f",
|
| 591 |
+
block_label_text_color_dark="#f2f2f2",
|
| 592 |
+
block_title_text_color="#1d1d1f",
|
| 593 |
+
block_title_text_color_dark="#f2f2f2",
|
| 594 |
+
input_background_fill="white",
|
| 595 |
+
input_background_fill_dark="#1c1c1e",
|
| 596 |
+
input_border_color="#d2d2d7",
|
| 597 |
+
input_border_color_dark="#38383a",
|
| 598 |
+
input_border_width="1px",
|
| 599 |
+
input_radius="10px",
|
| 600 |
+
input_shadow="none",
|
| 601 |
+
input_text_color="#1d1d1f",
|
| 602 |
+
input_text_color_dark="#f2f2f2",
|
| 603 |
),
|
| 604 |
footer_links=[
|
| 605 |
{"label": "Built with anycoder", "url": "https://huggingface.co/spaces/akhaliq/anycoder"}
|
| 606 |
]
|
| 607 |
+
)
|