Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: "Unable to open object (object 'bn_adjust.num_batches_tracked' doesn't exist)" #2

Open
xiaotian3 opened this issue Mar 11, 2019 · 5 comments

Comments

@xiaotian3
Copy link

CLIENT: Creating process /home/p920/anaconda3/envs/pytorch/bin/python -c "import sys; sys.path.append('/home/p920/vot-toolkit/native/trax/python');sys.path.append('/home/p920/vot-toolkit/tracker/examples/python'); import python_siamvgg"
CLIENT: Working directory is /tmp/tp2e6fda82_3ac8_4f5c_874a_227ad99f0323
CLIENT: Starting process
CLIENT: Setting up TraX with standard streams connection
@@Trax:hello "trax.image=path" "trax.region=rectangle" "trax.version=1"
CLIENT: Tracker process ID: 19059
CLIENT: Connection with tracker established.
@@Trax:initialize "file:///home/p920/vot-toolkit/vot-2018/sequences/ants1/color/00000001.jpg" "128.7200,458.3600,28.1100,71.0500"
@@Trax:status "128.72,458.36,28.11,71.05"
Traceback (most recent call last):
File "", line 1, in
File "/home/p920/vot-toolkit/tracker/examples/python/python_siamvgg.py", line 20, in
tracker = SiamVGGTracker(imagefile,selection)
File "/home/p920/vot-toolkit/tracker/examples/python/src/siamvggtracker.py", line 46, in init
load_net(NET_PATH,self.siam)
File "/home/p920/vot-toolkit/tracker/examples/python/src/siamvggtracker.py", line 20, in load_net
param = torch.from_numpy(np.asarray(h5f[k]))
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "/home/p920/anaconda3/envs/pytorch/lib/python2.7/site-packages/h5py/_hl/group.py", line 262, in getitem
oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5o.pyx", line 190, in h5py.h5o.open
KeyError: "Unable to open object (object 'bn_adjust.num_batches_tracked' doesn't exist)"

could you help me ?
my pytroch 0.40

@leeyeehoo
Copy link
Owner

So it's the pytorch version. I think PyTorch 5.0 will encounter these issue.

You can read this code:

def load_net(fname, net):
with h5py.File(fname, 'r') as h5f:
for k, v in net.state_dict().items():
try:
param = torch.from_numpy(np.asarray(h5f[k]))
except KeyError:
print "no value"
else: v.copy_(param)

@Totoro-wen
Copy link

Totoro-wen commented Apr 9, 2019

hello,after above way following the problem. my pytorch 1.0

Traceback (most recent call last):
  File "/home/aibc/Wen/Siamese/Pytorch-SiamVGG/demo2.py", line 104, in <module>
    tracker = SiamVGGTracker(imagefile, region)
  File "/home/aibc/Wen/Siamese/Pytorch-SiamVGG/src/siamvggtracker.py", line 66, in __init__
    load_net(NET_PATH, self.siam)
  File "/home/aibc/Wen/Siamese/Pytorch-SiamVGG/src/siamvggtracker.py", line 34, in load_net
    v.copy_(param)
RuntimeError: expand(torch.FloatTensor{[1]}, size=[]): the number of sizes provided (0) must be greater or equal to the number of dimensions in the tensor (1)

can you help me?
Thanks.

@leeyeehoo
Copy link
Owner

I only use PyTorch 0.4.0 for the test. So I'm not fully understand your problem.

@Totoro-wen
Copy link

Totoro-wen commented Apr 18, 2019

I only use PyTorch 0.4.0 for the test. So I'm not fully understand your problem.

I'm sorry I didn't make myself clear
After I replace

# def load_net(fname, net):
#     h5f = h5py.File(fname, mode='r')
#     for k, v in net.state_dict().items():
#         param = torch.from_numpy(np.asarray(h5f[k]))
#         v.copy_(param)

with

# def load_net(fname, net):
#     with h5py.File(fname, 'r') as h5f:
#         for k, v in net.state_dict().items():
#             try:
#                 param = torch.from_numpy(np.asarray(h5f[k]))
#             except KeyError:
#                 print("no value\n")
#             else: v.copy_(param)

, the following problem occurs.

Traceback (most recent call last):
File "python_siamvgg.py", line 27, in
tracker = SiamVGGTracker(imagefile, selection)
File "/home/aibc/Wen/Siamese/SiamVGG/vot2018submission/tracker/examples/python/src/siamvggtracker.py", line 71, in init
load_net(NET_PATH, self.siam)
File "/home/aibc/Wen/Siamese/SiamVGG/vot2018submission/tracker/examples/python/src/siamvggtracker.py", line 24, in load_net
param = torch.from_numpy(np.asarray(h5f[k]))
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "/usr/local/lib/python3.5/dist-packages/h5py/_hl/group.py", line 177, in getitem
oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5o.pyx", line 190, in h5py.h5o.open
KeyError: "Unable to open object (object 'bn_adjust.num_batches_tracked' doesn't exist)"
Exception ignored in: <bound method VOT.del of <vot.VOT object at 0x7f2201883b00>>
Traceback (most recent call last):
File "/home/aibc/Wen/Siamese/SiamVGG/vot2018submission/tracker/examples/python/vot.py", line 189, in del
File "/home/aibc/Wen/Siamese/SiamVGG/vot2018submission/tracker/examples/python/vot.py", line 183, in quit
LookupError: unknown encoding: ascii

And my pytorch is 0.4.0 under anacoda.

@leeyeehoo
Copy link
Owner

If you use 0.4.0, you don't need to replace anything. If you use 1.0, you need to replace it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants