Onnx2tf

Latest version: v1.27.1

Safety actively analyzes 723177 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 11 of 86

1.19.16

- Workaround for bug in TensorFlow quantization logic.
- Quantization behavior is clearly broken since `TensorFlow==2.15.0` or `TensorFlow==2.15.0.post1`.

python
representative_dataset_gen
def representative_dataset_gen():
for idx in range(data_count):
yield_data_dict = {}
for model_input_name in model_input_name_list:
calib_data, mean, std = calib_data_dict[model_input_name]
normalized_calib_data: np.ndarray = (calib_data[idx] - mean) / std
yield_data_dict[model_input_name] = tf.cast(tf.convert_to_tensor(normalized_calib_data), tf.float32)
yield yield_data_dict



EagerTensor object has no attribute 'astype'.
If you are looking for numpy-related methods, please run the following:
tf.experimental.numpy.experimental_enable_numpy_behavior()

File "/home/xxxx/.local/lib/python3.10/site-packages/tensorflow/python/framework/tensor.py", line 256, in __getattr__
raise AttributeError(
File "/home/xxxx/git/onnx2tf/onnx2tf/onnx2tf.py", line 1436, in representative_dataset_gen
yield_data_dict[model_input_name] = normalized_calib_data.astype(np.float32)
File "/home/xxxx/.local/lib/python3.10/site-packages/tensorflow/lite/python/optimize/calibrator.py", line 101, in _feed_tensors
for sample in dataset_gen():
File "/home/xxxx/.local/lib/python3.10/site-packages/tensorflow/lite/python/optimize/calibrator.py", line 254, in calibrate
self._feed_tensors(dataset_gen, resize_input=True)
File "/home/xxxx/.local/lib/python3.10/site-packages/tensorflow/lite/python/convert_phase.py", line 215, in wrapper
raise error from None Re-throws the exception.
File "/home/xxxx/.local/lib/python3.10/site-packages/tensorflow/lite/python/convert_phase.py", line 215, in wrapper
raise error from None Re-throws the exception.
File "/home/xxxx/.local/lib/python3.10/site-packages/tensorflow/lite/python/lite.py", line 735, in _quantize
calibrated = calibrate_quantize.calibrate(
File "/home/xxxx/.local/lib/python3.10/site-packages/tensorflow/lite/python/lite.py", line 1037, in _optimize_tflite_model
model = self._quantize(
File "/home/xxxx/.local/lib/python3.10/site-packages/tensorflow/lite/python/convert_phase.py", line 215, in wrapper
raise error from None Re-throws the exception.
File "/home/xxxx/.local/lib/python3.10/site-packages/tensorflow/lite/python/convert_phase.py", line 215, in wrapper
raise error from None Re-throws the exception.
File "/home/xxxx/.local/lib/python3.10/site-packages/tensorflow/lite/python/lite.py", line 1332, in _convert_from_saved_model
return self._optimize_tflite_model(
File "/home/xxxx/.local/lib/python3.10/site-packages/tensorflow/lite/python/lite.py", line 1465, in convert
return self._convert_from_saved_model(graph_def)
File "/home/xxxx/.local/lib/python3.10/site-packages/tensorflow/lite/python/lite.py", line 1093, in _convert_and_export_metrics
result = convert_func(self, *args, **kwargs)
File "/home/xxxx/.local/lib/python3.10/site-packages/tensorflow/lite/python/lite.py", line 1139, in wrapper
return self._convert_and_export_metrics(convert_func, *args, **kwargs)
File "/home/xxxx/git/onnx2tf/onnx2tf/onnx2tf.py", line 1449, in convert
tflite_model = converter.convert()
File "/home/xxxx/git/onnx2tf/onnx2tf/onnx2tf.py", line 2327, in main
model = convert(
File "/home/xxxx/git/onnx2tf/onnx2tf/onnx2tf.py", line 2381, in <module>
main()
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main (Current frame)
return _run_code(code, main_globals, None,
AttributeError: EagerTensor object has no attribute 'astype'.
If you are looking for numpy-related methods, please run the following:
tf.experimental.numpy.experimental_enable_numpy_behavior()


If the modifications are made as suggested by the error message, the main flow of model transformation will be significantly disrupted. The following sentence shall not be added to the logic

python
tf.experimental.numpy.experimental_enable_numpy_behavior()


- [Resize operation fails (['unk__0', 'unk__1', 'unk__2', 'unk__3']) and raises UnboundLocalError: local variable 'new_size' referenced before assignment 607](https://github.com/PINTO0309/onnx2tf/issues/607)

What's Changed
* Workaround for bug in TensorFlow quantization logic by PINTO0309 in https://github.com/PINTO0309/onnx2tf/pull/608


**Full Changelog**: https://github.com/PINTO0309/onnx2tf/compare/1.19.15...1.19.16

1.19.15

- `Split`
- Adjusted behavior when `Split` assumes splitting into multiple sizes.
- Fixed a bug that caused a list of constants to be transposed to NCHW when the tensor is split by multiple irregular constant sizes.
- https://github.com/PINTO0309/onnx2tf/files/14542513/topformer_small_512x512_160k_2x8_ade20k_512in.onnx.zip

![image](https://github.com/PINTO0309/onnx2tf/assets/33194443/4d463e53-714c-41de-aab7-23165d070d52)

- [ONNX Split operation converts to a tf StridedSlice operation with outputs in the wrong order. 588](https://github.com/PINTO0309/onnx2tf/issues/588)

What's Changed
* Adjusted behavior when Split assumes splitting into multiple sizes by PINTO0309 in https://github.com/PINTO0309/onnx2tf/pull/606


**Full Changelog**: https://github.com/PINTO0309/onnx2tf/compare/1.19.14...1.19.15

1.19.14

- `Celu`
- Fixed a bug that caused very few elements to diverge to `Nan`, resulting in inconsistent output.

onnx_tensor[0, 3, 1, 26]
97.723495

tf_transposed_tensor[0, 3, 1, 26]
nan

- [poc.onnx.zip](https://github.com/PINTO0309/onnx2tf/files/14975764/poc.onnx.zip)

TensorFlow operator combinations were reviewed.


onnx2tf -i poc.onnx -cotof


![image](https://github.com/PINTO0309/onnx2tf/assets/33194443/c9430e75-4687-4ded-948c-82c77bc10bbd)

![image](https://github.com/PINTO0309/onnx2tf/assets/33194443/0589bf32-690b-436d-84cd-bbd4d2741e67)

- [There are discrepancies between the outputs of the ONNX model and converted TensorFlow models. 602](https://github.com/PINTO0309/onnx2tf/issues/602)

What's Changed
* pip env setup guide: Fix onnx package version & add tensorflow and protobuf by Boulaouaney in https://github.com/PINTO0309/onnx2tf/pull/601
* Bug fix for `Celu`, onnxruntime==1.17.1 by PINTO0309 in https://github.com/PINTO0309/onnx2tf/pull/603

New Contributors
* Boulaouaney made their first contribution in https://github.com/PINTO0309/onnx2tf/pull/601

**Full Changelog**: https://github.com/PINTO0309/onnx2tf/compare/1.19.13...1.19.14

1.19.13

- `Gather`
ONNX `Gather` changes output shape by removing the singled out dimension. When converting to TF using `strided_slice`, the extra dimension is kept.

ONNX: `[1,50,768]` -> `Gather (index=0)` -> `[1,768]`
TF: `[1,50,768]` -> `StridedSlice (... )` -> `[1,1,768]`

![image](https://github.com/PINTO0309/onnx2tf/assets/33194443/67e33689-b041-4d6d-a0f9-bd13be6614f9)

What's Changed
* Gather - keep output dimensions by svobora in https://github.com/PINTO0309/onnx2tf/pull/597

New Contributors
* svobora made their first contribution in https://github.com/PINTO0309/onnx2tf/pull/597

**Full Changelog**: https://github.com/PINTO0309/onnx2tf/compare/1.19.12...1.19.13

1.19.12

What's Changed
* fix for float64 error by khatami-mehrdad in https://github.com/PINTO0309/onnx2tf/pull/593
* Add type specification, v1.19.12 by PINTO0309 in https://github.com/PINTO0309/onnx2tf/pull/594

New Contributors
* khatami-mehrdad made their first contribution in https://github.com/PINTO0309/onnx2tf/pull/593

**Full Changelog**: https://github.com/PINTO0309/onnx2tf/compare/1.19.11...1.19.12

1.19.11

- `MaxPoolWithArgmax`
- Support for 1D `MaxPoolWithArgmax`
- However, TFLite does not support `max_pool_with_argmax` as standard.
- [UM_best_model.onnx.zip](https://github.com/PINTO0309/onnx2tf/files/14111141/UM_best_model.onnx.zip)
![image](https://github.com/PINTO0309/onnx2tf/assets/33194443/e0ee2807-d6a4-4057-a852-0eff5d7b8326)
- [ValueError in MaxPool Layer during ONNX to TensorFlow Conversion with 3D Input 579](https://github.com/PINTO0309/onnx2tf/issues/579)

What's Changed
* Support for 1D `MaxPoolWithArgmax` by PINTO0309 in https://github.com/PINTO0309/onnx2tf/pull/580


**Full Changelog**: https://github.com/PINTO0309/onnx2tf/compare/1.19.10...1.19.11

Page 11 of 86

Links

Releases

Has known vulnerabilities

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.