Search code examples
pythonanacondatorchtorchvision

ImportError: cannot import name 'voc' from 'data' (unknown location)


I have been trying to run a code of ssd from the project https://github.com/amdegroot/ssd.pytorch.git but the above error keeps on poping up. There is some issue with the directory i guess. Please guide!!

I am trying to import the below files but unable to do it and

cannot import name 'BaseTransform' from 'data' (unknown location)

this shows up When I tried to run the ssd python file from the above link then I got

ImportError: cannot import name 'voc' from 'data' (unknown location)

So basically there is some path issue I guess.

import torch
from torch.autograd import Variable
import cv2
from data import BaseTransform, VOC_CLASSES as labelmap
from ssd import bulid_ssd
import imageio

Or please tell me in which directory should I put my project python file and https://github.com/amdegroot/ssd.pytorch.git files to make the above import statements work when data and ssd are from https://github.com/amdegroot/ssd.pytorch.git

PS: ssd is Single Shot MultiBox Detector and I am using anaconda


Solution

  • You will need to download the project, and it should have a folder with name data, inside of it, should exists a class with this name.

    Example of structure your_file.py data |_ xxx.py

    Example of code of xxx.py

    class BaseTransform: xxxxxx