notAI-tech / NudeNet

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

Help! Test source code of Detector Usage! #39

Closed happypqq closed 4 years ago

happypqq commented 4 years ago

Describe the bug and error messages (if any) A clear and concise description of what the bug is. I really like this project, help pls, thanks! My environment is anaconda3, python=3.6, tensorflow-gpu=1.9, tensorflow=1.9, keras=2.2.4, cython, Pillow, progressbar2, opencv-python=4.0.0.21, pydload, numpy, setuptools==39.1.0, keras-retinanet==0.5.0, nudenet

When I type python detector.py but I get the same picture in output directory and then I execute source code line by line as below.

(trynudenet) C:\Users\Happiness Learning\Desktop\NudeNet-master\NudeNet-master>python Python 3.6.10 |Anaconda, Inc.| (default, May 7 2020, 19:46:08) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from nudenet import NudeDetector Using TensorFlow backend. C:\Anaconda3\envs\trynudenet\lib\site-packages\tensorflow\python\framework\dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 = np.dtype([("qint8", np.int8, 1)]) C:\Anaconda3\envs\trynudenet\lib\site-packages\tensorflow\python\framework\dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) C:\Anaconda3\envs\trynudenet\lib\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint16 = np.dtype([("qint16", np.int16, 1)]) C:\Anaconda3\envs\trynudenet\lib\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) C:\Anaconda3\envs\trynudenet\lib\site-packages\tensorflow\python\framework\dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint32 = np.dtype([("qint32", np.int32, 1)]) C:\Anaconda3\envs\trynudenet\lib\site-packages\tensorflow\python\framework\dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. np_resource = np.dtype([("resource", np.ubyte, 1)]) >>> detector = NudeDetector() 2020-06-10 13:24:30.460748: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 2020-06-10 13:24:30.647062: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1392] Found device 0 with properties: name: GeForce GTX 1050 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.62 pciBusID: 0000:01:00.0 totalMemory: 4.00GiB freeMemory: 3.30GiB 2020-06-10 13:24:30.657394: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1471] Adding visible gpu devices: 0 2020-06-10 13:25:16.771448: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:952] Device interconnect StreamExecutor with strength 1 edge matrix: 2020-06-10 13:25:16.777435: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:958] 0 2020-06-10 13:25:16.781501: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0: N 2020-06-10 13:25:16.784688: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1084] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 3024 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1) C:\Anaconda3\envs\trynudenet\lib\site-packages\keras\engine\saving.py:292: UserWarning: No training configuration found in save file: the model was not compiled. Compile it manually. warnings.warn('No training configuration found in save file: ' >>> detector.detect('./Pic/ss4.jpg') [] detector.censor('./Pic/ss4.jpg', out_path='./output/ss4.jpg', visualize=False)

**The code snippet which gave this error*** detector.detect('./Pic/ss4.jpg') []

Specify versions of the following libraries

  1. nudenet 1.1.0
  2. tensorflow/ tensorflow-gpu 1.9
  3. keras 2.2.4

Expected behavior A clear and concise description of what you expected to happen. (1)Where the correct directory do I need to put the classifier_model and detector_model? (2) Do I need to use docker if I want to use the nudeclient.predict in my local computer? (3) Why nudeclient will install tensorflow 1.14 and remove the tensorflow 1.9 automatically? (4) When I type https://git-lfs.github.com/spec/v1 and it direct me to the https://git-lfs.github.com/, I install the git-lfs-windows-v2.11.0 and how can I get the detector_model?

Screenshots If applicable, add screenshots to help explain your problem. image

bedapudi6788 commented 4 years ago

In the image, the model was not able to detect anything. There is no error per se.

happypqq commented 4 years ago

Thanks for your reply !

After modify classifier.py to url = 'https://github.com/bedapudi6788/NudeNet-models/blob/master/v1/classifier_model' and detector.py to url = 'https://github.com/bedapudi6788/NudeNet-models/blob/master/v1/detector_model'. I get the censor picture with black block after sending another picture.

(1) The only way I can improve the model is retraining the model, right? (2) What's the difference between classifier.classify and nudeclient.predict ? (3) If I want to classify the safe picture, how much threshold do I need to set to identify the picture is safe?

bedapudi6788 commented 4 years ago

(1) The only way I can improve the model is retraining the model, right?

Yes.

(2) What's the difference between classifier.classify and nudeclient.predict ?

They are both the same. NudeClietnt uses the model in tensorflow serving format.

(3) If I want to classify the safe picture, how much threshold do I need to set to identify the picture is safe?

0.5 is a decent threshold.

classifier is also available as a pre-built API at https://fastdeploy.notai.tech/recipes#image-classification