Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions vision/classification/shufflenet/ShufflenetV2-export.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
]
data_dir = 'test_data_set_0'

url, filename = ("https://github.com/pytorch/hub/raw/master/dog.jpg", "dog.jpg")
url, filename = ("https://github.com/pytorch/hub/raw/master/images/dog.jpg", "dog.jpg")
urllib.request.urlretrieve(url, filename)


Expand Down Expand Up @@ -135,7 +135,8 @@ def shufflenetv2_test():
model_dir, data_dir = save_model('shufflenetv2', model.cpu(), input_1, output_1,
opset_version=10,
input_names=['input'],
output_names=['output'])
output_names=['output'],
dynamic_axes={"input": {0: 'batch_size'}, "output": {0: 'batch_size'}})

# Test exported model with TensorProto data saved in files
inputs_flatten = flatten(input_1)
Expand All @@ -161,5 +162,10 @@ def shufflenetv2_test():

inference(model_dir, inputs, outputs)

# Test model with different input
input_2 = torch.randn(6, 3, 224, 224)
output_2 = model(input_2)
inference(model_dir, input_2, output_2)

shufflenetv2_test()

shufflenetv2_test()