Skip to content

Commit

Permalink
On-demand pycocotools pip install (ultralytics#3547)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher committed Jun 9, 2021
1 parent 7001eb6 commit b74c26a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']:
Expand Down
2 changes: 1 addition & 1 deletion hubconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ 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
3 changes: 2 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion train.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def train(hyp, opt, device, tb_writer=None):
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)
Expand Down

0 comments on commit b74c26a

Please sign in to comment.