diff --git a/frontend/src/components/editor/QualityBadge.css b/frontend/src/components/editor/QualityBadge.css new file mode 100644 index 00000000..bb5e2744 --- /dev/null +++ b/frontend/src/components/editor/QualityBadge.css @@ -0,0 +1,16 @@ +.quality-score-badge { + display: inline-block; + padding: 4px 8px; + border-radius: 4px; + font-size: 11px; + font-weight: 600; + color: white; +} + +.quality-score-badge.high { + background: #10b981; +} + +.quality-score-badge.medium { + background: #f59e0b; +} diff --git a/frontend/src/components/editor/QualityBadge.jsx b/frontend/src/components/editor/QualityBadge.jsx new file mode 100644 index 00000000..b906ae74 --- /dev/null +++ b/frontend/src/components/editor/QualityBadge.jsx @@ -0,0 +1,12 @@ +import React from 'react'; +import './QualityBadge.css'; + +export default function QualityBadge({ score }) { + if (score === undefined || score === null) return null; + + return ( +
80 ? 'high' : 'medium'}`}> + Matting Score: {score}% +
+ ); +} diff --git a/python-ai-service/app/services/matting_quality_evaluator.py b/python-ai-service/app/services/matting_quality_evaluator.py new file mode 100644 index 00000000..2f13e819 --- /dev/null +++ b/python-ai-service/app/services/matting_quality_evaluator.py @@ -0,0 +1,15 @@ +""" +matting_quality_evaluator.py — AI Background Matting Quality Metrics Evaluator +Built for ELUSoC 2026 / GSSOC 2026. +""" +import numpy as np + +def evaluate_alpha_matting_quality(alpha_channel: np.ndarray) -> float: + if alpha_channel is None or alpha_channel.size == 0: + return 0.0 + + # Calculate boundary smoothness and edge sharpness + gradient_magnitude = np.abs(np.gradient(alpha_channel.astype(float))) + mean_gradient = float(np.mean(gradient_magnitude)) + quality_score = min(100.0, max(0.0, (1.0 - mean_gradient / 255.0) * 100.0)) + return round(quality_score, 2) diff --git a/python-ai-service/app/services/test_matting_quality.py b/python-ai-service/app/services/test_matting_quality.py new file mode 100644 index 00000000..f353e8e4 --- /dev/null +++ b/python-ai-service/app/services/test_matting_quality.py @@ -0,0 +1,11 @@ +""" +test_matting_quality.py — Matting Quality Evaluator Tests +Built for ELUSoC 2026 / GSSOC 2026. +""" +import numpy as np +from app.services.matting_quality_evaluator import evaluate_alpha_matting_quality + +def test_alpha_matting_quality(): + mock_alpha = np.ones((100, 100), dtype=np.uint8) * 255 + score = evaluate_alpha_matting_quality(mock_alpha) + assert score >= 90.0