Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -545,6 +545,27 @@ gr.HTML("""
|
|
| 545 |
</div>
|
| 546 |
""")
|
| 547 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 548 |
with gr.Blocks(css=css) as demo:
|
| 549 |
# βββ States βββ
|
| 550 |
image_data_state = gr.State([])
|
|
@@ -636,7 +657,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 636 |
)
|
| 637 |
|
| 638 |
process_btn.click(
|
| 639 |
-
fn=
|
| 640 |
process_url_images(sd, fmt, w, h) if mode.startswith("π") and sd else
|
| 641 |
process_uploaded_images(ups, fmt, w, h) if mode.startswith("π€") and ups else
|
| 642 |
process_single_url_image(pu, fmt, w, h) if pu.strip() else
|
|
|
|
| 545 |
</div>
|
| 546 |
""")
|
| 547 |
|
| 548 |
+
def process_all(mode, workbook_file, ups, pu, fmt, w, h):
|
| 549 |
+
# π Workbook mode
|
| 550 |
+
if mode.startswith("π"):
|
| 551 |
+
data, msg = read_uploaded_workbook(workbook_file)
|
| 552 |
+
if not data:
|
| 553 |
+
# no links β just show the fetchβerror
|
| 554 |
+
return [], None, msg, None
|
| 555 |
+
# got a list of dicts β process them
|
| 556 |
+
return process_and_zip(data, fmt, w, h)
|
| 557 |
+
|
| 558 |
+
# π€ Direct image files
|
| 559 |
+
if mode.startswith("π€") and ups:
|
| 560 |
+
return process_uploaded_images(ups, fmt, w, h)
|
| 561 |
+
|
| 562 |
+
# π Single URL
|
| 563 |
+
if pu and pu.strip():
|
| 564 |
+
return process_single_url_image(pu, fmt, w, h)
|
| 565 |
+
|
| 566 |
+
# nothing valid
|
| 567 |
+
return [], None, "β οΈ No valid input provided", None
|
| 568 |
+
|
| 569 |
with gr.Blocks(css=css) as demo:
|
| 570 |
# βββ States βββ
|
| 571 |
image_data_state = gr.State([])
|
|
|
|
| 657 |
)
|
| 658 |
|
| 659 |
process_btn.click(
|
| 660 |
+
fn=process_all, sd, ups, pu, fmt, w, h: (
|
| 661 |
process_url_images(sd, fmt, w, h) if mode.startswith("π") and sd else
|
| 662 |
process_uploaded_images(ups, fmt, w, h) if mode.startswith("π€") and ups else
|
| 663 |
process_single_url_image(pu, fmt, w, h) if pu.strip() else
|