Update app.py
Browse files
app.py
CHANGED
@@ -100,11 +100,12 @@ canvas_result = st_canvas(
|
|
100 |
# Do something interesting with the image data and paths
|
101 |
if canvas_result.image_data is not None:
|
102 |
#st.image(canvas_result.image_data)
|
103 |
-
image = canvas_result.image_data
|
104 |
image1 = image.copy()
|
105 |
-
image1 = image1.astype('
|
106 |
-
image1 = cv2.cvtColor(image1,cv2.COLOR_BGR2GRAY)
|
107 |
-
image1 = cv2.resize(image1,(28,28))
|
|
|
|
|
108 |
st.image(image1)
|
109 |
image1.resize(1,1,28,28)
|
110 |
st.title(np.argmax(cnn.predict(image1)))
|
|
|
100 |
# Do something interesting with the image data and paths
|
101 |
if canvas_result.image_data is not None:
|
102 |
#st.image(canvas_result.image_data)
|
|
|
103 |
image1 = image.copy()
|
104 |
+
image1 = image1.astype('float32') # Convert to float32
|
105 |
+
image1 = cv2.cvtColor(image1, cv2.COLOR_BGR2GRAY)
|
106 |
+
image1 = cv2.resize(image1, (28, 28))
|
107 |
+
image1 = image1 / 255.0 # Normalize the values to [0, 1]
|
108 |
+
|
109 |
st.image(image1)
|
110 |
image1.resize(1,1,28,28)
|
111 |
st.title(np.argmax(cnn.predict(image1)))
|