JKrishnanandhaa commited on
Commit
ac23557
·
verified ·
1 Parent(s): 04ddd6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -432,17 +432,20 @@ class ForgeryDetector:
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
  )
 
432
 
433
  region_mask = region_mask.astype(bool)
434
 
435
+ # Extract features using tensor converted to numpy (matches training pipeline)
436
+ # Convert tensor back to numpy: (C, H, W) -> (H, W, C)
437
+ preprocessed_numpy = image_tensor[0].permute(1, 2, 0).cpu().numpy()
438
+
439
+ # Resize region_mask to match tensor dimensions
440
+ tensor_h, tensor_w = preprocessed_numpy.shape[:2]
441
  region_mask_for_features = cv2.resize(
442
  region['region_mask'].astype(np.uint8),
443
+ (tensor_w, tensor_h),
444
  interpolation=cv2.INTER_NEAREST
445
  )
446
 
447
  features = self.feature_extractor.extract(
448
+ preprocessed_numpy,
449
  region_mask_for_features,
450
  [f.cpu() for f in decoder_features]
451
  )