Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions frontend/src/components/editor/QualityBadge.css
Original file line number Diff line number Diff line change
@@ -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;
}
12 changes: 12 additions & 0 deletions frontend/src/components/editor/QualityBadge.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import './QualityBadge.css';

export default function QualityBadge({ score }) {
if (score === undefined || score === null) return null;

return (
<div className={`quality-score-badge ${score > 80 ? 'high' : 'medium'}`}>
Matting Score: {score}%
</div>
);
}
15 changes: 15 additions & 0 deletions python-ai-service/app/services/matting_quality_evaluator.py
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 11 additions & 0 deletions python-ai-service/app/services/test_matting_quality.py
Original file line number Diff line number Diff line change
@@ -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