onnx2tf 1.26.3__py3-none-any.whl → 1.26.5__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.26.3'
3
+ __version__ = '1.26.5'
onnx2tf/onnx2tf.py CHANGED
@@ -80,6 +80,7 @@ def convert(
80
80
  overwrite_input_shape: Optional[List[str]] = None,
81
81
  no_large_tensor: Optional[bool] = False,
82
82
  output_nms_with_dynamic_tensor: Optional[bool] = False,
83
+ switch_nms_version: Optional[str] = 'v4',
83
84
  keep_ncw_or_nchw_or_ncdhw_input_names: Optional[List[str]] = None,
84
85
  keep_nwc_or_nhwc_or_ndhwc_input_names: Optional[List[str]] = None,
85
86
  keep_shape_absolutely_input_names: Optional[List[str]] = None,
@@ -270,6 +271,12 @@ def convert(
270
271
  enable --output_nms_with_dynamic_tensor:\n
271
272
  output_tensor_shape: [N, 7]
272
273
 
274
+ switch_nms_version: Optional[str]
275
+ Switch the NMS version to V4 or V5 to convert.\n\n
276
+ e.g.\n
277
+ NonMaxSuppressionV4(default): --switch_nms_version v4\n
278
+ NonMaxSuppressionV5: --switch_nms_version v5
279
+
273
280
  keep_ncw_or_nchw_or_ncdhw_input_names: Optional[List[str]]
274
281
  Holds the NCW or NCHW or NCDHW of the input shape for the specified INPUT OP names.\n
275
282
  If a nonexistent INPUT OP name is specified, it is ignored.\n
@@ -921,6 +928,7 @@ def convert(
921
928
  'mvn_epsilon': mvn_epsilon,
922
929
  'output_signaturedefs': output_signaturedefs,
923
930
  'output_nms_with_dynamic_tensor': output_nms_with_dynamic_tensor,
931
+ 'switch_nms_version': switch_nms_version,
924
932
  'output_integer_quantized_tflite': output_integer_quantized_tflite,
925
933
  'gelu_replace_op_names': {},
926
934
  'space_to_depth_replace_op_names': {},
@@ -2233,6 +2241,18 @@ def main():
2233
2241
  'enable --output_nms_with_dynamic_tensor: \n' +
2234
2242
  ' output_tensor_shape: [N, 7]'
2235
2243
  )
2244
+ parser.add_argument(
2245
+ '-snms',
2246
+ '--switch_nms_version',
2247
+ type=str,
2248
+ choices=['v4', 'v5'],
2249
+ default='v4',
2250
+ help=\
2251
+ 'Switch the NMS version to V4 or V5 to convert. \n' +
2252
+ 'e.g. \n' +
2253
+ 'NonMaxSuppressionV4(default): --switch_nms_version v4 \n' +
2254
+ 'NonMaxSuppressionV5: --switch_nms_version v5'
2255
+ )
2236
2256
  parser.add_argument(
2237
2257
  '-k',
2238
2258
  '--keep_ncw_or_nchw_or_ncdhw_input_names',
@@ -2623,6 +2643,7 @@ def main():
2623
2643
  overwrite_input_shape=args.overwrite_input_shape,
2624
2644
  no_large_tensor=args.no_large_tensor,
2625
2645
  output_nms_with_dynamic_tensor=args.output_nms_with_dynamic_tensor,
2646
+ switch_nms_version=args.switch_nms_version,
2626
2647
  keep_ncw_or_nchw_or_ncdhw_input_names=args.keep_ncw_or_nchw_or_ncdhw_input_names,
2627
2648
  keep_nwc_or_nhwc_or_ndhwc_input_names=args.keep_nwc_or_nhwc_or_ndhwc_input_names,
2628
2649
  keep_shape_absolutely_input_names=args.keep_shape_absolutely_input_names,
@@ -25,8 +25,9 @@ from tensorflow.python.util import dispatch
25
25
 
26
26
 
27
27
  class NMSLayer(tf_keras.layers.Layer):
28
- def __init__(self):
28
+ def __init__(self, switch_nms_version='v4'):
29
29
  super(NMSLayer, self).__init__()
30
+ self.switch_nms_version = switch_nms_version
30
31
 
31
32
  @dispatch.add_dispatch_support
32
33
  def non_max_suppression(
@@ -40,29 +41,56 @@ class NMSLayer(tf_keras.layers.Layer):
40
41
  name=None,
41
42
  ):
42
43
  with ops.name_scope(name, 'non_max_suppression'):
43
- selected_indices, num_valid = gen_image_ops.non_max_suppression_v4(
44
- boxes=boxes,
45
- scores=scores,
46
- max_output_size=max_output_size \
47
- if not isinstance(max_output_size, np.ndarray) \
48
- else tf.convert_to_tensor(
49
- value=max_output_size,
50
- name='max_output_size'
51
- ),
52
- iou_threshold=iou_threshold \
53
- if not isinstance(iou_threshold, np.ndarray) \
54
- else tf.convert_to_tensor(
55
- value=iou_threshold,
56
- name='iou_threshold',
57
- ),
58
- score_threshold=score_threshold \
59
- if not isinstance(score_threshold, np.ndarray) \
60
- else tf.convert_to_tensor(
61
- value=score_threshold,
62
- name='score_threshold',
63
- ),
64
- pad_to_max_output_size=pad_to_max_output_size,
65
- )
44
+ if self.switch_nms_version == 'v4':
45
+ selected_indices, num_valid = gen_image_ops.non_max_suppression_v4(
46
+ boxes=boxes,
47
+ scores=scores,
48
+ max_output_size=max_output_size \
49
+ if not isinstance(max_output_size, np.ndarray) \
50
+ else tf.convert_to_tensor(
51
+ value=max_output_size,
52
+ name='max_output_size'
53
+ ),
54
+ iou_threshold=iou_threshold \
55
+ if not isinstance(iou_threshold, np.ndarray) \
56
+ else tf.convert_to_tensor(
57
+ value=iou_threshold,
58
+ name='iou_threshold',
59
+ ),
60
+ score_threshold=score_threshold \
61
+ if not isinstance(score_threshold, np.ndarray) \
62
+ else tf.convert_to_tensor(
63
+ value=score_threshold,
64
+ name='score_threshold',
65
+ ),
66
+ pad_to_max_output_size=pad_to_max_output_size,
67
+ )
68
+
69
+ elif self.switch_nms_version == 'v5':
70
+ selected_indices, selected_scores, num_valid = gen_image_ops.non_max_suppression_v5(
71
+ boxes=boxes,
72
+ scores=scores,
73
+ max_output_size=max_output_size \
74
+ if not isinstance(max_output_size, np.ndarray) \
75
+ else tf.convert_to_tensor(
76
+ value=max_output_size,
77
+ name='max_output_size'
78
+ ),
79
+ iou_threshold=iou_threshold \
80
+ if not isinstance(iou_threshold, np.ndarray) \
81
+ else tf.convert_to_tensor(
82
+ value=iou_threshold,
83
+ name='iou_threshold',
84
+ ),
85
+ score_threshold=score_threshold \
86
+ if not isinstance(score_threshold, np.ndarray) \
87
+ else tf.convert_to_tensor(
88
+ value=score_threshold,
89
+ name='score_threshold',
90
+ ),
91
+ soft_nms_sigma=0.0,
92
+ pad_to_max_output_size=pad_to_max_output_size,
93
+ )
66
94
  if pad_to_max_output_size:
67
95
  return selected_indices
68
96
 
@@ -130,8 +158,8 @@ def make_node(
130
158
  scores = tf_layers_dict[graph_node_input_2.name]['tf_node'] \
131
159
  if isinstance(graph_node_input_2, gs.Variable) else graph_node_input_2
132
160
 
133
- output_nms_with_dynamic_tensor: bool = \
134
- kwargs['output_nms_with_dynamic_tensor']
161
+ output_nms_with_dynamic_tensor: bool = kwargs['output_nms_with_dynamic_tensor']
162
+ switch_nms_version: str = kwargs['switch_nms_version']
135
163
 
136
164
  # Pre-process transpose
137
165
  boxes = pre_process_transpose(
@@ -339,7 +367,7 @@ def make_node(
339
367
  axis=0,
340
368
  )
341
369
  # get the selected boxes indices
342
- nms = NMSLayer()
370
+ nms = NMSLayer(switch_nms_version=switch_nms_version)
343
371
  selected_indices = nms(
344
372
  boxes=tf_boxes,
345
373
  scores=tf_scores,
@@ -2386,6 +2386,15 @@ def shape_unmatched_special_avoidance_workaround(
2386
2386
  input_tensor_2: Any
2387
2387
  Input shape-corrected TensorFlow input node Y
2388
2388
  """
2389
+ try:
2390
+ if hasattr(input_tensor_1, "shape") \
2391
+ and hasattr(input_tensor_2, "shape") \
2392
+ and input_tensor_1.shape is not None \
2393
+ and input_tensor_2.shape is not None \
2394
+ and input_tensor_1.shape == input_tensor_2.shape:
2395
+ return input_tensor_1, input_tensor_2
2396
+ except:
2397
+ pass
2389
2398
  # At least one True value for same_input_shape_as_onnx
2390
2399
  # At least one True value in nhwc_flags
2391
2400
  # same_input_shape_as_onnx == True and nhwc_flags == False and 3D or 4D or 5D tensor is NHWC transposed
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: onnx2tf
3
- Version: 1.26.3
3
+ Version: 1.26.5
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
@@ -12,6 +12,15 @@ Requires-Python: >=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  License-File: LICENSE_onnx-tensorflow
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: license
21
+ Dynamic: platform
22
+ Dynamic: requires-python
23
+ Dynamic: summary
15
24
 
16
25
  # onnx2tf
17
26
  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](https://github.com/onnx/onnx-tensorflow) ([onnx-tf](https://pypi.org/project/onnx-tf/)). I don't need a Star, but give me a pull request. Since I am adding challenging model optimizations and fixing bugs almost daily, I frequently embed potential bugs that would otherwise break through CI's regression testing. Therefore, if you encounter new problems, I recommend that you try a package that is a few versions older, or try the latest package that will be released in a few days.
@@ -314,7 +323,7 @@ Video speed is adjusted approximately 50 times slower than actual speed.
314
323
  docker run --rm -it \
315
324
  -v `pwd`:/workdir \
316
325
  -w /workdir \
317
- ghcr.io/pinto0309/onnx2tf:1.26.3
326
+ ghcr.io/pinto0309/onnx2tf:1.26.5
318
327
 
319
328
  or
320
329
 
@@ -322,7 +331,7 @@ Video speed is adjusted approximately 50 times slower than actual speed.
322
331
  docker run --rm -it \
323
332
  -v `pwd`:/workdir \
324
333
  -w /workdir \
325
- docker.io/pinto0309/onnx2tf:1.26.3
334
+ docker.io/pinto0309/onnx2tf:1.26.5
326
335
 
327
336
  or
328
337
 
@@ -1541,6 +1550,7 @@ usage: onnx2tf
1541
1550
  [-ois OVERWRITE_INPUT_SHAPE [OVERWRITE_INPUT_SHAPE ...]]
1542
1551
  [-nlt]
1543
1552
  [-onwdt]
1553
+ [-snms {v4,v5}]
1544
1554
  [-k KEEP_NCW_OR_NCHW_OR_NCDHW_INPUT_NAMES [KEEP_NCW_OR_NCHW_OR_NCDHW_INPUT_NAMES ...]]
1545
1555
  [-kt KEEP_NWC_OR_NHWC_OR_NDHWC_INPUT_NAMES [KEEP_NWC_OR_NHWC_OR_NDHWC_INPUT_NAMES ...]]
1546
1556
  [-kat KEEP_SHAPE_ABSOLUTELY_INPUT_NAMES [KEEP_SHAPE_ABSOLUTELY_INPUT_NAMES ...]]
@@ -1740,6 +1750,12 @@ optional arguments:
1740
1750
  enable --output_nms_with_dynamic_tensor:
1741
1751
  output_tensor_shape: [N, 7]
1742
1752
 
1753
+ -snms {v4,v5}, --switch_nms_version {v4,v5}
1754
+ Switch the NMS version to V4 or V5 to convert.
1755
+ e.g.
1756
+ NonMaxSuppressionV4(default): --switch_nms_version v4
1757
+ NonMaxSuppressionV5: --switch_nms_version v5
1758
+
1743
1759
  -k KEEP_NCW_OR_NCHW_OR_NCDHW_INPUT_NAMES [KEEP_NCW_OR_NCHW_OR_NCDHW_INPUT_NAMES ...], \
1744
1760
  --keep_ncw_or_nchw_or_ncdhw_input_names KEEP_NCW_OR_NCHW_OR_NCDHW_INPUT_NAMES \
1745
1761
  [KEEP_NCW_OR_NCHW_OR_NCDHW_INPUT_NAMES ...]
@@ -2025,6 +2041,7 @@ convert(
2025
2041
  overwrite_input_shape: Union[List[str], NoneType] = None,
2026
2042
  no_large_tensor: Optional[bool] = False,
2027
2043
  output_nms_with_dynamic_tensor: Optional[bool] = False,
2044
+ switch_nms_version: Optional[str] = 'v4',
2028
2045
  keep_ncw_or_nchw_or_ncdhw_input_names: Union[List[str], NoneType] = None,
2029
2046
  keep_nwc_or_nhwc_or_ndhwc_input_names: Union[List[str], NoneType] = None,
2030
2047
  keep_shape_absolutely_input_names: Optional[List[str]] = None,
@@ -2230,6 +2247,12 @@ convert(
2230
2247
  enable --output_nms_with_dynamic_tensor:
2231
2248
  output_tensor_shape: [N, 7]
2232
2249
 
2250
+ switch_nms_version {v4,v5}
2251
+ Switch the NMS version to V4 or V5 to convert.
2252
+ e.g.
2253
+ NonMaxSuppressionV4(default): switch_nms_version="v4"
2254
+ NonMaxSuppressionV5: switch_nms_version="v5"
2255
+
2233
2256
  keep_ncw_or_nchw_or_ncdhw_input_names: Optional[List[str]]
2234
2257
  Holds the NCW or NCHW or NCDHW of the input shape for the specified INPUT OP names.
2235
2258
  If a nonexistent INPUT OP name is specified, it is ignored.
@@ -1,6 +1,6 @@
1
- onnx2tf/__init__.py,sha256=GQ8Cd-IK3KY_z7zOeJbzvlNqa1JZnqZNpGK3P7Hq7eg,66
1
+ onnx2tf/__init__.py,sha256=CCPWz_VoOl1azpYesO2K-voE8SmUyaEdAT-xziLuToc,66
2
2
  onnx2tf/__main__.py,sha256=2RSCQ7d4lc6CwD-rlGn9UicPFg-P5du7ZD_yh-kuBEU,57
3
- onnx2tf/onnx2tf.py,sha256=0QiBJXhX_m2ZuWoGbAsO_N6z3o9uqN0rL8uEkllYhJc,123980
3
+ onnx2tf/onnx2tf.py,sha256=IEnfIs3Dy8Y5F3iJ4HY7bWkn3QuB6lq_gHa1q5E3tMI,124745
4
4
  onnx2tf/ops/Abs.py,sha256=V7btmCG_ZvK_qJovUsguq0ZMJ349mhNQ4FHSgzP_Yuo,4029
5
5
  onnx2tf/ops/Acos.py,sha256=Fo8YkFKuWq8Fi2xUrBdKcAH1yJ8r5pjSD0wgLttTNdk,4003
6
6
  onnx2tf/ops/Acosh.py,sha256=ATQj2cT5JS_mTfXi0kXqJ1yzSZu5J0zHA5VjV3j7uKY,3588
@@ -96,7 +96,7 @@ onnx2tf/ops/Mod.py,sha256=K6oH5Q4I5JWh8DFp8T1CSdL4WUJCexYdfqTy5iceJxo,9999
96
96
  onnx2tf/ops/Mul.py,sha256=p75MHWbJSo6jLarFzmfK6oQREar4ntlFGqn-U7MzY8s,15962
97
97
  onnx2tf/ops/Multinomial.py,sha256=0HQC76IA3AvRsUx9RS0S__nIfEmPuvIaDfSt8bns4FU,3158
98
98
  onnx2tf/ops/Neg.py,sha256=vu2ExVXyGpggAM_DNPeZj9QFeUyqhn5XmJnDlPJFsQU,4219
99
- onnx2tf/ops/NonMaxSuppression.py,sha256=XdqIAh-KhU9JXRxXigGYe37cw2Fus7wgIteJTcIn_wQ,14153
99
+ onnx2tf/ops/NonMaxSuppression.py,sha256=nHeiX5eMGQAq_51KoljNZGlZddJ89Oe7Yfe33xLhl6M,15763
100
100
  onnx2tf/ops/NonZero.py,sha256=2EYZFMNIejeqR2azHw0CT2mthiKuRPQepUafzeVE8Nk,2788
101
101
  onnx2tf/ops/Not.py,sha256=wn3nThGf4gtpQdHjP7OX2xlhyaNQGeHifjZ18O5shhg,3599
102
102
  onnx2tf/ops/OneHot.py,sha256=OThLm1MF1X75zx7gep_qdnRHsTRZX_tqZxjt6pAVi7E,6489
@@ -185,13 +185,13 @@ onnx2tf/ops/_Loop.py,sha256=eo5sNfrfOnKV6_I737AWsM5LJTY9DVOxQEvhanxtP4g,11322
185
185
  onnx2tf/ops/__Loop.py,sha256=ClwMcbNS4hqUtW_pzwjMa9Cqg7ONvz9aplke55A0uJ0,19704
186
186
  onnx2tf/ops/__init__.py,sha256=jnmUWWa-3dHzBZV9bmPzXu6eoz2dumJTzO7i8JdcgSM,25
187
187
  onnx2tf/utils/__init__.py,sha256=E9FM9He68VIASDnYp-OrxvHFVn55GzWqw2OEkCqn1zg,27
188
- onnx2tf/utils/common_functions.py,sha256=35vTJfectN2lPwsVGaka_wzpZpCLJeQDmn327oVj4FA,241128
188
+ onnx2tf/utils/common_functions.py,sha256=lhhWuNVDwM_mVFc9DD2kYcYEyyT46CDlJMvZzi9KWD4,241473
189
189
  onnx2tf/utils/enums.py,sha256=7c5TqetqB07VjyHoxJHfLgtqBqk9ZRyUF33fPOJR1IM,1649
190
190
  onnx2tf/utils/logging.py,sha256=yUCmPuJ_XiUItM3sZMcaMO24JErkQy7zZwVTYWAuiKg,1982
191
- onnx2tf-1.26.3.dist-info/LICENSE,sha256=5v_Kxihy8i6mzHVl349ikSREaIdsl9YeUnX1KBDLD2w,1070
192
- onnx2tf-1.26.3.dist-info/LICENSE_onnx-tensorflow,sha256=gK4GtS9S5YcyINu6uuNNWdo-kBClyEM4MFLFGiNTeRM,11231
193
- onnx2tf-1.26.3.dist-info/METADATA,sha256=Z9LRHNes38qX_F5zyDsJumFxJ-BnD1N246dOw7O-yXw,146609
194
- onnx2tf-1.26.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
195
- onnx2tf-1.26.3.dist-info/entry_points.txt,sha256=gDPK8ToCFPKMvm8jr9xrGOkXtORJJVh4736fBEKO5k0,41
196
- onnx2tf-1.26.3.dist-info/top_level.txt,sha256=WgfPiEy3f6vZ_FOpAIEA2CF3TCx1eYrhGw93Ih6b9Fw,8
197
- onnx2tf-1.26.3.dist-info/RECORD,,
191
+ onnx2tf-1.26.5.dist-info/LICENSE,sha256=5v_Kxihy8i6mzHVl349ikSREaIdsl9YeUnX1KBDLD2w,1070
192
+ onnx2tf-1.26.5.dist-info/LICENSE_onnx-tensorflow,sha256=gK4GtS9S5YcyINu6uuNNWdo-kBClyEM4MFLFGiNTeRM,11231
193
+ onnx2tf-1.26.5.dist-info/METADATA,sha256=GtIaK3JYaUlveLrLhxHuJX-Tb9H54timBbTLctSs8Rw,147279
194
+ onnx2tf-1.26.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
195
+ onnx2tf-1.26.5.dist-info/entry_points.txt,sha256=gDPK8ToCFPKMvm8jr9xrGOkXtORJJVh4736fBEKO5k0,41
196
+ onnx2tf-1.26.5.dist-info/top_level.txt,sha256=WgfPiEy3f6vZ_FOpAIEA2CF3TCx1eYrhGw93Ih6b9Fw,8
197
+ onnx2tf-1.26.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5