Browse Source

fix import pycocotools

mamingjie-China 5 years ago
parent
commit
ad2affa7d7
1 changed files with 1 additions and 6 deletions
  1. 1 6
      paddlex/tools/dataset_split/coco_split.py

+ 1 - 6
paddlex/tools/dataset_split/coco_split.py

@@ -15,6 +15,7 @@
 import os.path as osp
 import random
 import json
+from pycocotools.coco import COCO
 from .utils import MyEncoder
 import paddlex.utils.logging as logging
 
@@ -23,12 +24,6 @@ def split_coco_dataset(dataset_dir, val_percent, test_percent, save_dir):
     if not osp.exists(osp.join(dataset_dir, "annotations.json")):
         logging.error("\'annotations.json\' is not found in {}!".format(
             dataset_dir))
-    try:
-        from pycocotools.coco import COCO
-    except:
-        logging.error(
-            "pycococotools is not installed, follow this doc install pycocotools: https://paddlex.readthedocs.io/zh_CN/develop/install.html#pycocotools"
-        )
 
     annotation_file = osp.join(dataset_dir, "annotations.json")
     coco = COCO(annotation_file)