Skip to content

Commit

Permalink
Merge branch 'anuragxel:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-ambrosio authored May 3, 2023
2 parents a1421f8 + e431b6e commit 69589fa
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions salt/dataset_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def parse_mask_to_coco(image_id, anno_id, image_mask, category_id, poly=False):
fortran_binary_mask = np.asfortranarray(image_mask)
encoded_mask = mask.encode(fortran_binary_mask)
if poly == True:
contours = measure.find_contours(image_mask, 0.5)
contours, _ = cv2.findContours(image_mask.astype(np.uint8), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
annotation = {
"id": start_anno_id,
"image_id": image_id,
Expand All @@ -87,11 +87,7 @@ def parse_mask_to_coco(image_id, anno_id, image_mask, category_id, poly=False):
)
if poly == True:
for contour in contours:
contour = np.flip(contour, axis=1)
segmentation = contour.ravel().tolist()
sc = bunch_coords(segmentation)
sc = simplify_coords_vwp(sc, 2)
sc = unbunch_coords(sc)
sc = simplify_coords_vwp(contour[:,0,:], 2).ravel().tolist()
annotation["segmentation"].append(sc)
return annotation

Expand Down

0 comments on commit 69589fa

Please sign in to comment.