nsfw_data_scraper README

The project's README from github.com/alex000kim/nsfw_data_scraper. As one markdown file: README.md.

NSFW Data Scraper

Note: use with caution - the dataset is noisy

Description

This is a set of scripts that allows for an automatic collection of tens of thousands of images for the following (loosely defined) categories to be later used for training an image classifier:

Here is what each script (located under scripts directory) does:

Prerequisites

How to collect data

$ docker build . -t docker_nsfw_data_scraper
Sending build context to Docker daemon  426.3MB
Step 1/3 : FROM ubuntu:18.04
 ---> 775349758637
Step 2/3 : RUN apt update  && apt upgrade -y  && apt install wget rsync imagemagick default-jre -y
 ---> Using cache
 ---> b2129908e7e2
Step 3/3 : ENTRYPOINT ["/bin/bash"]
 ---> Using cache
 ---> d32c5ae5235b
Successfully built d32c5ae5235b
Successfully tagged docker_nsfw_data_scraper:latest
$ # Next command might run for several hours. It is recommended to leave it overnight
$ docker run -v $(pwd):/root/nsfw_data_scraper docker_nsfw_data_scraper scripts/runall.sh
Getting images for class: neutral
...
...
$ ls data
test  train
$ ls data/train/
drawings  hentai  neutral  porn  sexy
$ ls data/test/
drawings  hentai  neutral  porn  sexy

How to train a CNN model

Results

I was able to train a CNN classifier to 91% accuracy with the following confusion matrix:

alt text

As expected, drawings and hentai are confused with each other more frequently than with other classes.

Same with porn and sexy categories.

nsfw_data_scraper (alex000kim/nsfw_data_scraper)

Searching Database…

What is this?This is a collection of shell scripts that scrapes and aggregates tens of thousands of images across 5 categories (porn, hentai, sexy, neutral, drawings) to build a labeled dataset for training an NSFW image classifier.
Is this a trained model or just scripts?It is not an app or a ready model — it is a set of numbered shell scripts (1_get_urls.sh through 6_create_test.sh) you run in sequence to scrape, download, and organize the raw image dataset yourself.
How do I collect the dataset?Run the scripts under scripts/ in order: the first script grabs image URLs per category using the bundled Ripme app, the second downloads the actual images, and later scripts split everything into train/test folders.
Do I need Docker or Python installed first?You need Docker to run the scraping pipeline, and fastai (installed via conda) if you also want to train the CNN classifier on the resulting dataset.
Is the resulting dataset clean and ready to use?No, the author explicitly warns it's noisy, and in their own tests the drawings/hentai and porn/sexy categories were frequently confused with each other.
What are the 5 image categories?Porn, hentai, sexy, neutral, and drawings — covering explicit content, suggestive-but-not-explicit images, and two safe-for-work categories used for contrast during training.
Where do the safe-for-work comparison images come from?Optional scripts pull SFW anime drawings from the Danbooru2018 database and SFW neutral photos from the Caltech256 dataset.
What is Ripme and why does the project need it?Ripme is a third-party downloader application the scripts call to actually scrape images from the source URLs, most of which point to various subreddits.
Do I have to re-scrape the URLs myself?No — the author already ran the URL-collection script and committed its output under the rawdata directory, so you only need to rerun it if you edit the source URL lists.
Creator
alex000kim
Size
8.3 MB
Stars
12.6K
Updated
CommitApr 17
Age
7y
Commits · 90 Days