Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -587,26 +587,22 @@ with gr.Blocks(title="QuickDraw 風格資料蒐集 & 瀏覽") as demo:
|
|
| 587 |
extra = ""
|
| 588 |
if mode == "count_any":
|
| 589 |
need = int(sc.get("need_count", 1))
|
| 590 |
-
extra = f"
|
| 591 |
elif mode == "collect_all":
|
| 592 |
targets = sc.get("targets", [])
|
| 593 |
got = set(collected or [])
|
| 594 |
checklist = " / ".join([f"{'✅' if t in got else '⬜'} {t}" for t in targets])
|
| 595 |
-
extra = f"
|
| 596 |
|
| 597 |
-
prompt = f"""
|
| 598 |
-
<div style="font-size:22px; font-weight:600; margin-bottom:8px;">
|
| 599 |
-
關卡:{name}
|
| 600 |
-
</div>
|
| 601 |
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 605 |
|
| 606 |
-
<div style="font-size:16px; line-height:1.4; margin-top:6px; opacity:0.85;">
|
| 607 |
-
{extra}
|
| 608 |
-
</div>
|
| 609 |
-
"""
|
| 610 |
|
| 611 |
|
| 612 |
can_draw = in_draw_phase(scene_idx, img_idx)
|
|
@@ -672,7 +668,7 @@ with gr.Blocks(title="QuickDraw 風格資料蒐集 & 瀏覽") as demo:
|
|
| 672 |
img_path,
|
| 673 |
prompt,
|
| 674 |
{}, # 清空 top5
|
| 675 |
-
None
|
| 676 |
guess_upd,
|
| 677 |
next_upd
|
| 678 |
)
|
|
@@ -742,7 +738,7 @@ with gr.Blocks(title="QuickDraw 風格資料蒐集 & 瀏覽") as demo:
|
|
| 742 |
return (
|
| 743 |
scene_idx, img_idx, count, collected, False,
|
| 744 |
"🎉 恭喜完成料理!",
|
| 745 |
-
|
| 746 |
None,
|
| 747 |
img_path, prompt,
|
| 748 |
gr.update(interactive=False),
|
|
@@ -762,15 +758,15 @@ with gr.Blocks(title="QuickDraw 風格資料蒐集 & 瀏覽") as demo:
|
|
| 762 |
img_path, prompt, guess_upd, next_upd, _ = render_ui(scene_idx, img_idx, count, collected, live)
|
| 763 |
|
| 764 |
status = status + "\n\n🎉 關卡完成!自動進入下一段。"
|
| 765 |
-
# 清空畫布 + 清空 top5,進下一段(如果是過場就按 Next)
|
| 766 |
return (
|
| 767 |
scene_idx, img_idx, count, collected, live,
|
| 768 |
status,
|
| 769 |
-
{}, None,
|
| 770 |
img_path, prompt,
|
| 771 |
guess_upd, next_upd
|
| 772 |
)
|
| 773 |
|
|
|
|
| 774 |
# 還沒完成:留在本關,更新 UI(進度/收集狀態會顯示在 prompt)
|
| 775 |
img_path, prompt, guess_upd, next_upd, _ = render_ui(scene_idx, img_idx, count, collected, live)
|
| 776 |
return (
|
|
|
|
| 587 |
extra = ""
|
| 588 |
if mode == "count_any":
|
| 589 |
need = int(sc.get("need_count", 1))
|
| 590 |
+
extra = f"進度:**{int(count)}/{need}**"
|
| 591 |
elif mode == "collect_all":
|
| 592 |
targets = sc.get("targets", [])
|
| 593 |
got = set(collected or [])
|
| 594 |
checklist = " / ".join([f"{'✅' if t in got else '⬜'} {t}" for t in targets])
|
| 595 |
+
extra = f"收集:{checklist}"
|
| 596 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 597 |
|
| 598 |
+
prompt = (
|
| 599 |
+
f"## 關卡:{name}\n\n"
|
| 600 |
+
f"{base_prompt}\n\n"
|
| 601 |
+
f"---\n\n"
|
| 602 |
+
f"{extra}"
|
| 603 |
+
)
|
| 604 |
+
|
| 605 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 606 |
|
| 607 |
|
| 608 |
can_draw = in_draw_phase(scene_idx, img_idx)
|
|
|
|
| 668 |
img_path,
|
| 669 |
prompt,
|
| 670 |
{}, # 清空 top5
|
| 671 |
+
gr.update(value=None) # 清空畫布
|
| 672 |
guess_upd,
|
| 673 |
next_upd
|
| 674 |
)
|
|
|
|
| 738 |
return (
|
| 739 |
scene_idx, img_idx, count, collected, False,
|
| 740 |
"🎉 恭喜完成料理!",
|
| 741 |
+
probs,
|
| 742 |
None,
|
| 743 |
img_path, prompt,
|
| 744 |
gr.update(interactive=False),
|
|
|
|
| 758 |
img_path, prompt, guess_upd, next_upd, _ = render_ui(scene_idx, img_idx, count, collected, live)
|
| 759 |
|
| 760 |
status = status + "\n\n🎉 關卡完成!自動進入下一段。"
|
|
|
|
| 761 |
return (
|
| 762 |
scene_idx, img_idx, count, collected, live,
|
| 763 |
status,
|
| 764 |
+
{}, gr.update(value=None), # ✅ 強制清空畫布
|
| 765 |
img_path, prompt,
|
| 766 |
guess_upd, next_upd
|
| 767 |
)
|
| 768 |
|
| 769 |
+
|
| 770 |
# 還沒完成:留在本關,更新 UI(進度/收集狀態會顯示在 prompt)
|
| 771 |
img_path, prompt, guess_upd, next_upd, _ = render_ui(scene_idx, img_idx, count, collected, live)
|
| 772 |
return (
|