Last active
October 9, 2022 04:22
-
-
Save josephrocca/0581baa153235adf9a3e6560203edc80 to your computer and use it in GitHub Desktop.
lyra-v2-soundstream-tflite-to-onnx-conversion-error-indexerror-list-index-out-of-range.ipynb
This file contains hidden or 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
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"collapsed_sections": [], | |
"authorship_tag": "ABX9TyNXqhgz4fRfe/ICu9LDaFtV", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
}, | |
"accelerator": "GPU", | |
"gpuClass": "standard" | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/josephrocca/0581baa153235adf9a3e6560203edc80/lyra-v2-soundstream-tflite-to-onnx-conversion-error-indexerror-list-index-out-of-range.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"!pip install tensorflow==2.9.2" | |
], | |
"metadata": { | |
"id": "4YHd4pEU14zL" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"import tensorflow as tf\n", | |
"tf.__version__" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"id": "ndU-oI3x3P-_", | |
"outputId": "1a71a161-d9db-418b-95b6-d3b36b2d064b" | |
}, | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"'2.9.2'" | |
], | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
} | |
}, | |
"metadata": {}, | |
"execution_count": 2 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"!pip install git+https://github.com/onnx/tensorflow-onnx" | |
], | |
"metadata": { | |
"id": "_Our00mFGN_J" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"!wget https://huggingface.co/rocca/lyra-v2-soundstream/resolve/main/tflite/soundstream_encoder.tflite" | |
], | |
"metadata": { | |
"id": "go1tTAjRF3KO" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "jjQIusn9FvAR", | |
"outputId": "f90c0b6b-42b7-4328-bd17-263e7e9d52fa" | |
}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"/usr/lib/python3.7/runpy.py:125: RuntimeWarning: 'tf2onnx.convert' found in sys.modules after import of package 'tf2onnx', but prior to execution of 'tf2onnx.convert'; this may result in unpredictable behaviour\n", | |
" warn(RuntimeWarning(msg))\n", | |
"2022-10-09 04:08:11,357 - INFO - tf2onnx: inputs: None\n", | |
"2022-10-09 04:08:11,357 - INFO - tf2onnx: outputs: None\n", | |
"2022-10-09 04:08:12,242 - INFO - tf2onnx.tfonnx: Using tensorflow=2.9.2, onnx=1.12.0, tf2onnx=1.12.0/c60c5e\n", | |
"2022-10-09 04:08:12,243 - INFO - tf2onnx.tfonnx: Using opset <onnx, 16>\n", | |
"INFO: Created TensorFlow Lite XNNPACK delegate for CPU.\n", | |
"Traceback (most recent call last):\n", | |
" File \"/usr/lib/python3.7/runpy.py\", line 193, in _run_module_as_main\n", | |
" \"__main__\", mod_spec)\n", | |
" File \"/usr/lib/python3.7/runpy.py\", line 85, in _run_code\n", | |
" exec(code, run_globals)\n", | |
" File \"/usr/local/lib/python3.7/dist-packages/tf2onnx/convert.py\", line 706, in <module>\n", | |
" main()\n", | |
" File \"/usr/local/lib/python3.7/dist-packages/tf2onnx/convert.py\", line 291, in main\n", | |
" output_path=args.output)\n", | |
" File \"/usr/local/lib/python3.7/dist-packages/tf2onnx/convert.py\", line 165, in _convert_common\n", | |
" custom_op_handlers=custom_op_handlers, **kwargs)\n", | |
" File \"/usr/local/lib/python3.7/dist-packages/tf2onnx/tfonnx.py\", line 453, in process_tf_graph\n", | |
" main_g, subgraphs = graphs_from_tflite(tflite_path, input_names, output_names)\n", | |
" File \"/usr/local/lib/python3.7/dist-packages/tf2onnx/tflite_utils.py\", line 153, in graphs_from_tflite\n", | |
" parse_tflite_graph(tfl_graph, opcodes, model, prefix, tensor_shapes_from_interpreter)\n", | |
" File \"/usr/local/lib/python3.7/dist-packages/tf2onnx/tflite_utils.py\", line 485, in parse_tflite_graph\n", | |
" onnx_node = helper.make_node(optype, input_names, output_names, name=output_names[0], **attr)\n", | |
"IndexError: list index out of range\n" | |
] | |
} | |
], | |
"source": [ | |
"!python -m tf2onnx.convert --opset 16 --tflite soundstream_encoder.tflite --output soundstream_encoder.onnx --verbose --debug # --inputs \"serving_default_input_audio:0\" --outputs \"StatefulPartitionedCall:0\"" | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment