openvinotoolkit / anomalib

An anomaly detection library comprising state-of-the-art algorithms and features such as experiment management, hyper-parameter optimization, and edge inference.
https://anomalib.readthedocs.io/en/latest/
Apache License 2.0
3.4k stars 615 forks source link

[Bug]: ImportError: cannot import name 'OpenVINOInferencer' #2140

Open ZJDATY opened 3 weeks ago

ZJDATY commented 3 weeks ago

Install from source

https://github.com/openvinotoolkit/anomalib.git

version:1.2 dev

from anomalib.deploy import OpenVINOInferencer

error

from anomalib.deploy import OpenVINOInferencer, ExportType File "/home/zhang/pythonworkspace/py310/anomalib/src/anomalib/deploy/init.py", line 7, in from .inferencers import Inferencer, OpenVINOInferencer, TorchInferencer File "/home/zhang/pythonworkspace/py310/anomalib/src/anomalib/deploy/inferencers/init.py", line 7, in from .openvino_inferencer import OpenVINOInferencer File "/home/zhang/pythonworkspace/py310/anomalib/src/anomalib/deploy/inferencers/openvino_inferencer.py", line 26, in import openvino as ov File "/home/zhang/pythonworkspace/py310/results/weights/onnx/openvino.py", line 11, in from anomalib.deploy import OpenVINOInferencer, ExportType ImportError: cannot import name 'OpenVINOInferencer' from partially initialized module 'anomalib.deploy' (most likely due to a circular import) (/home/zhang/pythonworkspace/py310/anomalib/src/anomalib/deploy/init.py)

I also tried writing like this

from anomalib.deploy.inferencers import OpenVINOInferencer

error

from anomalib.deploy.inferencers import OpenVINOInferencer File "/home/zhang/pythonworkspace/py310/anomalib/src/anomalib/deploy/init.py", line 7, in from .inferencers import Inferencer, OpenVINOInferencer, TorchInferencer File "/home/zhang/pythonworkspace/py310/anomalib/src/anomalib/deploy/inferencers/init.py", line 7, in from .openvino_inferencer import OpenVINOInferencer File "/home/zhang/pythonworkspace/py310/anomalib/src/anomalib/deploy/inferencers/openvino_inferencer.py", line 26, in import openvino as ov File "/home/zhang/pythonworkspace/py310/results/weights/onnx/openvino.py", line 4, in from anomalib.deploy.inferencers import OpenVINOInferencer ImportError: cannot import name 'OpenVINOInferencer' from partially initialized module 'anomalib.deploy.inferencers' (most likely due to a circular import) (/home/zhang/pythonworkspace/py310/anomalib/src/anomalib/deploy/inferencers/init.py)

I also tried writing like this from anomalib.deploy.inferencers.openvino_inferencer import OpenVINOInferencer

error

from anomalib.deploy.inferencers.openvino_inferencer import OpenVINOInferencer File "/home/zhang/pythonworkspace/py310/anomalib/src/anomalib/deploy/init.py", line 7, in from .inferencers import Inferencer, OpenVINOInferencer, TorchInferencer File "/home/zhang/pythonworkspace/py310/anomalib/src/anomalib/deploy/inferencers/init.py", line 7, in from .openvino_inferencer import OpenVINOInferencer File "/home/zhang/pythonworkspace/py310/anomalib/src/anomalib/deploy/inferencers/openvino_inferencer.py", line 26, in import openvino as ov File "/home/zhang/pythonworkspace/onnx/openvino.py", line 4, in from anomalib.deploy.inferencers.openvino_inferencer import OpenVINOInferencer ImportError: cannot import name 'OpenVINOInferencer' from partially initialized module 'anomalib.deploy.inferencers.openvino_inferencer' (most likely due to a circular import) (/home/zhang/pythonworkspace/py310/anomalib/src/anomalib/deploy/inferencers/openvino_inferencer.py)