Spaces:
Sleeping
Sleeping
im2
commited on
Commit
•
a8024f1
1
Parent(s):
56fd351
image error fixed
Browse files
app.py
CHANGED
@@ -32,12 +32,9 @@ model.load_state_dict(torch.hub.load_state_dict_from_url(model_path))
|
|
32 |
model.eval()
|
33 |
|
34 |
# Gradio preprocessing and prediction pipeline
|
35 |
-
def predict_digit(
|
36 |
-
#
|
37 |
-
image =
|
38 |
-
|
39 |
-
# Convert the image to a numpy array, then to a PIL image, and preprocess
|
40 |
-
image = Image.fromarray(np.array(image)).convert('L') # Convert to grayscale
|
41 |
|
42 |
# Preprocess: resize to 28x28 and normalize
|
43 |
transform = transforms.Compose([
|
@@ -66,4 +63,5 @@ interface = gr.Interface(
|
|
66 |
|
67 |
# Launch the app
|
68 |
if __name__ == "__main__":
|
69 |
-
interface.launch(
|
|
|
|
32 |
model.eval()
|
33 |
|
34 |
# Gradio preprocessing and prediction pipeline
|
35 |
+
def predict_digit(image):
|
36 |
+
# Convert the numpy array (from gr.Sketchpad) to a PIL Image
|
37 |
+
image = Image.fromarray(image).convert('L') # Convert to grayscale
|
|
|
|
|
|
|
38 |
|
39 |
# Preprocess: resize to 28x28 and normalize
|
40 |
transform = transforms.Compose([
|
|
|
63 |
|
64 |
# Launch the app
|
65 |
if __name__ == "__main__":
|
66 |
+
interface.launch()
|
67 |
+
|