airctic / icevision

An Agnostic Computer Vision Framework - Pluggable to any Training Library: Fastai, Pytorch-Lightning with more to come
https://airctic.github.io/icevision/
Apache License 2.0
845 stars 149 forks source link

Error: cannot import name 'intersect_dicts' from 'yolov5.utils.torch_utils when using icevision==0.12.0 with yolov5==6.2.3 #1153

Open rafaelvp-db opened 1 year ago

rafaelvp-db commented 1 year ago

🐛 Bug

Describe the bug

When trying to use yolov5==6.2.3 with icevision==0.12.0 I get the following error:

8 from yolov5.models.yolo import Model
      9 from yolov5.utils.downloads import attempt_download
---> 10 from yolov5.utils.torch_utils import intersect_dicts
     11 from yolov5.utils.general import check_img_size
     12 from icevision.models.ultralytics.yolov5.utils import *

ImportError: cannot import name 'intersect_dicts' from 'yolov5.utils.torch_utils' (/databricks/python/lib/python3.8/site-packages/yolov5/utils/torch_utils.py)

To Reproduce Steps to reproduce the behavior:

  1. Install icevision==0.12.0 and yolov5==6.2.3
  2. Try to instantiate icevision.parsers.COCOBBoxParser

Expected behavior COCOBBoxParser is instantiated correctly

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context I'm trying to replicate the exact same architecture available from ultralytics.yolov5 for inference (mainly because I want to run inference on raw images, without having to declare a Dataset or DataLoader. The reason for this is to deploy an object detection as a REST API endpoint.

fcakyon commented 1 year ago

It's in utils.general in the latest versions: https://github.com/ultralytics/yolov5/blob/fde77584687041aa62795bb2c27e895cf73686bf/utils/general.py#L242

But icevision should be used with yolov5-icevision package I believe: https://github.com/airctic/icevision/blob/b6b70ad5fe5fa168d4d44d122b433ad1aaf1959c/setup.cfg#L38