notAI-tech / NudeNet

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

OSError: Unable to open file (file signature not found) #21

Closed vinsofts-trientt closed 4 years ago

vinsofts-trientt commented 4 years ago

I used model classifier_model at https://github.com/bedapudi6788/nudenet-models But I got an error, my code: from nudenet import NudeClassifier classifier = NudeClassifier('C:/Users/anlan/OneDrive/Desktop/NudeNet-models-master/v1/classifier_model') classifier.classify('C:/Users/anlan/OneDrive/Desktop/1.jpg')

error: Using TensorFlow backend. Traceback (most recent call last): File "test.py", line 2, in classifier = NudeClassifier('C:/Users/anlan/OneDrive/Desktop/NudeNet-models-master/v1/classifier_model') File "C:\Users\anlan\Anaconda3\lib\site-packages\nudenet\classifier.py", line 43, in init Classifier.nsfw_model = keras.models.load_model(model_path) File "C:\Users\anlan\Anaconda3\lib\site-packages\keras\engine\saving.py", line 417, in load_model f = h5dict(filepath, 'r') File "C:\Users\anlan\Anaconda3\lib\site-packages\keras\utils\io_utils.py", line 186, in init self.data = h5py.File(path, mode=mode) File "C:\Users\anlan\Anaconda3\lib\site-packages\h5py_hl\files.py", line 269, in init fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr) File "C:\Users\anlan\Anaconda3\lib\site-packages\h5py_hl\files.py", line 99, in make_fid fid = h5f.open(name, flags, fapl=fapl) File "h5py_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "h5py\h5f.pyx", line 78, in h5py.h5f.open OSError: Unable to open file (file signature not found)

Please help me!

harangutang commented 4 years ago

You are using the wrong file. I also had this issue. Try opening the classifier_model you downloaded in notepad. If it is an html file, then it is not the right file. This is happening because of the git-lfs thing... the url you are downloading should be https://github.com/bedapudi6788/NudeNet-models/raw/master/v1/detector_model, NOT https://github.com/bedapudi6788/NudeNet-models/blob/master/v1/detector_model

bedapudi6788 commented 4 years ago

@harangutang is correct. Classifier model also has a tf-serving version available. You don't need to download the models manually in that version.