Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -432,11 +432,18 @@ class ForgeryDetector:
|
|
| 432 |
|
| 433 |
region_mask = region_mask.astype(bool)
|
| 434 |
|
| 435 |
-
# Extract features using
|
| 436 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 437 |
features = self.feature_extractor.extract(
|
| 438 |
-
|
| 439 |
-
|
| 440 |
[f.cpu() for f in decoder_features]
|
| 441 |
)
|
| 442 |
|
|
|
|
| 432 |
|
| 433 |
region_mask = region_mask.astype(bool)
|
| 434 |
|
| 435 |
+
# Extract features using PREPROCESSED image (matches training)
|
| 436 |
+
# Resize region_mask to match preprocessed dimensions (384x384)
|
| 437 |
+
preprocessed_h, preprocessed_w = preprocessed.shape[:2]
|
| 438 |
+
region_mask_for_features = cv2.resize(
|
| 439 |
+
region['region_mask'].astype(np.uint8),
|
| 440 |
+
(preprocessed_w, preprocessed_h),
|
| 441 |
+
interpolation=cv2.INTER_NEAREST
|
| 442 |
+
)
|
| 443 |
+
|
| 444 |
features = self.feature_extractor.extract(
|
| 445 |
+
preprocessed,
|
| 446 |
+
region_mask_for_features,
|
| 447 |
[f.cpu() for f in decoder_features]
|
| 448 |
)
|
| 449 |
|