Closed evansmal closed 2 years ago
Locally I've applied the following patch to test that the proposed fix works:
diff --git a/nnef_tools/model/graph.py b/nnef_tools/model/graph.py
index b3c88b0..cd4b37c 100644
--- a/nnef_tools/model/graph.py
+++ b/nnef_tools/model/graph.py
@@ -14,7 +14,7 @@
from __future__ import division, print_function, absolute_import
-from collections import Sequence
+from collections.abc import Sequence
from functools import reduce
import six
You should be able to reproduce this with the following Dockerfile:
FROM python:3.10.1
RUN pip3 install numpy future typing six
COPY ./fix_import.patch /
RUN git clone https://github.com/KhronosGroup/NNEF-Tools.git && \
cd /NNEF-Tools && git apply -vvvv /fix_import.patch && \
python setup.py install
CMD python3 -m nnef_tools.convert
Run with the following commands (put patch from above next to Dockerfile):
$> docker build -t nnef_tools_fix .
$> docker run nnef_tools_fix
usage: convert.py [-h] --input-model INPUT_MODEL [--output-model OUTPUT_MODEL]
--input-format {tf,tflite,onnx,nnef,caffe2,caffe}
--output-format {tf,tflite,onnx,nnef,caffe2}
[--input-shapes INPUT_SHAPES]
[--io-transpose [IO_TRANSPOSE ...]] [--fold-constants]
[--optimize] [--dequantize]
[--custom-converters CUSTOM_CONVERTERS [CUSTOM_CONVERTERS ...]]
[--custom-shapes CUSTOM_SHAPES [CUSTOM_SHAPES ...]]
[--custom-fragments CUSTOM_FRAGMENTS [CUSTOM_FRAGMENTS ...]]
[--custom-optimizers CUSTOM_OPTIMIZERS [CUSTOM_OPTIMIZERS ...]]
[--mirror-unsupported] [--generate-custom-fragments]
[--keep-io-names] [--decompose [DECOMPOSE ...]]
[--input-names INPUT_NAMES [INPUT_NAMES ...]]
[--output-names OUTPUT_NAMES [OUTPUT_NAMES ...]]
[--static-only] [--tensor-mapping [TENSOR_MAPPING]]
[--annotate-shapes] [--compress [COMPRESS]]
convert.py: error: the following arguments are required: --input-model, --input-format, --output-format
Summary
Using the NNEF tools (convert, visualize, etc.) with Python 3.10 and later fails with the following error:
This is due to a change in the
collections
module:To reproduce this issue, install the tools locally and run the following with Python 3.8:
Possible Fix
It should be possible to fix this by updating the import statement in
./nnef_tools/model/graph.py
from:to
I can submit a patch for this. Let me know if this is helpful.