Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -248,21 +248,23 @@ def predict(image):
|
|
| 248 |
image = cv2.resize(image, (input_shape[2], input_shape[3]))
|
| 249 |
image = image.reshape(3, 640, 640)
|
| 250 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
# Convert the image to a numpy array and add a batch dimension
|
| 252 |
if len(input_shape) == 4 and input_shape[0] == 1:
|
| 253 |
image = np.expand_dims(image, axis=0)
|
| 254 |
|
| 255 |
image = image.astype(np.float32) # after expands/astype (1, 640, 640, 3)
|
| 256 |
-
|
| 257 |
-
# Normalize the image
|
| 258 |
-
mean = [0.485, 0.456, 0.406]
|
| 259 |
-
std = [0.229, 0.224, 0.225]
|
| 260 |
-
image = (image / 255.0 - mean)/std
|
| 261 |
|
| 262 |
# Perform inference
|
| 263 |
output = model.run(None, {input_name: image})
|
| 264 |
# print(type(output))
|
| 265 |
-
|
| 266 |
|
| 267 |
return output
|
| 268 |
|
|
|
|
| 248 |
image = cv2.resize(image, (input_shape[2], input_shape[3]))
|
| 249 |
image = image.reshape(3, 640, 640)
|
| 250 |
|
| 251 |
+
# Normalize the image
|
| 252 |
+
mean = [0.485, 0.456, 0.406]
|
| 253 |
+
std = [0.229, 0.224, 0.225]
|
| 254 |
+
image = (image / 255.0 - mean)/std
|
| 255 |
+
|
| 256 |
+
print("normalized image:" image.shape)
|
| 257 |
+
|
| 258 |
# Convert the image to a numpy array and add a batch dimension
|
| 259 |
if len(input_shape) == 4 and input_shape[0] == 1:
|
| 260 |
image = np.expand_dims(image, axis=0)
|
| 261 |
|
| 262 |
image = image.astype(np.float32) # after expands/astype (1, 640, 640, 3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
|
| 264 |
# Perform inference
|
| 265 |
output = model.run(None, {input_name: image})
|
| 266 |
# print(type(output))
|
| 267 |
+
print("model.run worked")
|
| 268 |
|
| 269 |
return output
|
| 270 |
|