notAI-tech / NudeNet

Lightweight nudity detection
https://nudenet.notai.tech/
GNU Affero General Public License v3.0
1.66k stars 335 forks source link

onnxruntime latest version dependency causes not to work #118

Closed berkaycelebi closed 9 months ago

berkaycelebi commented 9 months ago

In newer version of onnxruntime InferenceSession method is not compitable with the package and throws this exception:

File "/usr/local/lib/python3.10/site-packages/nudenet/nudenet.py", line 104, in __init__
  self.onnx_session = onnxruntime.InferenceSession(
 File "/usr/local/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 432, in __init__
  raise e
 File "/usr/local/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 419, in __init__
  self._create_inference_session(providers, provider_options, disabled_optimizers)
 File "/usr/local/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 451, in _create_inference_session
  raise ValueError(
ValueError: This ORT build has ['AzureExecutionProvider', 'CPUExecutionProvider'] enabled. Since ORT 1.9, you are required to explicitly set the providers parameter when instantiating InferenceSession. For example, onnxruntime.InferenceSession(..., providers=['AzureExecutionProvider', 'CPUExecutionProvider'], ...)

We noticed that in setup.py

REQUIRED = [
    "numpy",
    "onnxruntime",
    "opencv-python",
]

"onnxruntime" forces to install latest version.

This causes old versions (2.0.9 in our case) not to work.

bedapudi6788 commented 9 months ago

fixed in nudenet 3.0.3, thanks for reporting. cuda and cpu execution providers are now set as default, in that order.

bedapudi6788 commented 9 months ago

closing the issue.