Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
| 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 |
|