Tencent / tencent-ml-images

Largest multi-label image database; ResNet-101 model; 80.73% top-1 acc on ImageNet
Other
3.05k stars 514 forks source link

Error when extracting features #48

Closed rgedeon closed 5 years ago

rgedeon commented 5 years ago

I downloaded ckpt-resnet101-mlimages checkpoint and used the extract_feature.py script to extarct features as follows:

python extract_feature.py --resnet_size=101 --data_format='NCWH' --visiable_gpu=0 --pretrain_ckpt=checkpoints/ckpt-resnet101-mlimages/model.ckpt --result=result.txt --images=imglist.txt

But I got the following error:

InvalidArgumentError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Assign requires shapes of both tensors to match. lhs shape= [2048,1000] rhs shape= [2048,11166] [[node save/Assign_6 (defined at extract_feature.py:67) ]]

wubaoyuan commented 5 years ago

@rgedeon Note that there are two checkpoints. Please use "ckpt-resnet101-mlimages-imagenet"

rgedeon commented 5 years ago

@wubaoyuan I fixed that but now I have this error: feature-length:2048, feature=[0.31629637 0. 0. ... 0.479185 0. 2.0601978 ] Traceback (most recent call last): File "extract_feature.py", line 93, in ffeat.write(sp[0] + "\t" + sp[1] + "\t" + " ".join([str(x) for x in list(feats)]) + '\n') IndexError: list index out of range

wubaoyuan commented 5 years ago

That is a minor issue, please print the value for debugging.

rgedeon notifications@github.com 于2019年3月19日周二 下午6:18写道:

@wubaoyuan https://github.com/wubaoyuan I fixed that but now I have this error: feature-length:2048, feature=[0.31629637 0. 0. ... 0.479185 0. 2.0601978 ] Traceback (most recent call last): File "extract_feature.py", line 93, in ffeat.write(sp[0] + "\t" + sp[1] + "\t" + " ".join([str(x) for x in list(feats)]) + '\n') IndexError: list index out of range

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Tencent/tencent-ml-images/issues/48#issuecomment-474287265, or mute the thread https://github.com/notifications/unsubscribe-auth/AKHHB1ZUabDFkBBYOYWSxK_6ZUHMce_Cks5vYLltgaJpZM4b7t2O .

rgedeon commented 5 years ago

Yes the sp[1] is the out of range.

how shall I prepare the images text file. Is it just one path per line?

rgedeon commented 5 years ago

I put the path then space then the file name then new line