leeyeehoo / SiamVGG

SiamVGG: Visual Tracking with Deeper Siamese Networks
79 stars 19 forks source link

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

Open xiaotian3 opened 5 years ago

xiaotian3 commented 5 years ago

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 commented 5 years ago

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.fromnumpy(np.asarray(h5f[k])) except KeyError: print "no value" else: v.copy(param)

Totoro-wen commented 5 years ago

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 commented 5 years ago

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

Totoro-wen commented 5 years ago

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 commented 5 years ago

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