Spaces:
Sleeping
Sleeping
bhaveshgoel07
commited on
Commit
•
504f5bf
1
Parent(s):
c4d114a
Fixed errors
Browse files
app.py
CHANGED
@@ -44,10 +44,10 @@ def predict(image):
|
|
44 |
try:
|
45 |
# The input image is already a 2D numpy array (grayscale)
|
46 |
# Ensure it's the right size and normalize it
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
# Convert to tensor and add batch and channel dimensions
|
53 |
tensor_image = torch.tensor(image, dtype=torch.float32).unsqueeze(0).unsqueeze(0)
|
|
|
44 |
try:
|
45 |
# The input image is already a 2D numpy array (grayscale)
|
46 |
# Ensure it's the right size and normalize it
|
47 |
+
|
48 |
+
pil_image = Image.fromarray(image.squeeze().astype('uint8'))
|
49 |
+
pil_image = pil_image.resize((28, 28))
|
50 |
+
image = np.array(pil_image)
|
51 |
|
52 |
# Convert to tensor and add batch and channel dimensions
|
53 |
tensor_image = torch.tensor(image, dtype=torch.float32).unsqueeze(0).unsqueeze(0)
|