leeyeehoo / CSRNet-pytorch

CSRNet: Dilated Convolutional Neural Networks for Understanding the Highly Congested Scenes
642 stars 259 forks source link

Problem while testing #89

Closed cybermritunjay closed 3 years ago

cybermritunjay commented 3 years ago

Traceback (most recent call last): File "F:\Bus-Tracking\person-counter\CSRNet-pytorch\val.py", line 64, in model = CSRNet() File "F:\CSRNet-pytorch\model.py", line 19, in init self.frontend.state_dict().items()[i][1].data[:] = mod.state_dict().items()[i][1].data[:] TypeError: 'odict_items' object is not subscriptable

ddzambranoa commented 3 years ago

Python3 list(self.frontend.state_dict().items())[i][1].data[:] = list(mod.state_dict().items())[i][1].data[:]

Python2 self.frontend.state_dict().items()[i][1].data[:] = mod.state_dict().items()[i][1].data[:]

cybermritunjay commented 3 years ago

xrange returns xrange object range returns range object there is a difference in them

ddzambranoa commented 3 years ago

Change xrange to range CSRNet code is Python2, you should change to code python 3

for i in range(len(self.frontend.state_dict().items())):