forked from gmalivenko/onnx2keras
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add tf_name to ones * add tf_pad for kerasTensor (dynamic) padding * use tf.add that support correct broadcasting instead of layers.Add * add LayerNorm * add swin test
- Loading branch information
1 parent
75a232a
commit 5942e44
Showing
6 changed files
with
85 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import onnxruntime as ort | ||
import numpy as np | ||
import onnx | ||
from onnx2kerastl import onnx_to_keras | ||
from keras_data_format_converter import convert_channels_first_to_last | ||
import tensorflow as tf | ||
from test.models.private_tests.aws_utils import aws_s3_download | ||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize('aws_s3_download', [["swin/", "swin/", False]], indirect=True) | ||
def test_swin(aws_s3_download): | ||
model_path = f'{aws_s3_download}/swin_v2_t.onnx' | ||
inpt = np.load(f'{aws_s3_download}/input.npy') | ||
result = np.load(f'{aws_s3_download}/output.npy') | ||
onnx_model = onnx.load(model_path) | ||
keras_model = onnx_to_keras(onnx_model, ['input'], name_policy='attach_weights_name', | ||
allow_partial_compilation=False).converted_model | ||
final_model = convert_channels_first_to_last(keras_model, should_transform_inputs_and_outputs=True) | ||
res = final_model(inpt) | ||
mean_error = (res-result).numpy().__abs__().mean() | ||
max_error = (res-result).numpy().__abs__().max() | ||
eps = 5e-6 | ||
assert mean_error < eps | ||
assert max_error < eps |