Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
63e20270
Commit
63e20270
authored
Oct 15, 2019
by
Hongkun Yu
Committed by
A. Unique TensorFlower
Oct 15, 2019
Browse files
Update resnet hub export
PiperOrigin-RevId: 274917111
parent
048f5a95
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
official/vision/image_classification/tfhub_export.py
official/vision/image_classification/tfhub_export.py
+7
-2
No files found.
official/vision/image_classification/tfhub_export.py
View file @
63e20270
...
...
@@ -19,6 +19,8 @@ from __future__ import division
# from __future__ import google_type_annotations
from
__future__
import
print_function
import
os
from
absl
import
app
from
absl
import
flags
...
...
@@ -39,14 +41,17 @@ def export_tfhub(model_path, hub_destination):
"""Restores a tf.keras.Model and saves for TF-Hub."""
model
=
resnet_model
.
resnet50
(
num_classes
=
imagenet_preprocessing
.
NUM_CLASSES
)
model
.
load_weights
(
model_path
)
model
.
save
(
os
.
path
.
join
(
hub_destination
,
"classification"
),
include_optimizer
=
False
)
# Extracts a sub-model to use pooling feature vector as model output.
image_input
=
model
.
get_layer
(
index
=
0
).
get_output_at
(
0
)
feature_vector_output
=
model
.
get_layer
(
name
=
'
reduce_mean
'
).
get_output_at
(
0
)
feature_vector_output
=
model
.
get_layer
(
name
=
"
reduce_mean
"
).
get_output_at
(
0
)
hub_model
=
tf
.
keras
.
Model
(
image_input
,
feature_vector_output
)
# Exports a SavedModel.
hub_model
.
save
(
hub_destination
,
include_optimizer
=
False
)
hub_model
.
save
(
os
.
path
.
join
(
hub_destination
,
"feature-vector"
),
include_optimizer
=
False
)
def
main
(
argv
):
...
...
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