Jeet Paul commited on
Commit
3b528ea
·
1 Parent(s): 654fe6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -37,9 +37,11 @@ def predict_digit(input_data):
37
  params = np.load("trained_params.npz", allow_pickle=True)
38
  W1, b1, W2, b2 = params["W1"], params["b1"], params["W2"], params["b2"]
39
 
40
-
41
- # Reshape the input data to match the neural network architecture
42
- X = input_data.reshape((784, 1)) / 255.
 
 
43
 
44
  # Get the prediction
45
  prediction = make_predictions(X, W1, b1, W2, b2)
 
37
  params = np.load("trained_params.npz", allow_pickle=True)
38
  W1, b1, W2, b2 = params["W1"], params["b1"], params["W2"], params["b2"]
39
 
40
+ # Convert the uploaded image to grayscale and resize it to (28, 28)
41
+ img = Image.fromarray(input_data).convert("L").resize((28, 28))
42
+
43
+ # Convert the image to a NumPy array and normalize it
44
+ X = np.array(img).reshape((784, 1)) / 255.
45
 
46
  # Get the prediction
47
  prediction = make_predictions(X, W1, b1, W2, b2)