Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -252,7 +252,7 @@ def predict(image):
|
|
| 252 |
# Reshape the image to match the model's input shape
|
| 253 |
image = image.reshape(3, 640, 640)
|
| 254 |
|
| 255 |
-
#
|
| 256 |
mean = [0.485, 0.456, 0.406]
|
| 257 |
std = [0.229, 0.224, 0.225]
|
| 258 |
mean = np.expand_dims(mean, axis=(1,2))
|
|
@@ -279,6 +279,7 @@ def predict(image):
|
|
| 279 |
annotated_img = output[0]
|
| 280 |
|
| 281 |
# Reshape the image to match the PIL Image input shape
|
|
|
|
| 282 |
annotated_img = annotated_img.reshape(640, 640, 3)
|
| 283 |
print("annotated_img shape after reshape:", annotated_img.shape)
|
| 284 |
|
|
@@ -286,7 +287,6 @@ def predict(image):
|
|
| 286 |
# annotated_img = classes[output[0][0].argmax(0)]
|
| 287 |
|
| 288 |
print("Annotated image type before normalization:", type(annotated_img))
|
| 289 |
-
# print("annotated_img shape before normalization:", annotated_img.shape)
|
| 290 |
# print("Annotated image before normalization:", annotated_img)
|
| 291 |
print("Min value of image before normalization:", np.min(annotated_img))
|
| 292 |
print("Max value of image before normalization:", np.max(annotated_img))
|
|
|
|
| 252 |
# Reshape the image to match the model's input shape
|
| 253 |
image = image.reshape(3, 640, 640)
|
| 254 |
|
| 255 |
+
# Normalize output image using ImageNet-style normalization
|
| 256 |
mean = [0.485, 0.456, 0.406]
|
| 257 |
std = [0.229, 0.224, 0.225]
|
| 258 |
mean = np.expand_dims(mean, axis=(1,2))
|
|
|
|
| 279 |
annotated_img = output[0]
|
| 280 |
|
| 281 |
# Reshape the image to match the PIL Image input shape
|
| 282 |
+
# print("annotated_img shape before reshape:", annotated_img.shape)
|
| 283 |
annotated_img = annotated_img.reshape(640, 640, 3)
|
| 284 |
print("annotated_img shape after reshape:", annotated_img.shape)
|
| 285 |
|
|
|
|
| 287 |
# annotated_img = classes[output[0][0].argmax(0)]
|
| 288 |
|
| 289 |
print("Annotated image type before normalization:", type(annotated_img))
|
|
|
|
| 290 |
# print("Annotated image before normalization:", annotated_img)
|
| 291 |
print("Min value of image before normalization:", np.min(annotated_img))
|
| 292 |
print("Max value of image before normalization:", np.max(annotated_img))
|