JKrishnanandhaa commited on
Commit
7f3d8d4
·
verified ·
1 Parent(s): e4771d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
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: (92, 184, 92), # #5cb85c - Muted green
34
- 2: (65, 105, 225) # #4169E1 - Royal blue
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=450,
155
  margin=dict(l=60, r=180, t=40, b=40)
156
  )
157
 
@@ -432,10 +432,13 @@ 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
  )
 
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 (Copy-Move)
33
+ 1: (65, 105, 225), # #4169E1 - Royal blue (Splicing)
34
+ 2: (92, 184, 92) # #5cb85c - Muted green (Text Substitution)
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=300, # Reduced from 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 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
+ # Pass region_mask directly - feature extractor handles resizing internally
440
  features = self.feature_extractor.extract(
441
+ preprocessed_numpy,
442
  region['region_mask'],
443
  [f.cpu() for f in decoder_features]
444
  )