模型= CSRNet()| TypeError:super(type,obj):obj必须是类型的实例或子类型

时间:2019-03-16 21:18:20

标签: machine-learning heatmap

transform=transforms.Compose([
                      transforms.ToTensor(),transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                    std=[0.229, 0.224, 0.225]),
])

root = '/home/meet/CSRNet-pytorch/ShanghaiTech/'
part_A_train = os.path.join(root,'part_A/train_data','images')
part_A_test = os.path.join(root,'part_A/test_data','images')
part_B_train = os.path.join(root,'part_B/train_data','images')
part_B_test = os.path.join(root,'part_B/test_data','images')
path_sets = [part_A_test]

#defining the image path
img_paths = []
for path in path_sets:
    for img_path in glob.glob(os.path.join(path, '*.jpg')):
       img_paths.append(img_path)

model = CSRNet()
model = model.cuda()

在运行模型= CSRNet()时,出现“ Typeerror:super(type,obj):obj必须是类型的实例或子类型”

我指的是从人群图像中获取人数的教程。

这是我指的教程:

https://www.analyticsvidhya.com/blog/2019/02/building-crowd-counting-model-python/

这是内核输出窗口:-

模型= CSRNet() 下载:“ https://download.pytorch.org/models/vgg16-397923af.pth”到/home/meet/.torch/models/vgg16-397923af.pth 追溯(最近一次通话):

文件“”,第1行,在     模型= CSRNet()

文件“ /home/meet/CSRNet-pytorch/model.py”,第16行,初始化     mod = models.vgg16(pretrained = True)

vgg16中的第152行“ /home/meet/anaconda3/lib/python3.7/site-packages/torchvision/models/vgg.py”     model.load_state_dict(model_zoo.load_url(model_urls ['vgg16']))

文件“ /home/meet/anaconda3/lib/python3.7/site-packages/torch/utils/model_zoo.py”,第66行,位于load_url中     _download_url_to_file(URL,cached_file,hash_prefix,progress = progress)

文件“ /home/meet/anaconda3/lib/python3.7/site-packages/torch/utils/model_zoo.py”,第73行,在_download_url_to_file中     u = urlopen(url,stream = True)

第70行中的文件“ /home/meet/anaconda3/lib/python3.7/site-packages/requests/api.py”     返回请求('get',url,params = params,** kwargs)

在请求中,文件“ /home/meet/anaconda3/lib/python3.7/site-packages/requests/api.py”,第55行     使用session.Session()作为会话:

文件“ /home/meet/anaconda3/lib/python3.7/site-packages/requests/sessions.py”,行346,位于初始中     self.mount('https://',HTTPAdapter())

init 中的文件“ /home/meet/anaconda3/lib/python3.7/site-packages/requests/adapters.py”,第117行     超级(HTTPAdapter,self)。初始化()

0 个答案:

没有答案