cocodataset / cocoapi

COCO API - Dataset @ http://cocodataset.org/
Other
6.05k stars 3.75k forks source link

mask.toBbox return wrong result in latest pycocotools 2.0.2 #446

Open ausk opened 4 years ago

ausk commented 4 years ago

Hello, When I install pycocotools 2.0.2 from pypi, and call pycocotools.mask.toBbox, it return wrong result.

Here is a simple test:

import  cv2
import numpy as np
import pycocotools.mask as pymask

fpath = r"test.jpg"

gray = cv2.imread(fpath, cv2.IMREAD_GRAYSCALE)
encoded = pymask.encode(np.asfortranarray(gray, np.uint8))
bbox = pymask.toBbox(encoded)
print(gray.shape, bbox)

test

[OK] 2.0.0 returns (448, 448) [ 56. 151. 304. 274.] [ERROR] 2.0.1/2.0.2 returns (448, 448) [ 56. 0. 304. 448.]

SINGIREDDYANUSHA commented 3 years ago

ERROR: detectron2 0.3+cu101 has requirement pycocotools>=2.0.2, but you'll have pycocotools 2.0 which is incompatible.

am geting this error

ppwwyyxx commented 3 years ago

RLE encode() only supports binary masks. You should convert the masks to binary by gray[gray>0]=1 and then it will produce correct results.