onnx2tf 1.25.10__py3-none-any.whl → 1.25.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
onnx2tf/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from onnx2tf.onnx2tf import convert, main
2
2
 
3
- __version__ = '1.25.10'
3
+ __version__ = '1.25.12'
@@ -338,11 +338,17 @@ def make_node(
338
338
 
339
339
  # Automatic correction of accuracy degradation
340
340
  min_abs_err = sys.maxsize
341
- min_abs_err_perm_1: List[int] = [idx for idx in range(len(mean.shape))]
341
+ min_abs_err_perm_1: List[int] = []
342
+ check_length = 0
343
+ if input_tensor.shape is not None and mean.shape is not None and len(input_tensor.shape) >= len(mean.shape):
344
+ check_length = len(input_tensor.shape)
345
+ else:
346
+ check_length = len(mean.shape)
347
+ min_abs_err_perm_1: List[int] = [idx for idx in range(check_length)]
342
348
 
343
349
  if not disable_strict_mode:
344
350
  if onnx_tensor_infos is not None and validation_data is not None:
345
- tensor_1_candidate_for_transpositions = list(itertools.permutations(range(len(mean.shape))))
351
+ tensor_1_candidate_for_transpositions = list(itertools.permutations(range(check_length)))
346
352
  # Search for the axis with the smallest error
347
353
  for tensor_1_candidate_for_transposition in tensor_1_candidate_for_transpositions:
348
354
  try:
@@ -470,71 +476,72 @@ def make_node(
470
476
  except Exception as ex:
471
477
  pass
472
478
 
473
- tf_layers_dict[Y.name]['tf_node'] = \
474
- tf.nn.batch_normalization(
475
- x=input_tensor,
476
- mean=\
477
- transpose_with_flexing_deterrence(
478
- input_tensor=mean,
479
- perm=min_abs_err_perm_1,
480
- output_shape=Y.shape \
481
- if None not in Y.shape and Y.shape != [] else None,
482
- **kwargs,
483
- ) if not isinstance(mean, np.ndarray) else \
484
- transpose_with_flexing_deterrence(
485
- input_tensor=tf.convert_to_tensor(mean),
486
- perm=min_abs_err_perm_1,
487
- output_shape=Y.shape \
488
- if None not in Y.shape and Y.shape != [] else None,
489
- **kwargs,
490
- ),
491
- variance=\
492
- transpose_with_flexing_deterrence(
493
- input_tensor=var,
494
- perm=min_abs_err_perm_1,
495
- output_shape=Y.shape \
496
- if None not in Y.shape and Y.shape != [] else None,
497
- **kwargs,
498
- ) if not isinstance(var, np.ndarray) else \
499
- transpose_with_flexing_deterrence(
500
- input_tensor=tf.convert_to_tensor(var),
501
- perm=min_abs_err_perm_1,
502
- output_shape=Y.shape \
503
- if None not in Y.shape and Y.shape != [] else None,
504
- **kwargs,
505
- ),
506
- offset=\
507
- transpose_with_flexing_deterrence(
508
- input_tensor=offset,
509
- perm=min_abs_err_perm_1,
510
- output_shape=Y.shape \
511
- if None not in Y.shape and Y.shape != [] else None,
512
- **kwargs,
513
- ) if not isinstance(offset, np.ndarray) else \
514
- transpose_with_flexing_deterrence(
515
- input_tensor=tf.convert_to_tensor(offset),
516
- perm=min_abs_err_perm_1,
517
- output_shape=Y.shape \
518
- if None not in Y.shape and Y.shape != [] else None,
519
- **kwargs,
520
- ),
521
- scale=\
522
- transpose_with_flexing_deterrence(
523
- input_tensor=scale,
524
- perm=min_abs_err_perm_1,
525
- output_shape=Y.shape \
526
- if None not in Y.shape and Y.shape != [] else None,
527
- **kwargs,
528
- ) if not isinstance(scale, np.ndarray) else \
529
- transpose_with_flexing_deterrence(
530
- input_tensor=tf.convert_to_tensor(scale),
531
- perm=min_abs_err_perm_1,
532
- output_shape=Y.shape \
533
- if None not in Y.shape and Y.shape != [] else None,
534
- **kwargs,
535
- ),
536
- variance_epsilon=epsilon,
537
- )
479
+ if min_abs_err_perm_1 != [idx for idx in range(check_length)]:
480
+ tf_layers_dict[Y.name]['tf_node'] = \
481
+ tf.nn.batch_normalization(
482
+ x=input_tensor,
483
+ mean=\
484
+ transpose_with_flexing_deterrence(
485
+ input_tensor=mean,
486
+ perm=min_abs_err_perm_1,
487
+ output_shape=Y.shape \
488
+ if None not in Y.shape and Y.shape != [] else None,
489
+ **kwargs,
490
+ ) if not isinstance(mean, np.ndarray) else \
491
+ transpose_with_flexing_deterrence(
492
+ input_tensor=tf.convert_to_tensor(mean),
493
+ perm=min_abs_err_perm_1,
494
+ output_shape=Y.shape \
495
+ if None not in Y.shape and Y.shape != [] else None,
496
+ **kwargs,
497
+ ),
498
+ variance=\
499
+ transpose_with_flexing_deterrence(
500
+ input_tensor=var,
501
+ perm=min_abs_err_perm_1,
502
+ output_shape=Y.shape \
503
+ if None not in Y.shape and Y.shape != [] else None,
504
+ **kwargs,
505
+ ) if not isinstance(var, np.ndarray) else \
506
+ transpose_with_flexing_deterrence(
507
+ input_tensor=tf.convert_to_tensor(var),
508
+ perm=min_abs_err_perm_1,
509
+ output_shape=Y.shape \
510
+ if None not in Y.shape and Y.shape != [] else None,
511
+ **kwargs,
512
+ ),
513
+ offset=\
514
+ transpose_with_flexing_deterrence(
515
+ input_tensor=offset,
516
+ perm=min_abs_err_perm_1,
517
+ output_shape=Y.shape \
518
+ if None not in Y.shape and Y.shape != [] else None,
519
+ **kwargs,
520
+ ) if not isinstance(offset, np.ndarray) else \
521
+ transpose_with_flexing_deterrence(
522
+ input_tensor=tf.convert_to_tensor(offset),
523
+ perm=min_abs_err_perm_1,
524
+ output_shape=Y.shape \
525
+ if None not in Y.shape and Y.shape != [] else None,
526
+ **kwargs,
527
+ ),
528
+ scale=\
529
+ transpose_with_flexing_deterrence(
530
+ input_tensor=scale,
531
+ perm=min_abs_err_perm_1,
532
+ output_shape=Y.shape \
533
+ if None not in Y.shape and Y.shape != [] else None,
534
+ **kwargs,
535
+ ) if not isinstance(scale, np.ndarray) else \
536
+ transpose_with_flexing_deterrence(
537
+ input_tensor=tf.convert_to_tensor(scale),
538
+ perm=min_abs_err_perm_1,
539
+ output_shape=Y.shape \
540
+ if None not in Y.shape and Y.shape != [] else None,
541
+ **kwargs,
542
+ ),
543
+ variance_epsilon=epsilon,
544
+ )
538
545
  tf_type = tf.nn.batch_normalization
539
546
 
540
547
  # Post-process transpose
onnx2tf/ops/Flatten.py CHANGED
@@ -57,14 +57,17 @@ def make_node(
57
57
  output_shape = graph_node_output.shape
58
58
  dtype = graph_node_output.dtype
59
59
 
60
- axis = graph_node.attrs.get("axis", 0)
61
- if graph_node_input.shape is not None \
62
- and axis < input_tensor_rank:
63
- axis = convert_axis(
64
- axis=axis,
65
- tensor_rank=len(graph_node_input.shape),
66
- before_op_output_shape_trans=before_op_output_shape_trans,
67
- )
60
+ axis = graph_node.attrs.get("axis", None)
61
+ if axis is not None:
62
+ if graph_node_input.shape is not None \
63
+ and axis < input_tensor_rank:
64
+ axis = convert_axis(
65
+ axis=axis,
66
+ tensor_rank=len(graph_node_input.shape),
67
+ before_op_output_shape_trans=before_op_output_shape_trans,
68
+ )
69
+ else:
70
+ axis = input_tensor_rank - 1
68
71
 
69
72
  # Preserving Graph Structure (Dict)
70
73
  tf_layers_dict[graph_node_output.name] = {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: onnx2tf
3
- Version: 1.25.10
3
+ Version: 1.25.12
4
4
  Summary: Self-Created Tools to convert ONNX files (NCHW) to TensorFlow/TFLite/Keras format (NHWC). The purpose of this tool is to solve the massive Transpose extrapolation problem in onnx-tensorflow (onnx-tf).
5
5
  Home-page: https://github.com/PINTO0309/onnx2tf
6
6
  Author: Katsuya Hyodo
@@ -314,7 +314,7 @@ Video speed is adjusted approximately 50 times slower than actual speed.
314
314
  docker run --rm -it \
315
315
  -v `pwd`:/workdir \
316
316
  -w /workdir \
317
- ghcr.io/pinto0309/onnx2tf:1.25.10
317
+ ghcr.io/pinto0309/onnx2tf:1.25.12
318
318
 
319
319
  or
320
320
 
@@ -322,7 +322,7 @@ Video speed is adjusted approximately 50 times slower than actual speed.
322
322
  docker run --rm -it \
323
323
  -v `pwd`:/workdir \
324
324
  -w /workdir \
325
- docker.io/pinto0309/onnx2tf:1.25.10
325
+ docker.io/pinto0309/onnx2tf:1.25.12
326
326
 
327
327
  or
328
328
 
@@ -419,7 +419,7 @@ The given SavedModel SignatureDef contains the following input(s):
419
419
  The given SavedModel SignatureDef contains the following output(s):
420
420
  outputs['output_0'] tensor_info:
421
421
  dtype: DT_FLOAT
422
- shape: (1, 1000) # <-- Model design bug in resnet18-v1-7.onnx
422
+ shape: (-1, 1000)
423
423
  name: PartitionedCall:0
424
424
  Method name is: tensorflow/serving/predict
425
425
 
@@ -1,4 +1,4 @@
1
- onnx2tf/__init__.py,sha256=1LHRsx2l2mQIIDQxnFqokQBOhqkzgY49KD3D8Gq1KIA,67
1
+ onnx2tf/__init__.py,sha256=627_ZeFqdp2iujcX3skUp2qZkqtcJ-iZUtUzhaWBmUU,67
2
2
  onnx2tf/__main__.py,sha256=2RSCQ7d4lc6CwD-rlGn9UicPFg-P5du7ZD_yh-kuBEU,57
3
3
  onnx2tf/onnx2tf.py,sha256=v7juKPrl_0h9SQyck-Ol4B59QXWSSePVC3AUu3fmvII,122750
4
4
  onnx2tf/ops/Abs.py,sha256=V7btmCG_ZvK_qJovUsguq0ZMJ349mhNQ4FHSgzP_Yuo,4029
@@ -13,7 +13,7 @@ onnx2tf/ops/Asinh.py,sha256=74ZzTEkpxZY4CGfJT2JJU-SHXYL5KZeUkWY2v7hsMMw,3588
13
13
  onnx2tf/ops/Atan.py,sha256=D24XDMxEwXFtJheQAr3V3IWOUOc6Q5M0-b_83bmGGMM,3981
14
14
  onnx2tf/ops/Atanh.py,sha256=VsUYopBWWPoo4gta1_aqvUL6NrVXuVkGid4SqDqYJ9Q,3588
15
15
  onnx2tf/ops/AveragePool.py,sha256=p9R4k87FO1yKZMQ699FIftXGUNKxb5yu0vYfzPlpsMA,14701
16
- onnx2tf/ops/BatchNormalization.py,sha256=tOSBgEEV7eZJiYNSt6wuW2-dS4fGoFT6srl0MtA-WBU,25998
16
+ onnx2tf/ops/BatchNormalization.py,sha256=_hlf2-5-j3MCJHEoE2oMNQ8YhCm7ad9h2fwPpTo3i7g,26624
17
17
  onnx2tf/ops/Bernoulli.py,sha256=PM0xS0n1q4bnT_9PnbcKW8_Qj8dJYYBQR8kb2X-wIp4,3670
18
18
  onnx2tf/ops/BitShift.py,sha256=a28_E9hwA8yfjvtsrSKCZCeeMPB5RBQbjB3cmaNGN6k,3861
19
19
  onnx2tf/ops/Cast.py,sha256=iVSqSm1l_MXHtxUBRdQPJlzOTNRHcqMAPKi_LWaPYuc,4357
@@ -45,7 +45,7 @@ onnx2tf/ops/Erf.py,sha256=ayvSp8Pr9h-VYuIiMorwOC0r9aQ4i4S1Uvaho9R6PYo,4962
45
45
  onnx2tf/ops/Exp.py,sha256=MM_Osse7UbJgld2u0fGMcjniJCs40uDztuOodVUqWMU,3583
46
46
  onnx2tf/ops/Expand.py,sha256=MGsby7IhTqKv1K-1INQPHcI5l3Wx-jjJ1FnulpCZsag,14761
47
47
  onnx2tf/ops/EyeLike.py,sha256=VHRlr_WpIGVpZSqfjN7zWQF6XT2KjNVJnjVccxB4P6U,5877
48
- onnx2tf/ops/Flatten.py,sha256=skiXNi4cbh3XRzSm8eaT1vyjQ_8GdWDMT2mf3mB4eO8,6148
48
+ onnx2tf/ops/Flatten.py,sha256=vXRd295Ro7V6p6TwL1xzE1IxI7PSA3iLvugYQJ8UYTA,6251
49
49
  onnx2tf/ops/Floor.py,sha256=8izJrNmw8wNmjF_YabIpLs4jm82J-gKcyAQbwV7Yqpc,3589
50
50
  onnx2tf/ops/FusedConv.py,sha256=gslI50V3yvt4l0mmodnyHFAu0cORx1J_ZL5cE0rZ8qs,4523
51
51
  onnx2tf/ops/GRU.py,sha256=kBHiZlhlPIV2DQCoFYFHxCTwOATeguJy1MSfj2kxqDM,30732
@@ -188,10 +188,10 @@ onnx2tf/utils/__init__.py,sha256=E9FM9He68VIASDnYp-OrxvHFVn55GzWqw2OEkCqn1zg,27
188
188
  onnx2tf/utils/common_functions.py,sha256=gCpAe11EcX-gYOMu68saIpIj20pDmLld-6jybnc_0aY,240691
189
189
  onnx2tf/utils/enums.py,sha256=7c5TqetqB07VjyHoxJHfLgtqBqk9ZRyUF33fPOJR1IM,1649
190
190
  onnx2tf/utils/logging.py,sha256=yUCmPuJ_XiUItM3sZMcaMO24JErkQy7zZwVTYWAuiKg,1982
191
- onnx2tf-1.25.10.dist-info/LICENSE,sha256=5v_Kxihy8i6mzHVl349ikSREaIdsl9YeUnX1KBDLD2w,1070
192
- onnx2tf-1.25.10.dist-info/LICENSE_onnx-tensorflow,sha256=gK4GtS9S5YcyINu6uuNNWdo-kBClyEM4MFLFGiNTeRM,11231
193
- onnx2tf-1.25.10.dist-info/METADATA,sha256=DXGvuW621kGBqw1ZSO6lNZVmnU-TltYJCjJERZ4GFDc,146191
194
- onnx2tf-1.25.10.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
195
- onnx2tf-1.25.10.dist-info/entry_points.txt,sha256=gDPK8ToCFPKMvm8jr9xrGOkXtORJJVh4736fBEKO5k0,41
196
- onnx2tf-1.25.10.dist-info/top_level.txt,sha256=WgfPiEy3f6vZ_FOpAIEA2CF3TCx1eYrhGw93Ih6b9Fw,8
197
- onnx2tf-1.25.10.dist-info/RECORD,,
191
+ onnx2tf-1.25.12.dist-info/LICENSE,sha256=5v_Kxihy8i6mzHVl349ikSREaIdsl9YeUnX1KBDLD2w,1070
192
+ onnx2tf-1.25.12.dist-info/LICENSE_onnx-tensorflow,sha256=gK4GtS9S5YcyINu6uuNNWdo-kBClyEM4MFLFGiNTeRM,11231
193
+ onnx2tf-1.25.12.dist-info/METADATA,sha256=rnNHfLpnT2aW8Zbbdc2rGwQj7-t6Z5rXP2uu7YkNLnY,146147
194
+ onnx2tf-1.25.12.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
195
+ onnx2tf-1.25.12.dist-info/entry_points.txt,sha256=gDPK8ToCFPKMvm8jr9xrGOkXtORJJVh4736fBEKO5k0,41
196
+ onnx2tf-1.25.12.dist-info/top_level.txt,sha256=WgfPiEy3f6vZ_FOpAIEA2CF3TCx1eYrhGw93Ih6b9Fw,8
197
+ onnx2tf-1.25.12.dist-info/RECORD,,