Commit 59928cbb authored by Yuxin Wu's avatar Yuxin Wu

udpate docs about load-resnet

parent 8c441b52
ImageNet training code coming soon. ImageNet training code coming soon.
## load-resnet.py
A script to convert and run ResNet{50,101,152} caffe models trained on ImageNet [released by Kaiming](https://github.com/KaimingHe/deep-residual-networks).
Example usage:
```bash
# convert the model
python -m tensorpack.utils.loadcaffe PATH/TO/{ResNet-101-deploy.prototxt,ResNet-101-model.caffemodel} ResNet101.npy
# run on an image
./load-resnet.py --load ResNet-101.npy --input cat.jpg --depth 101
# validate on ILSVRC12
./load-resnet.py --load ResNet-101.npy --eval PATH/TO/ILSVRC12 --depth 101
```
The converted models are verified on ILSVRC12 validation set.
The per-pixel mean used here is slightly different from the original.
| Model | Top 5 Error | Top 1 Error |
|:-------------------|-------------|------------:|
| ResNet 50 | 7.89% | 25.03% |
| ResNet 101 | 7.16% | 23.74% |
| ResNet 152 | 6.81% | 23.28% |
## cifar10-resnet.py ## cifar10-resnet.py
Reproduce the results in paper "Deep Residual Learning for Image Recognition", [http://arxiv.org/abs/1512.03385](http://arxiv.org/abs/1512.03385) Reproduce the results in paper "Deep Residual Learning for Image Recognition", [http://arxiv.org/abs/1512.03385](http://arxiv.org/abs/1512.03385)
...@@ -15,14 +38,3 @@ Download model: ...@@ -15,14 +38,3 @@ Download model:
[Cifar10 ResNet-110 (n=18)](https://drive.google.com/open?id=0B9IPQTvr2BBkTXBlZmh1cmlnQ0k) [Cifar10 ResNet-110 (n=18)](https://drive.google.com/open?id=0B9IPQTvr2BBkTXBlZmh1cmlnQ0k)
Also see an implementation of [DenseNet](https://github.com/YixuanLi/densenet-tensorflow) from [Densely Connected Convolutional Networks](https://arxiv.org/abs/1608.06993). Also see an implementation of [DenseNet](https://github.com/YixuanLi/densenet-tensorflow) from [Densely Connected Convolutional Networks](https://arxiv.org/abs/1608.06993).
## load-resnet.py
A script to convert and run ResNet{50,101,152} ImageNet caffe models [released by Kaiming](https://github.com/KaimingHe/deep-residual-networks).
Example usage:
```bash
python -m tensorpack.utils.loadcaffe PATH/TO/{ResNet-101-deploy.prototxt,ResNet-101-model.caffemodel} ResNet101.npy
./load-resnet.py --load ResNet-101.npy --input cat.png --depth 101
```
...@@ -58,6 +58,8 @@ class SaverRestore(SessionInit): ...@@ -58,6 +58,8 @@ class SaverRestore(SessionInit):
:param prefix: add a `prefix/` for every variable in this checkpoint :param prefix: add a `prefix/` for every variable in this checkpoint
""" """
assert os.path.isfile(model_path) assert os.path.isfile(model_path)
if os.path.basename(model_path) == model_path:
model_path = os.path.join('.', model_path) # avoid #4921
if os.path.basename(model_path) == 'checkpoint': if os.path.basename(model_path) == 'checkpoint':
model_path = tf.train.get_checkpoint_state( model_path = tf.train.get_checkpoint_state(
os.path.dirname(model_path)).model_checkpoint_path os.path.dirname(model_path)).model_checkpoint_path
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment