phonghh commited on
Commit
bdcbd2b
Β·
1 Parent(s): 7de3058

fix: remove @spaces.GPU from on_analyze; add Model Card button with GPU dummy; fix clear button output count

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -276,6 +276,7 @@ def build_app(predict_fn, model_choices: list[str]) -> gr.Blocks:
276
  with gr.Row():
277
  analyze_btn = gr.Button("πŸ” Analyze", variant="primary", scale=2)
278
  clear_btn = gr.Button("πŸ—‘οΈ Clear", scale=1)
 
279
 
280
  gr.Markdown("### πŸ€– Model")
281
  model_dropdown = gr.Dropdown(
@@ -387,7 +388,6 @@ def build_app(predict_fn, model_choices: list[str]) -> gr.Blocks:
387
  csv = ", ".join(format_tag(t, _use_underscore) for t, _ in items)
388
  return table, csv
389
 
390
- @spaces.GPU
391
  def on_analyze(image, url):
392
  if image is None and not url:
393
  return *refresh_results(
@@ -446,7 +446,7 @@ def build_app(predict_fn, model_choices: list[str]) -> gr.Blocks:
446
  state["all_logits"] = None
447
  state["tag_metadata"] = None
448
  state["current_image"] = None
449
- return None, "", "<i>No results yet.</i>", "Cleared.", "", ""
450
 
451
  clear_btn.click(
452
  fn=on_clear,
@@ -498,6 +498,17 @@ def build_app(predict_fn, model_choices: list[str]) -> gr.Blocks:
498
  }"""
499
  )
500
 
 
 
 
 
 
 
 
 
 
 
 
501
  # ── model switcher ────────────────────────────────────────────────
502
 
503
  def on_model_change(variant):
 
276
  with gr.Row():
277
  analyze_btn = gr.Button("πŸ” Analyze", variant="primary", scale=2)
278
  clear_btn = gr.Button("πŸ—‘οΈ Clear", scale=1)
279
+ model_card_btn = gr.Button("πŸ“„ Model Card", scale=1)
280
 
281
  gr.Markdown("### πŸ€– Model")
282
  model_dropdown = gr.Dropdown(
 
388
  csv = ", ".join(format_tag(t, _use_underscore) for t, _ in items)
389
  return table, csv
390
 
 
391
  def on_analyze(image, url):
392
  if image is None and not url:
393
  return *refresh_results(
 
446
  state["all_logits"] = None
447
  state["tag_metadata"] = None
448
  state["current_image"] = None
449
+ return None, "", "<i>No results yet.</i>", "Cleared.", "", "", "<i>No results yet.</i>"
450
 
451
  clear_btn.click(
452
  fn=on_clear,
 
498
  }"""
499
  )
500
 
501
+ @spaces.GPU
502
+ def _gpu_dummy():
503
+ return None
504
+
505
+ model_card_btn.click(
506
+ fn=_gpu_dummy,
507
+ inputs=[],
508
+ outputs=[],
509
+ js='() => window.open("https://huggingface.co/realphongha/danbooru-tag-query", "_blank")'
510
+ )
511
+
512
  # ── model switcher ────────────────────────────────────────────────
513
 
514
  def on_model_change(variant):