From a26e95ceffef1bfe8f91f96f11005b3a5f86fa01 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Wed, 9 Jun 2021 11:22:21 +0200 Subject: [PATCH] On-demand `pycocotools` pip install (#3547) (cherry picked from commit ef0b5c9d29192ae1c4a931f9db808114bb486001) --- detect.py | 2 +- hubconf.py | 2 +- requirements.txt | 2 +- test.py | 3 ++- train.py | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/detect.py b/detect.py index 537f47dfafab..8dbb656ed95f 100644 --- a/detect.py +++ b/detect.py @@ -175,7 +175,7 @@ def detect(opt): parser.add_argument('--half', action='store_true', help='use FP16 half-precision inference') opt = parser.parse_args() print(opt) - check_requirements(exclude=('tensorboard', 'pycocotools', 'thop')) + check_requirements(exclude=('tensorboard', 'thop')) if opt.update: # update all models (to fix SourceChangeWarning) for opt.weights in ['yolov5s.pt', 'yolov5m.pt', 'yolov5l.pt', 'yolov5x.pt']: diff --git a/hubconf.py b/hubconf.py index bedbee18f87f..429e61bbab1b 100644 --- a/hubconf.py +++ b/hubconf.py @@ -31,7 +31,7 @@ def _create(name, pretrained=True, channels=3, classes=80, autoshape=True, verbo from utils.torch_utils import select_device check_requirements(requirements=Path(__file__).parent / 'requirements.txt', - exclude=('tensorboard', 'pycocotools', 'thop', 'opencv-python')) + exclude=('tensorboard', 'thop', 'opencv-python')) set_logging(verbose=verbose) fname = Path(name).with_suffix('.pt') # checkpoint filename diff --git a/requirements.txt b/requirements.txt index d80d373a6fa5..5f2a774b1a93 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,7 +26,7 @@ pandas # extras -------------------------------------- # Cython # for pycocotools https://github.com/cocodataset/cocoapi/issues/172 -pycocotools>=2.0 # COCO mAP +# pycocotools>=2.0 # COCO mAP thop # FLOPs computation diff --git a/test.py b/test.py index 6a2a4e47c142..515b984bc7be 100644 --- a/test.py +++ b/test.py @@ -260,6 +260,7 @@ def test(data, json.dump(jdict, f) try: # https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb + check_requirements(['pycocotools']) from pycocotools.coco import COCO from pycocotools.cocoeval import COCOeval @@ -311,7 +312,7 @@ def test(data, opt.save_json |= opt.data.endswith('coco.yaml') opt.data = check_file(opt.data) # check file print(opt) - check_requirements(exclude=('tensorboard', 'pycocotools', 'thop')) + check_requirements(exclude=('tensorboard', 'thop')) if opt.task in ('train', 'val', 'test'): # run normally test(opt.data, diff --git a/train.py b/train.py index 5ef19c8a0fa9..c4ab52e1645a 100644 --- a/train.py +++ b/train.py @@ -572,7 +572,7 @@ def train_ray_tune(config): set_logging(opt.global_rank) if opt.global_rank in [-1, 0]: check_git_status() - check_requirements(exclude=('pycocotools', 'thop')) + check_requirements(exclude=['thop']) # Resume wandb_run = check_wandb_resume(opt)