28 Commits

Author SHA1 Message Date
bvandeusen ce560d09a1 feat(integrity): structural verification + supersede-on-replace pipeline
Adds per-image integrity tracking so corrupt files are detected, excluded
from random/showcase/ML/suggestion paths, and recoverable by dropping a
fresh copy in /import — closing the gap that surfaced as the WD14
'6 bytes not processed' OSError.

Schema (migration l26042501)
- image_record.integrity_status: unknown | ok | truncated | unreadable | missing
- image_record.integrity_checked_at: timestamptz
- partial index on status <> 'ok' for cheap report/filter queries

Verifier
- app/services/integrity.py: verify_path() dispatches by extension
- PIL two-stage (verify + load with LOAD_TRUNCATED_IMAGES disabled)
- ffprobe for video, zipfile.testzip for archives
- Truncation-vs-unreadable distinction via PIL message hints

Pipeline
- verify_media_integrity Celery task: per-image, idempotent
- verify_unverified_images sweep: only_unknown by default, skips
  paths in active import tasks
- Hooked into the end of import_media_file (new + archive paths) and
  the supersede branch
- supersede_image() resets status to 'unknown' so the post-supersede
  verify writes a fresh truth
- Supersede-on-replace: a fresh /import/<artist>/<filename> matching
  a flagged-corrupt record routes through _supersede_existing,
  preserving tags/series/embeddings

Exclusions
- /, /api/random-images, tag_and_embed, ml.backfill enqueue, and
  get_suggestions all filter integrity_status IN ('ok', 'unknown') so
  flagged rows don't poison the gallery, ML, or suggestion math.
  'unknown' is treated as healthy so post-migration data stays visible
  until the sweep runs.

UI / report
- Settings -> Maintenance: 'Verify unknown' + 'Force re-verify all'
- GET /api/integrity/failed (paginated list of flagged rows)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 00:16:06 -04:00
bvandeusen 667a70acb9 fix(tags): case-insensitive kind prefix + (Fandom) suffix rescue on add
parse_kind_prefix now lowercases the prefix before checking KNOWN_KINDS,
matching the modal JS which already lowercases before its visibility
check. Without this, typing 'Character:Jinx ...' showed the fandom
picker but the server fell back to kind=user.

Both /tags/add and /api/images/bulk-add-tag now also split a trailing
'(Fandom)' suffix from a typed character name when no explicit fandom
is staged, so a manual entry like 'Character:Jinx (League Of Legends)'
produces a clean (name='Jinx', fandom_id=<league>) row instead of a
malformed character with the suffix baked into the name.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-25 14:23:43 -04:00
bvandeusen 478d01c5ff refactor(enrichment): post tag name omits post: prefix
The inner platform:artist:id identifier remains as opaque tag.name.
Kind column carries 'post'.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-22 15:50:45 -04:00
bvandeusen 6c767e2427 refactor(importer): archive tags drop kind prefix
Archive identifier string (artist:archive_name) stays as the tag's
opaque name — the archive kind lives in the kind column.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-22 15:45:47 -04:00
bvandeusen b9104f9caa feat(utils): add parse_kind_prefix helper
Owns the 'character:Saber' user-input shortcut parser in one place.
Invoked by add_tag, bulk_add_tag, and the migration's sanity check.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-22 09:36:20 -04:00
bvandeusen bc6b0a4a58 feat(ml): video tagging + embedding via frame sampling
Videos now route through a 10-frame sampling branch (configurable via
VIDEO_ML_FRAMES env) instead of the previous unsupported_format early
return. WD14 predictions are aggregated by max-confidence per (name,
category) across frames so sparse signals aren't diluted; SigLIP
embeddings are mean-pooled for a representative shot. Also generates a
fallback thumbnail when the record is missing one, and removes the
video_filter from backfill so videos get enqueued.

Celery soft/hard limits bumped to 240s/360s to accommodate 10x inference.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-20 18:39:33 -04:00
bvandeusen 0f35a0c484 feat: ML tag suggestions, character/fandom integrity, underscores, modal polish
Consolidated merge of feat/tag-suggestions branch. Original 64-commit history
was lost to git-object corruption in a Nextcloud-synced checkout; this single
commit captures the equivalent diff.

Includes:
- pgvector-backed tag suggestion infra (WD14 + SigLIP centroids, ml-worker
  container, Celery tasks, suggestion service, accept/reject endpoints + modal
  UI with green/red chip buttons)
- Character/fandom integrity: title-case normalization on every write path,
  fandom-id backfill, maintenance task + settings button, migrations g26041901
  + h26041901 to canonicalize legacy rows with case-only duplicate merging
- Tag-underscores + modal polish: WD14 name canonicalization at emit + accept
  + add/bulk-add paths, migration i26041901 for legacy-row rename-or-merge
  across character/fandom/NULL kinds, suggestion-accept refresh parity via
  awaited loadTags, persistent chip tint
2026-04-19 19:50:58 -04:00
bvandeusen c95896693f import filters for pixiv sidecars, tag filtering, and favicon generation 2026-02-04 19:08:50 -05:00
Bryan Van Deusen 3b5cd83b01 archive tag naming correction 2026-02-02 19:24:44 -05:00
Bryan Van Deusen 09883960d4 tuning job log views and deep scan archive processing. 2026-02-02 18:48:01 -05:00
Bryan Van Deusen d0fcde38e8 ui polish and importer logging tuning 2026-01-28 09:36:59 -05:00
Bryan Van Deusen 9ebeeed133 series management tuning and import archive extraction troubleshooting 2026-01-23 23:05:25 -05:00
Bryan Van Deusen a05aee5a07 implement post metadata import and views. implemented series paging and reader view. 2026-01-22 22:19:11 -05:00
Bryan Van Deusen 041a3dbfb4 fixed metadata time import error and moved quest status widget to top of settings. 2026-01-21 11:30:45 -05:00
Bryan Van Deusen fa9b89eca2 updates to transparency filtering, fixing mass tag edit autocomplete 2026-01-21 08:36:46 -05:00
Bryan Van Deusen 87bcb633f6 added transcoding to mp4 in import to ensure web playback. 2026-01-20 16:10:19 -05:00
Bryan Van Deusen cb3897c0b0 changes to mobile styling in modal view, complete reword of backend worker system 2026-01-20 13:14:13 -05:00
Bryan Van Deusen 96f72718bd moving styling and views to be more consistent and for gallery view to be less cumbersome. 2026-01-19 23:41:36 -05:00
Bryan Van Deusen b3331bad76 additional tag edditing functionality. and delete by tag. added import tuning options to settings 2026-01-18 16:52:32 -05:00
Bryan Van Deusen a77724dccc fixed pagination issues and thumbnail generation issues 2025-08-16 10:25:16 -04:00
Bryan Van Deusen 3ff34ec9c2 switched to tagging and added views to support it, in progress for other tagging functions. 2025-08-14 21:36:27 -04:00
Bryan Van Deusen e9793ba38c polish on archive import processing 2025-08-14 16:19:16 -04:00
Bryan Van Deusen c480a176c2 added video import and playback functionality 2025-08-03 20:42:49 -04:00
Bryan Van Deusen 3c3bfed75f tuning import process and db handling 2025-08-03 15:16:02 -04:00
Bryan Van Deusen 0dc944ef25 page load optimization and pagination changes 2025-08-03 11:40:32 -04:00
Bryan Van Deusen 63918363c1 improved Modal with zoom and pagination. also implementing thumbnail generation 2025-08-01 23:19:17 -04:00
Bryan Van Deusen e3a4c348f1 major styling pass, artist list, and import processing improvements 2025-07-31 23:48:37 -04:00
Bryan Van Deusen c67f1afc1f initial functionality and styling pass 2025-07-29 00:34:03 -04:00