Skip to content

Commit

Permalink
fix when no objects detected
Browse files Browse the repository at this point in the history
  • Loading branch information
wassname committed Oct 14, 2020
1 parent 60e6c1b commit d41aa24
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 397 deletions.
430 changes: 36 additions & 394 deletions notebooks/c08_Object_Detection/Object_Detection.ipynb

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions notebooks/c08_Object_Detection/Object_Detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,10 @@ def get_prediction(img, threshold=0.5):

# Get the Prediction Score
pred_score = list(pred[0]["scores"].cpu().detach().numpy())
pred_t = [pred_score.index(x) for x in pred_score if x > threshold][
-1
]
pred_ts = [pred_score.index(x) for x in pred_score if x > threshold]
if len(pred_ts)==0:
return [], [], []
pred_t = pred_ts[-1]

# Get list of index with score greater than threshold.
pred_boxes = pred_boxes[: pred_t + 1]
Expand Down Expand Up @@ -568,3 +569,5 @@ def instance_segmentation_api(img_path, threshold=0.5, rect_th=1, text_size=1):
# -




0 comments on commit d41aa24

Please sign in to comment.