Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -53,7 +53,7 @@ def custom_decode_predictions(predictions, class_labels):
|
|
53 |
decoded_predictions = []
|
54 |
for pred in predictions:
|
55 |
# Get indices of top predicted classes
|
56 |
-
top_indices = pred.argsort()[-
|
57 |
# Decode each top predicted class
|
58 |
decoded_pred = [(class_labels[i], pred[i]) for i in top_indices]
|
59 |
decoded_predictions.append(decoded_pred)
|
@@ -61,8 +61,6 @@ def custom_decode_predictions(predictions, class_labels):
|
|
61 |
|
62 |
def classify_image(img):
|
63 |
img_array = img_to_array(img)
|
64 |
-
img_array = img_array / 255.0
|
65 |
-
img_array = (img_array - img_array.mean()) / img_array.std()
|
66 |
img_array = np.expand_dims(img_array, axis=0)
|
67 |
img_array = preprocess_input(img_array)
|
68 |
|
|
|
53 |
decoded_predictions = []
|
54 |
for pred in predictions:
|
55 |
# Get indices of top predicted classes
|
56 |
+
top_indices = pred.argsort()[-4:][::-1] # Change 5 to the number of top classes you want to retrieve
|
57 |
# Decode each top predicted class
|
58 |
decoded_pred = [(class_labels[i], pred[i]) for i in top_indices]
|
59 |
decoded_predictions.append(decoded_pred)
|
|
|
61 |
|
62 |
def classify_image(img):
|
63 |
img_array = img_to_array(img)
|
|
|
|
|
64 |
img_array = np.expand_dims(img_array, axis=0)
|
65 |
img_array = preprocess_input(img_array)
|
66 |
|