Resources referenced in tutorial TorchVision Object Detection Finetuning Tutorial

I’m working with TorchVision Object Detection Finetuning Tutorial in Google Colab and I’ve run into a few problems.

## Putting everything together

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 everything under references/detection to your folder and use them here.

I don’t know what “/references/detection” refers to. I looked in the Resources section pytorch.org and nothing jumped out at me as the relevant section.

Missing the references section I think leads to this next problem:

import transforms as T

def get_transform(train):
    transforms = []
    transforms.append(T.ToTensor())
    if train:
        transforms.append(T.RandomHorizontalFlip(0.5))
    return T.Compose(transforms)

I get this error:


ModuleNotFoundError Traceback (most recent call last)

in ()
----> 1 import transforms as T
2
3 def get_transform(train):
4 transforms = []
5 transforms.append(T.ToTensor())

ModuleNotFoundError: No module named ‘transforms’

Another problem for me comes from this code:

data_loader = torch.utils.data.DataLoader(
 dataset, batch_size=2, shuffle=True, num_workers=4,
 collate_fn=utils.collate_fn)

I get an error message like the “utils” module cannot be found. I tried using the data loader before I realized that my data set still needed work. That’s potentially another question, but I think I am finally figuring out how to get my data to build the dataset. That’s still in the air, but getting close.

Another question has to do with:

# use our dataset and defined transformations
dataset = PennFudanDataset('PennFudanPed', get_transform(train=True))
dataset_test = PennFudanDataset('PennFudanPed', get_transform(train=False))

Where do the transformations come from? The code block for torch.utils.data.Dataset
only includes the line:
self.transforms = transforms

I looked here and couldn’t find anything that seems to create the “get_transform(train=True)” bit.

Hi John!

I found it in pytorch’s github: vision / references / detection. It contains,
for example, engine.py and utils.py.

Best.

K. Frank

Ah, yes, should have looked there to begin with. Thanks, K. Frank!

John