Skip to content

per-tag thresholds for animetimm models - #3

Draft
Foxyz1302 wants to merge 5 commits into
itterative:feature/svelte-frontendfrom
Foxyz1302:feature/svelte-frontend
Draft

Foxyz1302 wants to merge 5 commits into
itterative:feature/svelte-frontendfrom
Foxyz1302:feature/svelte-frontend

Conversation

@Foxyz1302

Copy link
Copy Markdown

this wires up the per-tag threshold toggle.

how it works: if the model's csv has best_threshold / best_recall columns, the tag settings show a checkbox to use those instead of the three sliders, plus a dropdown to pick which column. wd models don't have the columns so nothing changes for them.

i tested it with the unit tests (csv parsing, threshold override, cache keys) and clicked through the toggle + swap in the ui. ruff, eslint and svelte-check are clean.

two things to know:

  • unknown column values get a 400 instead of silently falling back
  • only best_threshold and best_recall are supported, best_f1 csvs will just not show the toggle

Wire per_tag_thresholds/per_tag_column per request through
TagImageBody/TagJobOptions into TaggingThresholds, resolve the
per-tag dict per request, isolate cache slots per toggle+column
with unknown-column collapse, validate column values (400),
refresh thresholds on swap rollback and set_active_tagger.
Forward per-tag options in tagImage/startTagJob/fetch/preview,
pass through single/batch actions, dynamic column dropdown from
per_tag_columns with reset on unsupported models, Tags tab fetch
and preview carry per-tag, re-fetch on swap settled via SSE.
Cover CSV parsing edge cases, per-tag override/fallback semantics,
options resolution, cache-key divergence and unknown-column
collapse, get_tag_result filtering, active-endpoint capability,
body validation, and rollback refresh.
Comment thread yadc/api/controllers/api_tagging.py Outdated
per_tag_enabled = None if per_tag_raw is None else per_tag_raw.lower() in ("true", "1", "yes")
per_tag_column = request.args.get("per_tag_column")
if per_tag_column is not None:
from yadc.taggers.onnx import PER_TAG_THRESHOLD_COLUMNS as _PER_TAG_COLS

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, might be good to have this outside of onnx so it doesn't have to import heavy. might be good to move these to onnx_preprocess ig since it already has the profiles

let sawSwapTransition = $state(false);

async function fetchPerTagSupport(signal?: AbortSignal, retries = 3) {
for (let i = 0; i < retries; i++) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abort should be handled both in the loop and in the catch

return;
} catch {
if (i < retries - 1) {
await new Promise((r) => setTimeout(r, 2000));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a sleep promise in async.ts

sawSwapTransition = false;
fetchPerTagSupport();
};
window.addEventListener(TAGGER_SWAPPED_EVENT, handler);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer subscribing to the active tagger rather than using an event here. though you'll need to move it to a store. there's no active tagger event on the backend I see, I missed adding that

onnx pulls numpy and the session machinery; the column allowlist
and CSV loader need neither. Top-level imports everywhere, no
more lazy dance in validators and refresh.
Capability derives from a shared store re-fetched on tagger_status
settle (cross-tab, survives long HF downloads). Drops
TAGGER_SWAPPED_EVENT and the abort-unaware retry loop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants