EngReem85 commited on
Commit
e747d46
·
verified ·
1 Parent(s): e288244

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -84,7 +84,10 @@ def preprocess_image(img: Image.Image):
84
  img_np = ensure_rgb(np.array(img))
85
  img_resized = cv2.resize(img_np, (IMG_SIZE, IMG_SIZE))
86
  img_norm = img_resized.astype(np.float32) / 255.0
87
- img_norm = (img_norm - 0.5) / 0.5
 
 
 
88
  tensor = torch.from_numpy(img_norm).permute(2, 0, 1).unsqueeze(0)
89
  return tensor.to(DEVICE), img_np
90
 
 
84
  img_np = ensure_rgb(np.array(img))
85
  img_resized = cv2.resize(img_np, (IMG_SIZE, IMG_SIZE))
86
  img_norm = img_resized.astype(np.float32) / 255.0
87
+ mean = np.array([0.485, 0.456, 0.406])
88
+ std = np.array([0.229, 0.224, 0.225])
89
+ img_norm = (img_norm - mean) / std
90
+
91
  tensor = torch.from_numpy(img_norm).permute(2, 0, 1).unsqueeze(0)
92
  return tensor.to(DEVICE), img_np
93