Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -36,14 +36,17 @@ def classify_image(inp):
|
|
36 |
prediction = model.predict(inp)
|
37 |
predicted_class_indices = np.argmax(prediction, axis=1)
|
38 |
result = {}
|
39 |
-
for i in range(len(predicted_class_indices)):
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
47 |
|
48 |
|
49 |
|
|
|
36 |
prediction = model.predict(inp)
|
37 |
predicted_class_indices = np.argmax(prediction, axis=1)
|
38 |
result = {}
|
39 |
+
# for i in range(len(predicted_class_indices)):
|
40 |
+
# if predicted_class_indices[i] < NUM_CLASSES:
|
41 |
+
# try:
|
42 |
+
# label = labels[predicted_class_indices[i]]
|
43 |
+
# result[label] = float(predicted_class_indices[i])
|
44 |
+
# except KeyError:
|
45 |
+
# print(f"KeyError: Label not found for index {predicted_class_indices[i]}")
|
46 |
+
result = {labels[i]: float(prediction[i]) for i in range(NUM_CLASSES)}
|
47 |
+
return str(result)
|
48 |
+
|
49 |
+
|
50 |
|
51 |
|
52 |
|