22c3b54746
The eval (#1130) proved the frozen-embedding + trained-head spine; this lands its production form (the first of three slices that make heads the suggestion source, replacing Camie + centroid). - tag_head: one logistic-regression head per general/character concept with enough labelled positives. Weights (pgvector), honest CV-derived suggest threshold + earned-auto-apply point, and per-concept quality metrics. - head_training_run: persisted batch lifecycle (mirrors tag_eval_run) so the admin card shows live + historical status across navigation. - services/ml/heads.py: TRAIN (sync, ml worker, reuses tag_eval's proven data loaders + metric math so production heads match measured eval numbers) and SCORE (async, API worker — numpy via pgvector, no scikit-learn): score one image's embedding against all heads → the rail's suggestions, cached on (count, max trained_at) so a retrain invalidates without per-request loads. - tasks.ml.train_heads (ml queue, commits per head so a kill leaves progress) + recover_stalled_head_training_runs sweep + retention(20) + 5-min beat (rule 89). - api/heads.py: POST /api/heads/train (one run at a time, 409 guard) + GET /api/heads (count, graduated, last-trained, running, per-concept table, recent runs). - ml_settings: head_min_positives + head_auto_apply_precision, tunable via /api/ml/settings. Scoring isn't wired into the rail yet (slice C) and the admin UI is slice B — this slice makes training + scoring exist and CI-verifiable. 'precision' column stored as precision_cv (SQL reserved word). Migration 0058. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ttrj5P7upUTueSfoJcxEqa
80 lines
2.3 KiB
Python
80 lines
2.3 KiB
Python
"""All ORM models. Import this module to make every model visible to Alembic."""
|
|
|
|
from .app_setting import AppSetting
|
|
from .artist import Artist
|
|
from .artist_visit import ArtistVisit
|
|
from .backup_run import BackupRun
|
|
from .base import Base
|
|
from .credential import Credential
|
|
from .download_event import DownloadEvent
|
|
from .external_link import ExternalLink
|
|
from .image_prediction import ImagePrediction
|
|
from .image_provenance import ImageProvenance
|
|
from .image_record import ImageRecord
|
|
from .import_batch import ImportBatch
|
|
from .import_settings import ImportSettings
|
|
from .import_task import ImportTask
|
|
from .library_audit_run import LibraryAuditRun
|
|
from .ml_settings import MLSettings
|
|
from .patreon_failed_media import PatreonFailedMedia
|
|
from .patreon_seen_media import PatreonSeenMedia
|
|
from .post import Post
|
|
from .post_attachment import PostAttachment
|
|
from .series_chapter import SeriesChapter
|
|
from .series_page import SeriesPage
|
|
from .series_suggestion import SeriesSuggestion
|
|
from .source import Source
|
|
from .subscribestar_failed_media import SubscribeStarFailedMedia
|
|
from .subscribestar_seen_media import SubscribeStarSeenMedia
|
|
from .head_training_run import HeadTrainingRun
|
|
from .tag import Tag, TagKind, image_tag
|
|
from .tag_alias import TagAlias
|
|
from .tag_allowlist import TagAllowlist
|
|
from .tag_eval_run import TagEvalRun
|
|
from .tag_head import TagHead
|
|
from .tag_positive_confirmation import TagPositiveConfirmation
|
|
from .tag_reference_embedding import TagReferenceEmbedding
|
|
from .tag_suggestion_rejection import TagSuggestionRejection
|
|
from .task_run import TaskRun
|
|
|
|
__all__ = [
|
|
"Base",
|
|
"AppSetting",
|
|
"Artist",
|
|
"ArtistVisit",
|
|
"BackupRun",
|
|
"Source",
|
|
"Credential",
|
|
"PatreonFailedMedia",
|
|
"PatreonSeenMedia",
|
|
"SubscribeStarFailedMedia",
|
|
"SubscribeStarSeenMedia",
|
|
"Post",
|
|
"PostAttachment",
|
|
"SeriesChapter",
|
|
"SeriesPage",
|
|
"SeriesSuggestion",
|
|
"ImageRecord",
|
|
"ImagePrediction",
|
|
"ImageProvenance",
|
|
"Tag",
|
|
"TagKind",
|
|
"image_tag",
|
|
"DownloadEvent",
|
|
"ExternalLink",
|
|
"ImportBatch",
|
|
"ImportTask",
|
|
"ImportSettings",
|
|
"LibraryAuditRun",
|
|
"MLSettings",
|
|
"HeadTrainingRun",
|
|
"TagAlias",
|
|
"TagAllowlist",
|
|
"TagEvalRun",
|
|
"TagHead",
|
|
"TagPositiveConfirmation",
|
|
"TagReferenceEmbedding",
|
|
"TagSuggestionRejection",
|
|
"TaskRun",
|
|
]
|