notAI-tech / NudeNet

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

UserWarning: Specified provider 'CUDAExecutionProvider' is not in available provider names.Available providers: 'AzureExecutionProvider, CPUExecutionProvider' #123

Closed yaroslaff closed 8 months ago

yaroslaff commented 9 months ago

Hello!

Thank you for NudeNet, I'm using it in my nudecrawler package, but having problems integrating new version of NudeNet.

Installed NudeNet in venv with pip install --upgrade nudenet. Using simple script (no detection, just create NudeDetector()):

#!/usr/bin/env python

from nudenet import NudeDetector
nude_detector = NudeDetector()

And getting this warning:

$ python x.py 
/tmp/nudenet-testing/.venv/lib/python3.9/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py:69: UserWarning: Specified provider 'CUDAExecutionProvider' is not in available provider names.Available providers: 'AzureExecutionProvider, CPUExecutionProvider'
  warnings.warn(

It works, if I will later use nude_detector.detect('/path/file.jpg') it makes detections. But throws this ugly warning and I want to properly avoid it (not just suppress all warnings).

As I see, this happens on NudeDetector.__init__() :

            providers=["CUDAExecutionProvider", "CPUExecutionProvider"],

because it uses hardcoded providers. Maybe if we will have optional providers argument to __init__ to overwrite it, this would solve problem? Or maybe somehow NudeNet may use currently available providers for onnxruntime as default?

(I took this code from onnxruntime/capi/onnxruntime_inference_collection.py)

from onnxruntime.capi import _pybind_state as C

available_providers = C.get_available_providers()

My environment: Debian 11. python packages:

coloredlogs==15.0.1
flatbuffers==23.5.26
humanfriendly==10.0
mpmath==1.3.0
nudenet==3.0.5
numpy==1.26.0
onnxruntime==1.16.0
opencv-python-headless==4.8.1.78
packaging==23.2
protobuf==4.24.3
sympy==1.12
bedapudi6788 commented 8 months ago

@yaroslaff thanks, updated!