Browse Source

On-demand `pycocotools` pip install (#3547)

modifyDataloader
Glenn Jocher GitHub 3 years ago
parent
commit
ef0b5c9d29
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 5 deletions
  1. +1
    -1
      detect.py
  2. +1
    -1
      hubconf.py
  3. +1
    -1
      requirements.txt
  4. +2
    -1
      test.py
  5. +1
    -1
      train.py

+ 1
- 1
detect.py View File

parser.add_argument('--half', action='store_true', help='use FP16 half-precision inference') parser.add_argument('--half', action='store_true', help='use FP16 half-precision inference')
opt = parser.parse_args() opt = parser.parse_args()
print(opt) print(opt)
check_requirements(exclude=('tensorboard', 'pycocotools', 'thop'))
check_requirements(exclude=('tensorboard', 'thop'))


if opt.update: # update all models (to fix SourceChangeWarning) if opt.update: # update all models (to fix SourceChangeWarning)
for opt.weights in ['yolov5s.pt', 'yolov5m.pt', 'yolov5l.pt', 'yolov5x.pt']: for opt.weights in ['yolov5s.pt', 'yolov5m.pt', 'yolov5l.pt', 'yolov5x.pt']:

+ 1
- 1
hubconf.py View File

from utils.torch_utils import select_device from utils.torch_utils import select_device


check_requirements(requirements=Path(__file__).parent / 'requirements.txt', check_requirements(requirements=Path(__file__).parent / 'requirements.txt',
exclude=('tensorboard', 'pycocotools', 'thop', 'opencv-python'))
exclude=('tensorboard', 'thop', 'opencv-python'))
set_logging(verbose=verbose) set_logging(verbose=verbose)


fname = Path(name).with_suffix('.pt') # checkpoint filename fname = Path(name).with_suffix('.pt') # checkpoint filename

+ 1
- 1
requirements.txt View File



# extras -------------------------------------- # extras --------------------------------------
# Cython # for pycocotools https://github.com/cocodataset/cocoapi/issues/172 # Cython # for pycocotools https://github.com/cocodataset/cocoapi/issues/172
pycocotools>=2.0 # COCO mAP
# pycocotools>=2.0 # COCO mAP
thop # FLOPs computation thop # FLOPs computation

+ 2
- 1
test.py View File

json.dump(jdict, f) json.dump(jdict, f)


try: # https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb try: # https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb
check_requirements(['pycocotools'])
from pycocotools.coco import COCO from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval from pycocotools.cocoeval import COCOeval


opt.save_json |= opt.data.endswith('coco.yaml') opt.save_json |= opt.data.endswith('coco.yaml')
opt.data = check_file(opt.data) # check file opt.data = check_file(opt.data) # check file
print(opt) print(opt)
check_requirements(exclude=('tensorboard', 'pycocotools', 'thop'))
check_requirements(exclude=('tensorboard', 'thop'))


if opt.task in ('train', 'val', 'test'): # run normally if opt.task in ('train', 'val', 'test'): # run normally
test(opt.data, test(opt.data,

+ 1
- 1
train.py View File

set_logging(opt.global_rank) set_logging(opt.global_rank)
if opt.global_rank in [-1, 0]: if opt.global_rank in [-1, 0]:
check_git_status() check_git_status()
check_requirements(exclude=('pycocotools', 'thop'))
check_requirements(exclude=['thop'])


# Resume # Resume
wandb_run = check_wandb_resume(opt) wandb_run = check_wandb_resume(opt)

Loading…
Cancel
Save