Skip to content

Commit a616886

Browse files
authored
[Bug Fix] Fix pycocotools warning (#4958)
1 parent 5795367 commit a616886

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

mmdet/datasets/api_wrappers/coco_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class COCO(_COCO):
1515
"""
1616

1717
def __init__(self, annotation_file=None):
18-
if not getattr(pycocotools, '__version__', '0') >= '12.0.2':
18+
if getattr(pycocotools, '__version__', '0') >= '12.0.2':
1919
warnings.warn(
2020
'mmpycocotools is deprecated. Please install official pycocotools by "pip install pycocotools"', # noqa: E501
2121
UserWarning)

mmdet/datasets/lvis.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def load_annotations(self, ann_file):
278278

279279
try:
280280
import lvis
281-
if lvis.__version__ >= '10.5.3':
281+
if getattr(lvis, '__version__', '0') >= '10.5.3':
282282
warnings.warn(
283283
'mmlvis is deprecated, please install official lvis-api by "pip install git+https://github.com/lvis-dataset/lvis-api.git"', # noqa: E501
284284
UserWarning)
@@ -336,7 +336,7 @@ def evaluate(self,
336336

337337
try:
338338
import lvis
339-
if lvis.__version__ >= '10.5.3':
339+
if getattr(lvis, '__version__', '0') >= '10.5.3':
340340
warnings.warn(
341341
'mmlvis is deprecated, please install official lvis-api by "pip install git+https://github.com/lvis-dataset/lvis-api.git"', # noqa: E501
342342
UserWarning)
@@ -711,6 +711,11 @@ class LVISV1Dataset(LVISDataset):
711711

712712
def load_annotations(self, ann_file):
713713
try:
714+
import lvis
715+
if getattr(lvis, '__version__', '0') >= '10.5.3':
716+
warnings.warn(
717+
'mmlvis is deprecated, please install official lvis-api by "pip install git+https://github.com/lvis-dataset/lvis-api.git"', # noqa: E501
718+
UserWarning)
714719
from lvis import LVIS
715720
except ImportError:
716721
raise ImportError(

0 commit comments

Comments
 (0)