Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -244,18 +244,23 @@ def predict(image):
|
|
244 |
input_name = model.get_inputs()[0].name
|
245 |
input_shape = model.get_inputs()[0].shape
|
246 |
|
247 |
-
print("start", image.shape)
|
|
|
248 |
|
249 |
# Resize the image to the model's input shape
|
250 |
image = cv2.resize(image, (input_shape[2], input_shape[3]))
|
251 |
|
252 |
-
print("after resize", image.shape)
|
|
|
|
|
|
|
|
|
253 |
|
254 |
# Convert the image to a numpy array and add a batch dimension
|
255 |
if len(input_shape) == 4 and input_shape[0] == 1:
|
256 |
image = np.expand_dims(image, axis=0)
|
257 |
|
258 |
-
image = image.astype(np.float32)
|
259 |
|
260 |
print("after expands/astype", image.shape)
|
261 |
|
|
|
244 |
input_name = model.get_inputs()[0].name
|
245 |
input_shape = model.get_inputs()[0].shape
|
246 |
|
247 |
+
print("start", image.shape) #start (720, 1280, 3)
|
248 |
+
|
249 |
|
250 |
# Resize the image to the model's input shape
|
251 |
image = cv2.resize(image, (input_shape[2], input_shape[3]))
|
252 |
|
253 |
+
print("after resize", image.shape) # after resize (640, 640, 3)
|
254 |
+
|
255 |
+
image = image.reshape(3, 640, 640)
|
256 |
+
|
257 |
+
print("after reshape", image.shape) # after reshape
|
258 |
|
259 |
# Convert the image to a numpy array and add a batch dimension
|
260 |
if len(input_shape) == 4 and input_shape[0] == 1:
|
261 |
image = np.expand_dims(image, axis=0)
|
262 |
|
263 |
+
image = image.astype(np.float32) # after expands/astype (1, 640, 640, 3)
|
264 |
|
265 |
print("after expands/astype", image.shape)
|
266 |
|