JKrishnanandhaa commited on
Commit
1b696e4
·
verified ·
1 Parent(s): 9dc80fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -432,11 +432,18 @@ class ForgeryDetector:
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
  )
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