[TF Hub] Fix compute output size issue in test (#19719)

It helps to get 4 new models passed and other 2 models failed with accuracy issue.

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
This commit is contained in:
Roman Kazantsev 2023-09-11 12:14:09 +04:00 committed by GitHub
parent 1d0709f533
commit 530da61a4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -7,6 +7,7 @@ efficientnet/lite0/classification,https://tfhub.dev/tensorflow/efficientnet/lite
movenet/multipose/lightning,https://tfhub.dev/google/movenet/multipose/lightning/1?tf-hub-format=compressed
imagenet/efficientnet_v2_imagenet1k_b0/feature_vector,https://tfhub.dev/google/imagenet/efficientnet_v2_imagenet1k_b0/feature_vector/2?tf-hub-format=compressed
imagenet/mobilenet_v1_100_224/classification,https://tfhub.dev/google/imagenet/mobilenet_v1_100_224/classification/5?tf-hub-format=compressed,skip,119718 - Accuracy issue
magenta/arbitrary-image-stylization-v1-256,https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/2?tf-hub-format=compressed
# secure notebook models
unet/industrial/class_1,https://tfhub.dev/nvidia/unet/industrial/class_1/1?tf-hub-format=compressed
movenet/singlepose/thunder,https://tfhub.dev/google/movenet/singlepose/thunder/4?tf-hub-format=compressed

View File

@ -36,11 +36,16 @@ class TestTFHubConvertModel(TestConvertModel):
for input_name, input_info in model_obj.structured_input_signature[1].items():
input_shape = []
try:
for dim in input_info.shape.as_list():
if dim is None:
input_shape.append(1)
else:
input_shape.append(dim)
if input_info.shape.as_list() == [None, None, None, 3] and input_info.dtype == tf.float32:
# image classification case, let us imitate an image
# that helps to avoid compute output size issue
input_shape = [1, 200, 200, 3]
else:
for dim in input_info.shape.as_list():
if dim is None:
input_shape.append(1)
else:
input_shape.append(dim)
except ValueError:
# unknown rank case
pass