Error in utils/segment/general `masks2segments()` (#9724)

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>
pull/9150/merge
Paul Guerrie 2022-10-06 14:55:15 -06:00 committed by GitHub
parent 7f097ddb6c
commit 5ef69ef3e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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])