Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
17863b8b
You need to sign in or sign up before continuing.
Commit
17863b8b
authored
Oct 25, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update readme
parent
59928cbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
15 deletions
+4
-15
examples/ResNet/README.md
examples/ResNet/README.md
+1
-3
examples/ResNet/load-resnet.py
examples/ResNet/load-resnet.py
+3
-12
No files found.
examples/ResNet/README.md
View file @
17863b8b
...
@@ -7,12 +7,10 @@ A script to convert and run ResNet{50,101,152} caffe models trained on ImageNet
...
@@ -7,12 +7,10 @@ A script to convert and run ResNet{50,101,152} caffe models trained on ImageNet
Example usage:
Example usage:
```
bash
```
bash
# convert
the model
# convert
caffe model to npy format
python
-m
tensorpack.utils.loadcaffe PATH/TO/
{
ResNet-101-deploy.prototxt,ResNet-101-model.caffemodel
}
ResNet101.npy
python
-m
tensorpack.utils.loadcaffe PATH/TO/
{
ResNet-101-deploy.prototxt,ResNet-101-model.caffemodel
}
ResNet101.npy
# run on an image
# run on an image
./load-resnet.py
--load
ResNet-101.npy
--input
cat.jpg
--depth
101
./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 converted models are verified on ILSVRC12 validation set.
...
...
examples/ResNet/load-resnet.py
View file @
17863b8b
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
# File: load-resnet.py
# File: load-resnet.py
# Author: Eric Yujia Huang yujiah1@andrew.cmu.edu
# Author: Eric Yujia Huang yujiah1@andrew.cmu.edu
# Yuxin Wu <ppwwyyxx@gmail.com>
# Yuxin Wu <ppwwyyxx@gmail.com>
#
import
cv2
import
cv2
import
tensorflow
as
tf
import
tensorflow
as
tf
...
@@ -21,11 +20,6 @@ from tensorpack.tfutils.symbolic_functions import *
...
@@ -21,11 +20,6 @@ from tensorpack.tfutils.symbolic_functions import *
from
tensorpack.tfutils.summary
import
*
from
tensorpack.tfutils.summary
import
*
from
tensorpack.dataflow.dataset
import
ILSVRCMeta
from
tensorpack.dataflow.dataset
import
ILSVRCMeta
"""
Usage:
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
"""
MODEL_DEPTH
=
None
MODEL_DEPTH
=
None
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
...
@@ -98,11 +92,9 @@ class Model(ModelDesc):
...
@@ -98,11 +92,9 @@ class Model(ModelDesc):
def
get_inference_augmentor
():
def
get_inference_augmentor
():
# load ResNet mean from Kaiming:
# load ResNet mean from Kaiming:
#from tensorpack.utils.loadcaffe import get_caffe_pb
#from tensorpack.utils.loadcaffe import get_caffe_pb
#pb = get_caffe_pb()
#obj = get_caffe_pb().BlobProto()
#obj = pb.BlobProto()
#obj.ParseFromString(open('ResNet_mean.binaryproto').read())
#obj.ParseFromString(open('ResNet_mean.binaryproto').read())
#pp_mean_224 = np.array(obj.data).reshape(3, 224, 224)
#pp_mean_224 = np.array(obj.data).reshape(3, 224, 224).transpose(1,2,0)
#pp_mean_224 = pp_mean_224.transpose(1,2,0)
meta
=
ILSVRCMeta
()
meta
=
ILSVRCMeta
()
pp_mean
=
meta
.
get_per_pixel_mean
()
pp_mean
=
meta
.
get_per_pixel_mean
()
...
@@ -209,13 +201,12 @@ if __name__ == '__main__':
...
@@ -209,13 +201,12 @@ if __name__ == '__main__':
required
=
True
)
required
=
True
)
parser
.
add_argument
(
'--depth'
,
help
=
'resnet depth'
,
required
=
True
,
type
=
int
,
choices
=
[
50
,
101
,
152
])
parser
.
add_argument
(
'--depth'
,
help
=
'resnet depth'
,
required
=
True
,
type
=
int
,
choices
=
[
50
,
101
,
152
])
parser
.
add_argument
(
'--input'
,
help
=
'an input image'
)
parser
.
add_argument
(
'--input'
,
help
=
'an input image'
)
parser
.
add_argument
(
'--eval'
,
help
=
'
Run evaluation on dataset
'
)
parser
.
add_argument
(
'--eval'
,
help
=
'
ILSVRC dir to run validation on
'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
assert
args
.
input
or
args
.
eval
,
"Choose either input or eval!"
assert
args
.
input
or
args
.
eval
,
"Choose either input or eval!"
if
args
.
gpu
:
if
args
.
gpu
:
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
args
.
gpu
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
args
.
gpu
# run resNet with given model (in npy format)
MODEL_DEPTH
=
args
.
depth
MODEL_DEPTH
=
args
.
depth
param
=
np
.
load
(
args
.
load
,
encoding
=
'latin1'
)
.
item
()
param
=
np
.
load
(
args
.
load
,
encoding
=
'latin1'
)
.
item
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment