Spaces:
Running on Zero
Running on Zero
fix: remove @spaces.GPU from on_analyze; add Model Card button with GPU dummy; fix clear button output count
Browse files
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):
|