Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ image = None
|
|
15 |
prediction = None
|
16 |
labels = None
|
17 |
max_label_index = None
|
18 |
-
max_prediction_value = -1
|
19 |
|
20 |
print('START')
|
21 |
np.set_printoptions(suppress=True)
|
@@ -29,7 +29,6 @@ with open("labels.txt", "r") as file:
|
|
29 |
def classify(image_path):
|
30 |
try:
|
31 |
image_data = np.array(image_path)
|
32 |
-
# image = cv.imread(image_path)
|
33 |
image_data = cv.resize(image_data, (224, 224))
|
34 |
image_array = np.asarray(image_data)
|
35 |
normalized_image_array = (image_array.astype(np.float32) / 127.0) - 1
|
@@ -45,7 +44,7 @@ def classify(image_path):
|
|
45 |
|
46 |
if prediction_value > max_prediction_value:
|
47 |
max_label_index = i
|
48 |
-
max_prediction_value = prediction_value
|
49 |
|
50 |
if max_label_index is not None:
|
51 |
max_label = labels[max_label_index].split(' ', 1)[1]
|
|
|
15 |
prediction = None
|
16 |
labels = None
|
17 |
max_label_index = None
|
18 |
+
max_prediction_value = -1 # Initialize max_prediction_value here
|
19 |
|
20 |
print('START')
|
21 |
np.set_printoptions(suppress=True)
|
|
|
29 |
def classify(image_path):
|
30 |
try:
|
31 |
image_data = np.array(image_path)
|
|
|
32 |
image_data = cv.resize(image_data, (224, 224))
|
33 |
image_array = np.asarray(image_data)
|
34 |
normalized_image_array = (image_array.astype(np.float32) / 127.0) - 1
|
|
|
44 |
|
45 |
if prediction_value > max_prediction_value:
|
46 |
max_label_index = i
|
47 |
+
max_prediction_value = prediction_value # Update max_prediction_value
|
48 |
|
49 |
if max_label_index is not None:
|
50 |
max_label = labels[max_label_index].split(' ', 1)[1]
|