Manish Chhetri commited on
Commit
6977399
1 Parent(s): ace7b38
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -140,9 +140,17 @@ def after(image):
140
  # file.save('static/file.jpg')
141
 
142
  # Read the saved file
143
- print(image)
144
- img = cv2.imread(image)
145
- img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
 
 
 
 
 
 
 
 
146
  img = cv2.resize(img, (224,224))
147
  img = img.reshape(1,224,224,3)
148
  test_img_resized=ResNet152Model.predict(img).reshape(2048,)
 
140
  # file.save('static/file.jpg')
141
 
142
  # Read the saved file
143
+ print("Received image:", image)
144
+
145
+ # Convert Gradio Image object to numpy array
146
+ img_array = np.array(image)
147
+
148
+ # Ensure the image is not empty
149
+ if img_array is None:
150
+ return "Error: Empty image received."
151
+
152
+ # Perform image processing
153
+ img = cv2.cvtColor(img_array, cv2.COLOR_BGR2RGB)
154
  img = cv2.resize(img, (224,224))
155
  img = img.reshape(1,224,224,3)
156
  test_img_resized=ResNet152Model.predict(img).reshape(2048,)