rbarman commited on
Commit
768d600
·
1 Parent(s): 281556c

clean up class result

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -20,8 +20,6 @@ def predict(img: np.ndarray) -> str:
20
  # input: numpy array of image in RGB (see defaults for https://www.gradio.app/docs/#image)
21
 
22
  # The MobileNet model expects images in RGB format.
23
- #image = cv2.cvtColor(img, code=cv2.COLOR_BGR2RGB)
24
- #image = cv2.cvtColor(img, code=cv2.COLOR_BGR2RGB)
25
  # Resize to MobileNet image shape.
26
  input_image = cv2.resize(src=img, dsize=(224, 224))
27
  # Reshape to model input shape.
@@ -38,6 +36,8 @@ def predict(img: np.ndarray) -> str:
38
  # Therefore, a background must be added at the beginning of imagenet_classes.
39
  imagenet_classes = ['background'] + imagenet_classes
40
  best_class = imagenet_classes[result_index]
 
 
41
  # TODO: get n best results with corresponding probabilities?
42
  return best_class
43
 
 
20
  # input: numpy array of image in RGB (see defaults for https://www.gradio.app/docs/#image)
21
 
22
  # The MobileNet model expects images in RGB format.
 
 
23
  # Resize to MobileNet image shape.
24
  input_image = cv2.resize(src=img, dsize=(224, 224))
25
  # Reshape to model input shape.
 
36
  # Therefore, a background must be added at the beginning of imagenet_classes.
37
  imagenet_classes = ['background'] + imagenet_classes
38
  best_class = imagenet_classes[result_index]
39
+ # clean up
40
+ best_class = best_class.partition(' ')[2])
41
  # TODO: get n best results with corresponding probabilities?
42
  return best_class
43