nsfw image detector

LukeJacob2023

Introduction

The NSFW-Image-Detector is a fine-tuned model based on google/vit-base-patch16-224-in21k, designed to classify images into categories such as 'drawings', 'hentai', 'neutral', 'porn', and 'sexy'. This model was trained on a custom dataset containing approximately 28,000 images and achieves a high accuracy of 93.16% on the evaluation set.

Architecture

The model utilizes the Vision Transformer (ViT) architecture, specifically the vit-base-patch16-224-in21k variant. It processes images through a series of transformer layers to classify them into predefined categories.

Training

Training and Evaluation Data

A custom dataset of around 28,000 images was used for training. If additional data is needed to enhance accuracy in specific domains, contributions to the dataset are welcome.

Training Procedure

The model was trained using the following hyperparameters:

  • Learning Rate: 2e-05
  • Training Batch Size: 32
  • Evaluation Batch Size: 32
  • Seed: 42
  • Optimizer: Adam (betas=(0.9,0.999), epsilon=1e-08)
  • Learning Rate Scheduler: Linear with 500 warmup steps
  • Epochs: 10
  • Mixed Precision Training: Native AMP

Training Results

The model achieved a final validation accuracy of 93.16% with a loss of 0.8138 after 10 epochs.

Guide: Running Locally

To run the NSFW-Image-Detector locally, follow these steps:

  1. Clone the Repository: Download the model files from the Hugging Face repository.
  2. Install Required Libraries: Ensure that you have Transformers, PyTorch, Datasets, and Tokenizers installed. Use the following versions for compatibility:
    • Transformers 4.36.2
    • PyTorch 2.0.0
    • Datasets 2.15.0
    • Tokenizers 0.15.0
  3. Download the Model Weights: Load the model using the Hugging Face transformers library.
  4. Prepare Input Data: Format your images in a compatible way with the model's input requirements.
  5. Run Inference: Use the model to classify images.

For optimal performance, especially with larger datasets or higher batch sizes, consider using cloud GPUs from providers like AWS, Google Cloud, or Azure.

License

The NSFW-Image-Detector is licensed under the Apache 2.0 License, allowing for both personal and commercial use.

More Related APIs in Image Classification