12ed183f1b
- Remove legacy distance-mode scanning (build_profile, _similarity, etc.) and hand-crafted intensity features — pipeline is now embedding-only - Integrate Microsoft BEATs as embedding option alongside wav2vec2/HuBERT - Add TrainDialog with positive class selector, model picker, video dir fallback, and live training stats - Add TrainWorker QThread with cancel support and proper lifecycle cleanup - Add source_path column to DB for robust source video tracking - Add get_export_folders/get_training_data/get_training_stats to DB - Wire source_path in all export DB writes (_on_clip_done, _on_auto_clip_done) - Cancel scan/train workers in closeEvent to prevent use-after-free crashes - Add setup_env.sh supporting both conda and python venv (CUDA 12.8) - Update requirements.txt with all actual dependencies - Update 8cut_train.py with --positive flag for new DB-driven training Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
import tempfile, os
|
|
import numpy as np
|
|
from core.audio_scan import scan_video, load_classifier, default_model_path
|
|
|
|
|
|
def test_scan_video_no_model_returns_empty():
|
|
"""scan_video with no model should return empty list."""
|
|
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as vid:
|
|
import soundfile as sf
|
|
sf.write(vid.name, np.random.randn(16000 * 20).astype(np.float32) * 0.1, 16000)
|
|
try:
|
|
regions = scan_video(vid.name, model=None)
|
|
assert regions == []
|
|
finally:
|
|
os.unlink(vid.name)
|
|
|
|
|
|
def test_load_classifier_missing_returns_none():
|
|
assert load_classifier("/no/such/model.joblib") is None
|
|
|
|
|
|
def test_default_model_path_contains_profile():
|
|
path = default_model_path("test_profile")
|
|
assert "test_profile" in path
|
|
assert path.endswith(".joblib")
|
|
|
|
|
|
def test_db_get_all_export_paths():
|
|
with tempfile.NamedTemporaryFile(suffix=".db", delete=False) as f:
|
|
path = f.name
|
|
try:
|
|
from core.db import ProcessedDB
|
|
db = ProcessedDB(path)
|
|
db.add("a.mp4", 10.0, "/out/a_001.mp4", profile="test")
|
|
db.add("b.mp4", 20.0, "/out/b_001.mp4", profile="test")
|
|
db.add("c.mp4", 30.0, "/out/c_001.mp4", profile="other")
|
|
paths = db.get_all_export_paths("test")
|
|
assert set(paths) == {"/out/a_001.mp4", "/out/b_001.mp4"}
|
|
finally:
|
|
os.unlink(path)
|