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
33f0aa0f
Commit
33f0aa0f
authored
Aug 31, 2021
by
Fan Yang
Committed by
A. Unique TensorFlower
Aug 31, 2021
Browse files
Internal change.
PiperOrigin-RevId: 394116606
parent
a9d416f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
official/vision/beta/serving/export_tflite_lib.py
official/vision/beta/serving/export_tflite_lib.py
+2
-1
official/vision/beta/serving/export_tflite_lib_test.py
official/vision/beta/serving/export_tflite_lib_test.py
+2
-1
No files found.
official/vision/beta/serving/export_tflite_lib.py
View file @
33f0aa0f
...
@@ -13,10 +13,10 @@
...
@@ -13,10 +13,10 @@
# limitations under the License.
# limitations under the License.
"""Library to facilitate TFLite model conversion."""
"""Library to facilitate TFLite model conversion."""
import
functools
import
functools
from
typing
import
Iterator
,
List
,
Optional
from
typing
import
Iterator
,
List
,
Optional
from
absl
import
logging
import
tensorflow
as
tf
import
tensorflow
as
tf
from
official.core
import
config_definitions
as
cfg
from
official.core
import
config_definitions
as
cfg
...
@@ -45,6 +45,7 @@ def create_representative_dataset(
...
@@ -45,6 +45,7 @@ def create_representative_dataset(
# Ensure batch size is 1 for TFLite model.
# Ensure batch size is 1 for TFLite model.
params
.
task
.
train_data
.
global_batch_size
=
1
params
.
task
.
train_data
.
global_batch_size
=
1
params
.
task
.
train_data
.
dtype
=
'float32'
params
.
task
.
train_data
.
dtype
=
'float32'
logging
.
info
(
'Task config: %s'
,
params
.
task
.
as_dict
())
return
task
.
build_inputs
(
params
=
params
.
task
.
train_data
)
return
task
.
build_inputs
(
params
=
params
.
task
.
train_data
)
...
...
official/vision/beta/serving/export_tflite_lib_test.py
View file @
33f0aa0f
...
@@ -54,6 +54,7 @@ class ExportTfliteLibTest(tf.test.TestCase, parameterized.TestCase):
...
@@ -54,6 +54,7 @@ class ExportTfliteLibTest(tf.test.TestCase, parameterized.TestCase):
def
test_export_tflite
(
self
,
experiment
,
quant_type
,
input_image_size
):
def
test_export_tflite
(
self
,
experiment
,
quant_type
,
input_image_size
):
params
=
exp_factory
.
get_exp_config
(
experiment
)
params
=
exp_factory
.
get_exp_config
(
experiment
)
params
.
task
.
validation_data
.
input_path
=
self
.
_test_tfrecord_file
params
.
task
.
validation_data
.
input_path
=
self
.
_test_tfrecord_file
params
.
task
.
train_data
.
input_path
=
self
.
_test_tfrecord_file
temp_dir
=
self
.
get_temp_dir
()
temp_dir
=
self
.
get_temp_dir
()
module
=
image_classification_serving
.
ClassificationModule
(
module
=
image_classification_serving
.
ClassificationModule
(
params
=
params
,
batch_size
=
1
,
input_image_size
=
input_image_size
)
params
=
params
,
batch_size
=
1
,
input_image_size
=
input_image_size
)
...
@@ -66,7 +67,7 @@ class ExportTfliteLibTest(tf.test.TestCase, parameterized.TestCase):
...
@@ -66,7 +67,7 @@ class ExportTfliteLibTest(tf.test.TestCase, parameterized.TestCase):
saved_model_dir
=
os
.
path
.
join
(
temp_dir
,
'saved_model'
),
saved_model_dir
=
os
.
path
.
join
(
temp_dir
,
'saved_model'
),
quant_type
=
quant_type
,
quant_type
=
quant_type
,
params
=
params
,
params
=
params
,
calibration_steps
=
20
)
calibration_steps
=
5
)
self
.
assertIsInstance
(
tflite_model
,
bytes
)
self
.
assertIsInstance
(
tflite_model
,
bytes
)
...
...
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