Skip to content

Commit

Permalink
correct bug encoding the mask
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 28, 2024
1 parent 1840577 commit 25201b8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/ai/nets/samj/models/PythonMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public class PythonMethods {
+ " for obj in labels:" + System.lineSeparator()
+ " if obj.num_pixels >= at_least_of_this_size:" + System.lineSeparator()
+ " x_coords,y_coords = trace_contour(obj.image, obj.num_pixels, obj.bbox[1],obj.bbox[0])" + System.lineSeparator()
+ " rle = encode_rle(obj.image)" + System.lineSeparator()
+ " rle = encode_rle(obj.image * 1)" + System.lineSeparator()
+ " print(np.array(rle)[1::2])" + System.lineSeparator()
+ " bbox_w = obj.bbox[3] - obj.bbox[1]" + System.lineSeparator()
+ " for i in range(0, len(rle), 2):" + System.lineSeparator()
+ " rle[i] = sam_result.shape[1] * (obj.bbox[0] + rle[i] // bbox_w) + obj.bbox[1] + rle[i] % bbox_w" + System.lineSeparator()
Expand Down Expand Up @@ -145,6 +146,12 @@ public class PythonMethods {
+ " " + System.lineSeparator()
+ " # Only encode runs of 1s" + System.lineSeparator()
+ " if binary[start] == 1:" + System.lineSeparator()
+ " rem = start % ww" + System.lineSeparator()
+ " while rem + length > ww:" + System.lineSeparator()
+ " rle.extend([int(start), int(ww - rem)])" + System.lineSeparator()
+ " start = (start // ww + 1) * ww" + System.lineSeparator()
+ " length -= (ww - rem)" + System.lineSeparator()
+ " rem = start % ww" + System.lineSeparator()
+ " rle.extend([int(start), int(length)])" + System.lineSeparator()
+ " " + System.lineSeparator()
+ " return rle" + System.lineSeparator()
Expand Down

0 comments on commit 25201b8

Please sign in to comment.