Skip to content

HCA97/CLIP-based-NSFW-Detector

 
 

Repository files navigation

CLIP-based-NSFW-Detector

The CLIP-based NSFW Detector is a 2-class model primarily trained to detect nudity or pornographic content. It provides an estimation value ranging between 0 and 1, where 1 indicates NSFW content. The detector works well with image embeddings.

Different models are available, ranging from small (ViT-B-32) to large models (ViT-H-14). Please refer to models/README.md for more details.

Note The model files (clip_autokeras_binary_nsfw.zip, clip_autokeras_nsfw_b32.zip, h14_nsfw.pth, violence_detection_vit_b_32.npy, violence_detection_vit_l_14.npy) need to stay where they are. Becayse they are used in clip_retrival see link.

Local Development

To get started with local development, install the dependencies by running the following command:

pip install -r requirements.txt

Training

We provide an example for training and testing the ViT-L-14 openai model, as it's the only model for which we provide the training embeddings. You can find the training embeddings in the Google Drive link. Please see data/README.md for more information.

For training and testing, refer to the notebook Traininig_Test.ipynb.

Inference

You can find inference examples in the notebook CLIP_based_NSFW_detector.ipynb

Additional Resources

Here are some other useful NSFW detectors:

For NSFW detection datasets, you can refer to:

LICENSE

This code and model is released under the MIT license:

Copyright 2022, Christoph Schuhmann

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Releases

No releases published

Packages

 
 
 

Languages

  • Jupyter Notebook 79.1%
  • Python 20.9%