Sa-m commited on
Commit
47a795d
1 Parent(s): cc9f68a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
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
- 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
- return f"{labels[i]: float(prediction[i]) for i in range(NUM_CLASSES)}"
 
 
 
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