feat: Add hybrid quality evaluation system with CLIP and VLM support
- Add FeatureExtractor for CLIP-based image/text feature extraction - Add ObjectiveMetricsCalculator for technical quality metrics - Add VLMEvaluator for vision language model evaluation - Add HybridQualityGate combining objective + VLM evaluation - Enhance CharacterMemory with visual feature support - Add quality optional dependency (torch, ftfy, regex) - Add unit tests for new modules 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
53
tests/test_hybrid_quality_gate.py
Normal file
53
tests/test_hybrid_quality_gate.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# Copyright (C) 2025 AIDC-AI
|
||||
# Tests for HybridQualityGate
|
||||
|
||||
import pytest
|
||||
|
||||
from pixelle_video.services.quality.quality_gate import (
|
||||
QualityGate,
|
||||
HybridQualityGate,
|
||||
HybridQualityConfig,
|
||||
)
|
||||
from pixelle_video.services.quality.models import QualityScore
|
||||
|
||||
|
||||
class TestHybridQualityConfig:
|
||||
"""Tests for HybridQualityConfig"""
|
||||
|
||||
def test_default_values(self):
|
||||
config = HybridQualityConfig()
|
||||
assert config.enable_clip_score is True
|
||||
assert config.enable_smart_skip is True
|
||||
assert config.smart_skip_threshold == 0.75
|
||||
|
||||
def test_inherits_quality_config(self):
|
||||
config = HybridQualityConfig()
|
||||
assert hasattr(config, "overall_threshold")
|
||||
assert config.overall_threshold == 0.6
|
||||
|
||||
|
||||
class TestHybridQualityGate:
|
||||
"""Tests for HybridQualityGate"""
|
||||
|
||||
def test_init_default(self):
|
||||
gate = HybridQualityGate()
|
||||
assert gate.hybrid_config is not None
|
||||
|
||||
def test_inherits_quality_gate(self):
|
||||
gate = HybridQualityGate()
|
||||
assert isinstance(gate, QualityGate)
|
||||
|
||||
def test_lazy_load_metrics_calculator(self):
|
||||
gate = HybridQualityGate()
|
||||
calc = gate.metrics_calculator
|
||||
assert calc is not None
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_evaluate_nonexistent_image(self):
|
||||
gate = HybridQualityGate()
|
||||
score = await gate.evaluate_image(
|
||||
"/nonexistent/path.png",
|
||||
"test prompt"
|
||||
)
|
||||
assert score.passed is False
|
||||
assert "not found" in score.issues[0].lower()
|
||||
Reference in New Issue
Block a user