Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,10 @@ class Net(nn.Module):
|
|
21 |
|
22 |
# Load the trained model
|
23 |
model = Net()
|
24 |
-
|
|
|
|
|
|
|
25 |
model.eval()
|
26 |
|
27 |
# Define the transform to preprocess the input image
|
@@ -51,4 +54,3 @@ iface = gr.Interface(
|
|
51 |
# Launch the Gradio interface
|
52 |
if __name__ == "__main__":
|
53 |
iface.launch()
|
54 |
-
|
|
|
21 |
|
22 |
# Load the trained model
|
23 |
model = Net()
|
24 |
+
try:
|
25 |
+
model.load_state_dict(torch.load('mnist_model.pth', map_location=torch.device('cpu')))
|
26 |
+
except Exception as e:
|
27 |
+
print(f"Error loading model: {e}")
|
28 |
model.eval()
|
29 |
|
30 |
# Define the transform to preprocess the input image
|
|
|
54 |
# Launch the Gradio interface
|
55 |
if __name__ == "__main__":
|
56 |
iface.launch()
|
|