Skip to content

Commit

Permalink
Error in utils/segment/general masks2segments() (#9724)
Browse files Browse the repository at this point in the history
When running segmentation predict on gpu, the conversion from tensor to numpy fails. Calling `.cpu()` solves this problem. 

Signed-off-by: Paul Guerrie <97041392+paulguerrie@users.noreply.github.com>

Signed-off-by: Paul Guerrie <97041392+paulguerrie@users.noreply.github.com>
  • Loading branch information
paulguerrie committed Oct 6, 2022
1 parent 7f097dd commit 5ef69ef
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils/segment/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def masks_iou(mask1, mask2, eps=1e-7):
def masks2segments(masks, strategy='largest'):
# Convert masks(n,160,160) into segments(n,xy)
segments = []
for x in masks.int().numpy().astype('uint8'):
for x in masks.int().cpu().numpy().astype('uint8'):
c = cv2.findContours(x, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)[0]
if strategy == 'concat': # concatenate all segments
c = np.concatenate([x.reshape(-1, 2) for x in c])
Expand Down

0 comments on commit 5ef69ef

Please sign in to comment.