485387ff0b
Heads + CCIP are the tag source and head auto-apply is the earned propagation.
The Camie tagger ran only to feed the allowlist bulk-apply (its ImagePrediction
rows had no other consumer), and the allowlist was a SECOND, un-earned auto-apply
path firing in parallel with heads on every accept — exactly the un-earned spray
the v2 pivot replaced. Retire both.
Behavior change: accepting a suggestion now applies the tag to THAT image only
(source='ml_accepted', a head-training positive) — it no longer allowlists +
fans the tag across the library via Camie. Propagation is heads' earned
auto-apply. (Loses instant cold-start propagation for booru-vocab tags; that was
un-earned and bypassed the precision gate.)
- tag_and_embed is now EMBED-ONLY (no Camie load/infer, no ImagePrediction
writes); backfill enqueues it for images with no embedding.
- Removed: services/ml/tagger.py, apply_allowlist_tags + helpers + daily beat +
every enqueue caller (accept/alias/merge/per-image), api/allowlist.py +
blueprint, ImagePrediction + TagAllowlist models/tables (migration 0067),
AllowlistTable.vue + allowlist store, the accept coverage-projection payload.
- AllowlistService gutted to accept/dismiss/undismiss/reject (the rejection store
the rail still needs); accept returns nothing, API returns {accepted, tag_id}.
- tag merge no longer repoints/triggers the allowlist; _keep_as_alias now keys on
ML-applied image_tag sources (incl. head_auto) instead of the allowlist.
- UI: MLBackfillCard relabelled to embedding-only; accept toast simplified;
MaintenancePanel drops the allowlist tile.
Left for a follow-up hygiene pass (now-inert, harmless): the dead settings
columns (tagger_store_floor, tagger_model_version, suggestion_threshold_*,
video_min_tag_frames), image_record.tagger_model_version, MLThresholdSliders
trim, and the Camie model download in download_models.py.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ttrj5P7upUTueSfoJcxEqa
79 lines
3.1 KiB
Python
79 lines
3.1 KiB
Python
"""Suggestion actions: accept applies the canonical tag to an image (which
|
|
feeds head training); dismiss / reject record a per-image rejection.
|
|
|
|
(The Camie allowlist bulk-apply was retired #1189 — heads + CCIP are the tag
|
|
source, and head auto-apply is the earned propagation. Accept no longer
|
|
allowlists or fans a tag out across the library.)
|
|
"""
|
|
|
|
from sqlalchemy import delete
|
|
from sqlalchemy.dialects.postgresql import insert
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from ...models import TagSuggestionRejection
|
|
from ...models.tag import image_tag
|
|
from .aliases import AliasService
|
|
|
|
|
|
class AllowlistService:
|
|
def __init__(self, session: AsyncSession):
|
|
self.session = session
|
|
self.aliases = AliasService(session)
|
|
|
|
async def _apply_image_tag(self, image_id: int, tag_id: int, source: str):
|
|
stmt = insert(image_tag).values(
|
|
image_record_id=image_id, tag_id=tag_id, source=source
|
|
).on_conflict_do_nothing(
|
|
index_elements=["image_record_id", "tag_id"]
|
|
)
|
|
await self.session.execute(stmt)
|
|
|
|
async def _clear_rejection(self, image_id: int, tag_id: int):
|
|
await self.session.execute(
|
|
delete(TagSuggestionRejection)
|
|
.where(TagSuggestionRejection.image_record_id == image_id)
|
|
.where(TagSuggestionRejection.tag_id == tag_id)
|
|
)
|
|
|
|
async def accept(self, image_id: int, tag_id: int) -> None:
|
|
"""Apply the accepted tag to this image (source='ml_accepted', a head
|
|
training positive) and clear any prior rejection."""
|
|
await self._apply_image_tag(image_id, tag_id, source="ml_accepted")
|
|
await self._clear_rejection(image_id, tag_id)
|
|
|
|
async def add_alias_and_accept(
|
|
self,
|
|
image_id: int,
|
|
alias_string: str,
|
|
alias_category: str,
|
|
canonical_tag_id: int,
|
|
) -> None:
|
|
await self.aliases.create(
|
|
alias_string, alias_category, canonical_tag_id
|
|
)
|
|
await self.accept(image_id, canonical_tag_id)
|
|
|
|
async def dismiss(self, image_id: int, tag_id: int) -> None:
|
|
stmt = insert(TagSuggestionRejection).values(
|
|
image_record_id=image_id, tag_id=tag_id
|
|
).on_conflict_do_nothing(
|
|
index_elements=["image_record_id", "tag_id"]
|
|
)
|
|
await self.session.execute(stmt)
|
|
|
|
async def undismiss(self, image_id: int, tag_id: int) -> None:
|
|
"""Undo a per-image dismissal — drop the TagSuggestionRejection so the
|
|
suggestion reverts to a live (un-rejected) state. Backs the rail's
|
|
one-click reject-recovery (operator-asked 2026-06-27)."""
|
|
await self._clear_rejection(image_id, tag_id)
|
|
|
|
async def reject_applied_tag(self, image_id: int, tag_id: int) -> None:
|
|
"""Operator removed an applied tag from an image. Remove the image_tag
|
|
row AND record a rejection so head auto-apply won't re-apply it."""
|
|
await self.session.execute(
|
|
image_tag.delete()
|
|
.where(image_tag.c.image_record_id == image_id)
|
|
.where(image_tag.c.tag_id == tag_id)
|
|
)
|
|
await self.dismiss(image_id, tag_id)
|