Mpavan45 commited on
Commit
4963c13
·
verified ·
1 Parent(s): 2d372b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -71,7 +71,7 @@ from streamlit_drawable_canvas import st_canvas
71
  # === Load models ===
72
  @st.cache_resource
73
  def load_single_digit_model():
74
- return load_model("mnist_model.keras")
75
 
76
  @st.cache_resource
77
  def load_multi_digit_model():
@@ -133,7 +133,9 @@ if canvas_result.image_data is not None:
133
  # Preprocess image
134
  img = cv2.cvtColor(canvas_result.image_data.astype("uint8"), cv2.COLOR_RGBA2GRAY)
135
  img = 255 - img # Invert colors
136
- img_resized = cv2.resize(img, (28, 80)) # Resize to match multi-digit model input shape
 
 
137
  img_normalized = img_resized / 255.0
138
  final_img = img_normalized.reshape(1, 28, 80, 1)
139
 
@@ -157,4 +159,3 @@ if canvas_result.image_data is not None:
157
 
158
  # Show prediction result
159
  st.markdown(f"### 🧠 Predicted Number: **{predicted_str}**")
160
-
 
71
  # === Load models ===
72
  @st.cache_resource
73
  def load_single_digit_model():
74
+ return load_model("single_digit_model.keras")
75
 
76
  @st.cache_resource
77
  def load_multi_digit_model():
 
133
  # Preprocess image
134
  img = cv2.cvtColor(canvas_result.image_data.astype("uint8"), cv2.COLOR_RGBA2GRAY)
135
  img = 255 - img # Invert colors
136
+
137
+ # Resize image to match model input dimensions
138
+ img_resized = cv2.resize(img, (80, 28)) # Resize to match multi-digit model input shape
139
  img_normalized = img_resized / 255.0
140
  final_img = img_normalized.reshape(1, 28, 80, 1)
141
 
 
159
 
160
  # Show prediction result
161
  st.markdown(f"### 🧠 Predicted Number: **{predicted_str}**")