作者一周微调 EVA-02 开源神经视频检索引擎
I fine-tuned EVA-02 in a week to build a neural video retrieval engine for what CLIP still won't do [P]
作者用一周时间微调 EVA-02-CLIP-L-14-336,开源了一个本地视频检索引擎,可按姿态、服装细节、机位和运动节奏检索视频,并在 8 GB RTX 4060 笔记本上以 4.5 GB 显存完成训练。
TL;DR: After a manic 7-day sprint, I open-sourced a local video retrieval engine built to search massive unstructured video portals by visual poses, clothing details, camera angles, and motion cadence—ignoring uploader metadata at search time and running in minimal VRAM.
Why Existing Models and Search Fail
- Scrubbed foundation weights: Stock CLIP, BLIP, and SigLIP still have massive blind spots for specific body postures, unconventional clothing styles, and unfiltered visual concepts.
- Fragile fixed classifiers: My earlier ensemble of JoyTag, P-HAR, and FashionCLIP choked on blurry, compressed footage and rigid taxonomies where "thighhighs" misses "over-the-knee socks" or "from behind" misses "rear view."
- Broken platform search: Uploaders stuff 50 generic SEO tags per video, and single-thumbnail indexing completely misses a pose or outfit that only appears for 20 seconds in a 25-minute clip.
Data Pipeline and Storage
- Graph crawling: A 48-thread breadth-first crawler traverses recommendation graphs, filtering candidates via regex for specific attire (stockings, miniskirt, maid uniform, apron, heels) and poses (kneeling, bent over, squatting, POV).
- Mosaic compression: Instead of hoarding terabytes of raw video, each clip is stored as a 3x3 contact-sheet mosaic of 9 chronological keyframes, with 141k remaining archive tarballs (12 GB) offloaded to Colab G4 instances.
- Dynamic captioning: A sanitizer strips URLs, studio watermarks, punctuation spam, and resolution clutter, while training regenerates captions every epoch by rotating synonyms, shuffling clauses, and dropping random tags.
Training Architecture and Dataset Fixes
- Frozen spatial trunk: Freezing the EVA-02-CLIP-L-14-336 vision backbone (304M parameters, 336x336 input, 576 spatial patches) fits training inside 4.5 GB VRAM on an 8 GB RTX 4060 laptop while updating the text tower and projection head.
- Multi-instance routing: Rather than averaging a video into one blurry vector, training pulls a random bag of mosaic frames, scores each against the caption, and routes gradients through the single best-matching frame.
- Soft negative floor: Parallel SigLIP runs swap softmax for pairwise sigmoid loss and use a frozen text encoder copy to detect near-duplicate batch titles, softening their negative penalty down to a 25% floor.
- Long-tail balancing: Tag counts skew 9,000x from head terms (15,000 to 45,000+ hits, ~16k for POV, 4k–5k+ for common outfits) to rare tails (apron at ~130, standing split at 15, lotus at 5), solved via square-root inverse-frequency sampling.
- Preventing domain collapse: Mixing a curated 4,652-image Danbooru2023 anchor set symmetrically into live-action batches keeps 2D illustration features intact alongside real-world footage.
Benchmarks and Qualitative Results
- Dataset scale: Trained across 147,412 curated videos (1.32 million keyframes) and currently scaling past 288,000 clips, dropping validation loss from 1.428 to 1.054.
- Held-out retrieval: Recall@1 jumped from 12.4% to 20.67% across held-out validation splits, reaching 28.0% Recall@1 and 60.0% Recall@5 on curated splits.
- Cross-domain and multi-tile gains: Cross-domain Recall@1 rose from 18.09% zero-shot to 55.28%, and evaluating every mosaic tile instead of only the center thumbnail gives a +39% Recall@1 boost on its own.
- Fine-grained visual search: The web viewer (with drag-and-drop and Ctrl+V screenshot search) cleanly separates matte leather vs. glossy latex skirts, shower vs. bathtub vs. toilet scenes, and exact lingerie colors buried dozens of pages deep.
Hardware Bottlenecks and Inference Speed
- Two-stage local search: Keeping all normalized half-precision keyframe vectors in 2 GB VRAM scans the full index in ~8.9 ms, before Stage II unpacks spatial patches for localized reranking and runs live optical flow BPM on a 4x3 grid on hover.
- JPEG decode bottleneck: Python PIL spent 32 ms per image decoding JPEGs on CPU and starved the GPU at 18% utilization; rewriting the loader around C++ libjpeg-turbo dropped decode time to 2.1 ms.
- Ada Lovelace FP8 trap: cuBLASLt refused FP8 matrix multiplies on dimensions not divisible by 16, and padding the 577 tokens and 2,730 MLP width erased any speedup over native FP16 FlashAttention.
Still plenty left to tighten up around noisy edge tags and finishing the remaining mosaics on disk, but I'm happy to answer questions about the MIL contrastive setup, label skew, domain collapse, optical flow cadence estimation, or PyTorch/CUDA quirks!
submitted by /u/qn06142
[link] [留言]
来源:r/MachineLearning · reddit.com