Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,9 +29,9 @@ from src.training.classifier import ForgeryClassifier
|
|
| 29 |
# Class names
|
| 30 |
CLASS_NAMES = {0: 'Copy-Move', 1: 'Splicing', 2: 'Text Substitution'}
|
| 31 |
CLASS_COLORS = {
|
| 32 |
-
0: (217, 83, 79), # #d9534f - Muted red
|
| 33 |
-
1: (
|
| 34 |
-
2: (
|
| 35 |
}
|
| 36 |
|
| 37 |
# Actual model performance metrics
|
|
@@ -151,7 +151,7 @@ def create_detection_metrics_gauge(avg_confidence: float, iou: float, precision:
|
|
| 151 |
),
|
| 152 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 153 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 154 |
-
height=
|
| 155 |
margin=dict(l=60, r=180, t=40, b=40)
|
| 156 |
)
|
| 157 |
|
|
@@ -432,13 +432,10 @@ class ForgeryDetector:
|
|
| 432 |
|
| 433 |
region_mask = region_mask.astype(bool)
|
| 434 |
|
| 435 |
-
# Extract features using
|
| 436 |
-
#
|
| 437 |
-
preprocessed_numpy = image_tensor[0].permute(1, 2, 0).cpu().numpy()
|
| 438 |
-
|
| 439 |
-
# Pass region_mask directly - feature extractor handles resizing internally
|
| 440 |
features = self.feature_extractor.extract(
|
| 441 |
-
|
| 442 |
region['region_mask'],
|
| 443 |
[f.cpu() for f in decoder_features]
|
| 444 |
)
|
|
|
|
| 29 |
# Class names
|
| 30 |
CLASS_NAMES = {0: 'Copy-Move', 1: 'Splicing', 2: 'Text Substitution'}
|
| 31 |
CLASS_COLORS = {
|
| 32 |
+
0: (217, 83, 79), # #d9534f - Muted red
|
| 33 |
+
1: (92, 184, 92), # #5cb85c - Muted green
|
| 34 |
+
2: (65, 105, 225) # #4169E1 - Royal blue
|
| 35 |
}
|
| 36 |
|
| 37 |
# Actual model performance metrics
|
|
|
|
| 151 |
),
|
| 152 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 153 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 154 |
+
height=450,
|
| 155 |
margin=dict(l=60, r=180, t=40, b=40)
|
| 156 |
)
|
| 157 |
|
|
|
|
| 432 |
|
| 433 |
region_mask = region_mask.astype(bool)
|
| 434 |
|
| 435 |
+
# Extract features using ORIGINAL image (not preprocessed)
|
| 436 |
+
# This matches how the classifier was trained
|
|
|
|
|
|
|
|
|
|
| 437 |
features = self.feature_extractor.extract(
|
| 438 |
+
original_image / 255.0, # Normalize to [0, 1]
|
| 439 |
region['region_mask'],
|
| 440 |
[f.cpu() for f in decoder_features]
|
| 441 |
)
|