omerferhatt / torch2tflite

PyTorch to TensorFlow Lite converter
MIT License
181 stars 43 forks source link

TypeError: 'tuple' object cannot be interpreted as an integer #11

Open nyadla-sys opened 2 years ago

nyadla-sys commented 2 years ago

I created below colab and getting below "TypeError: 'tuple' object cannot be interpreted as an integer" error. Could you please help me on this ? https://colab.research.google.com/drive/19JeOkrxlGP6KtkfGbrkO87COc4pvSZSE?usp=sharing#scrollTo=vdeytDxjFdZ3

Traceback (most recent call last): File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/content/torch2tflite/torch2tflite/converter.py", line 187, in args.seed File "/content/torch2tflite/torch2tflite/converter.py", line 40, in init self.sample_data = self.load_sample_input(sample_file_path, target_shape, seed, normalize) File "/content/torch2tflite/torch2tflite/converter.py", line 121, in load_sample_input data = np.random.random(target_shape).astype(np.float32) File "mtrand.pyx", line 434, in numpy.random.mtrand.RandomState.random File "mtrand.pyx", line 425, in numpy.random.mtrand.RandomState.random_sample File "_common.pyx", line 291, in numpy.random._common.double_fill TypeError: 'tuple' object cannot be interpreted as an integer

nyadla-sys commented 2 years ago

@omerferhatt

Please use the below Colab to reproduce the issue https://colab.research.google.com/drive/1HZgkJRkvuX_6xhceQJGC6TW-zHYhA41a?usp=sharing

yaserabdelaziz commented 2 years ago

@nyadla-sys change type in this line https://github.com/omerferhatt/torch2tflite/blob/6dac47aafffa9ec4093b3d420e2ac026a48b3192/torch2tflite/converter.py#L177 from tuple to int and run again.

Note: you will need to unzip the installed torch2tflite-1.0.0-py3.8.egg file at your Python site-packages folder using any unzipping tool (e.g. unzip), make the modification above, compress all files again, and put the compressed files in the same path.