tensorflow-resnet
tensorflow-resnet copied to clipboard
image classification using resnet pre-trained
hey, what command should I run to do a classification or object recognition on a pre-trained model given to us in the torrent file?
[jalal@scc-c01 MHRN]$ tree tensorflow-resnet-pretrained-20160509
tensorflow-resnet-pretrained-20160509
|-- ResNet-L101.ckpt
|-- ResNet-L101.meta
|-- ResNet-L152.ckpt
|-- ResNet-L152.meta
|-- ResNet-L50.ckpt
`-- ResNet-L50.meta
0 directories, 6 files
[jalal@scc-c01 MHRN]$ tree tensorflow-resnet
tensorflow-resnet
|-- LICENSE
|-- README.md
|-- __init__.py
|-- config.py
|-- convert.py
|-- data
| |-- ResNet-101-deploy.prototxt
| |-- ResNet-152-deploy.prototxt
| |-- ResNet-50-deploy.prototxt
| |-- ResNet_mean.binaryproto
| |-- cat.jpg
| `-- tensorflow-resnet-pretrained-20160509.tar.gz.torrent
|-- forward.py
|-- image_processing.py
|-- resnet.py
|-- resnet_train.py
|-- synset.py
|-- train_cifar.py
`-- train_imagenet.py
1 directory, 18 files
If you use tensorflow, then you should first build the graph and then load the pre-trained weight (tf.restore). Besides, the pre-trained model is a old checkpoint format (V1) as there is no .index and .data-00000-of-00001 file. I am currently training the ResNet50 and I will provide more info as the experiment proceeds.
@cardwing hello, buddy. have you finished training the ResNet-50 yet?
I found the pretrained model @ry provided can not be loaded, because i'm receiving this error message. can you help me?
ValueError: At least two variables have the same name: scale5/block1/a/weights
You should have a look on the variable name of ry's pre-trained model. Then, you should use the same variable name and this problem should be fixed.
@cardwing where can I find the variable name list of ry's pre-trained model? thx
@LvJC I met this problem too. Have you solved this problem? If have, please tell me. Thanks~
@Yimian-Go sorry buddy. Could you please describe your problems? Or you just want to get the variable names in ry's checkpoints?
@Yiman-GO sorry this is you
@LvJC I want to use the pretrained model 'res50', so i use: saver = tf.train.import_meta_graph(pretrained_meta) saver.restore(sess, pretrained_ckpt)
Then it told me that the first sentence lead to :'ValueError: At least two variables have the same name: scale1/gamma'. [the name changed everytime]. I wanna know that whether my import is true or notand how to solve this problem. Thank you very much!
@Yiman-GO Actually I can't find the .meta file, so I rebuild the graph of ry. And restore the Resnet-50 checkpoint. And I think you can have a try of my method. And if you met other problems, welcome to communicate.
@LvJC ok. I will try it later. Now, I met a new problem. I converted my data to the byte(same with cifar10), but when i start to train, it told that loss_ is nan(from the 0 step). It's strange. Have you met with this problem?
The following code works for me where I load the weight of 2D ResNet-50 model into 3D ResNet-50 model:
with tf.Session() as sess:
# build 3D ResNet-50
saver = tf.train.import_meta_graph('/DATA/houyn/pre-trained-models/models/ResNet-L50.meta')
saver.restore(sess, '/DATA/houyn/pre-trained-models/models/ResNet-L50.ckpt')
var_list = saver._var_list
value=[]
for i in range(265):
tmp = sess.run(var_list[i], feed_dict={})
if tmp.shape[0] < 10:
tmp = [tmp / 1.0 / tmp.shape[0] for _ in range(tmp.shape[0])]
tmp = np.stack(tmp, axis=0)
value.append(tmp)
You can use PyCharm to view the variable values and its names in the debug mode.
The variable name is stored in saver._var_list
.