Few-shot-Object-Detection-via-Feature-Reweighting icon indicating copy to clipboard operation
Few-shot-Object-Detection-via-Feature-Reweighting copied to clipboard

Error in loading the weight file

Open Fly-dream12 opened this issue 4 years ago • 2 comments

Sorry for troubling you. When I run train_meta.py and load weightfile, a runtimeerror occured:

File "dior_train_meta.py", line 85, in model.load_weights(weightfile) File "/home/baby47/Documents/Few-shot Learning/DeepTrial-Few-shot-Object-Detection-via-Feature-Reweighting-main/models/darknet_meta.py", line 375, in load_weights start = load_conv_bn(buf, start, model[0], model[1]) File "/home/baby47/Documents/Few-shot Learning/DeepTrial-Few-shot-Object-Detection-via-Feature-Reweighting-main/cfg/cfg.py", line 469, in load_conv_bn conv_model.weight.data.copy_(torch.from_numpy(buf[start:start+num_w])); start = start + num_w RuntimeError: The size of tensor a (3) must match the size of tensor b (864) at non-singleton dimension 3

Do you know what's wrong with this? Thank you so much. The environment is under torch==1.4.0, python3.7.

Fly-dream12 avatar Dec 04 '20 01:12 Fly-dream12

Excuse me, have you successfully run this code?

kirkzZ avatar Apr 26 '22 07:04 kirkzZ

Sorry for troubling you. When I run train_meta.py and load weightfile, a runtimeerror occured:

File "dior_train_meta.py", line 85, in model.load_weights(weightfile) File "/home/baby47/Documents/Few-shot Learning/DeepTrial-Few-shot-Object-Detection-via-Feature-Reweighting-main/models/darknet_meta.py", line 375, in load_weights start = load_conv_bn(buf, start, model[0], model[1]) File "/home/baby47/Documents/Few-shot Learning/DeepTrial-Few-shot-Object-Detection-via-Feature-Reweighting-main/cfg/cfg.py", line 469, in load_conv_bn conv_model.weight.data.copy_(torch.from_numpy(buf[start:start+num_w])); start = start + num_w RuntimeError: The size of tensor a (3) must match the size of tensor b (864) at non-singleton dimension 3

Do you know what's wrong with this? Thank you so much. The environment is under torch==1.4.0, python3.7.

Replace line no 469 with "conv_model.weight.data.copy_(torch.from_numpy(buf[start:start+num_w]).reshape_as(conv_model.weight.data)); start = start + num_w "

VARANASISATYASREEKANTH avatar Jun 26 '24 10:06 VARANASISATYASREEKANTH