Object detection FineTuning Tutorial

I have tried to run the script from the tutorial above and I get a crash in Python on line 13

from engine import train_one_epoch, evaluate

The error message is "ImportError: No module named ‘engine’ "

It looks like I forgot something but I can’t find the said module in Pytorch, can somebody tell me what I am doing wrong ?

2 Likes

This error seems to come from an older torchvision version.
Could you update torchvision to >=0.3.0?

The version I have is 0.3.0, PyTorch is 1.1.0 but I can’t use CUDA (no GPU)

Yeah, you were right. You cannot simply import this methods without copying some files first.
From the tutorial:

In references/detection/ , we have a number of helper functions to simplify training and evaluating detection models. Here, we will use references/detection/engine.py , references/detection/utils.py and references/detection/transforms.py . Just copy them to your folder and use them here.

1 Like

Thanks for the reply, I got it to work, just need to add in the directory coco_utils.py and coco_eval.py from the same directory, and to install pycocotools as well.

2 Likes

after all these, the next error is on annotations,

any solution?

Where can I find these files: references/detection/engine.py , references/detection/utils.py and references/detection/transforms.py? Thank you very much!

1 Like

Seems like engine.py requires a module called ‘coco_utils’

Could you tell us where we can find it or how we can install it?

coco_utils should be part of the cocoapi and can be installed via:

git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
python setup.py build_ext install

coco_utils and coco_eval are actually in the reference/detection/ folder as well.
Both of them can be found at https://github.com/pytorch/vision/tree/master/references/detection

3 Likes

You can refer to this repo as well. It is based on torchvision>=0.3.