# NudeNet: Neural Nets for Nudity Classification, Detection and selective censoring
This is a fork of the `v2` branch of [https://github.com/notAI-tech/NudeNet](https://github.com/notAI-tech/NudeNet).
This fork exists since the original branch is no longer functional, as it relies upon downloading the classifier model from the github release page, which now requires the user to be logged in.
The emphasis of this fork is to maintain a simple working nudenet python package for easy use, primarily for classification purposes. I also removed the indecent images from the readme, as in my probably prude opinion they do not belong onto the page of a project that's about censoring it.
**Classifier classes:**
|class name | Description |
|--------|:--------------:
|safe | Image/Video is not sexually explicit |
|unsafe | Image/Video is sexually explicit|
# As Python module
**Installation**:
```bash
pip install --upgrade NudeNetv2
```
**Classifier Usage**:
```python
# Import module
from NudeNetv2 import NudeClassifier
# initialize classifier (downloads the checkpoint file automatically the first time)
classifier = NudeClassifier()
# Classify single image
classifier.classify('path_to_image_1')
# Returns {'path_to_image_1': {'safe': PROBABILITY, 'unsafe': PROBABILITY}}
# Classify multiple images (batch prediction)
# batch_size is optional; defaults to 4
classifier.classify(['path_to_image_1', 'path_to_image_2'], batch_size=BATCH_SIZE)
# Returns {'path_to_image_1': {'safe': PROBABILITY, 'unsafe': PROBABILITY},
# 'path_to_image_2': {'safe': PROBABILITY, 'unsafe': PROBABILITY}}
# Classify video
# batch_size is optional; defaults to 4
classifier.classify_video('path_to_video', batch_size=BATCH_SIZE)
# Returns {"metadata": {"fps": FPS, "video_length": TOTAL_N_FRAMES, "video_path": 'path_to_video'},
# "preds": {frame_i: {'safe': PROBABILITY, 'unsafe': PROBABILITY}, ....}}
```
Thanks to [Johnny Urosevic](https://github.com/JohnnyUrosevic), NudeClassifier is also available in tflite.
**TFLite Classifier Usage**:
```python
# Import module
from nudenet import NudeClassifierLite
# initialize classifier (downloads the checkpoint file automatically the first time)
classifier_lite = NudeClassifierLite()
# Classify single image
classifier_lite.classify('path_to_image_1')
# Returns {'path_to_image_1': {'safe': PROBABILITY, 'unsafe': PROBABILITY}}
# Classify multiple images (batch prediction)
# batch_size is optional; defaults to 4
classifier_lite.classify(['path_to_image_1', 'path_to_image_2'])
# Returns {'path_to_image_1': {'safe': PROBABILITY, 'unsafe': PROBABILITY},
# 'path_to_image_2': {'safe': PROBABILITY, 'unsafe': PROBABILITY}}
```
Using the tflite classifier from flutter: **https://github.com/ndaysinaiK/nude-test**
**Detector Usage**:
```python
# Import module
from NudeNetv2 import NudeDetector
# initialize detector (downloads the checkpoint file automatically the first time)
detector = NudeDetector() # detector = NudeDetector('base') for the "base" version of detector.
# Detect single image
detector.detect('path_to_image')
# fast mode is ~3x faster compared to default mode with slightly lower accuracy.
detector.detect('path_to_image', mode='fast')
# Returns [{'box': LIST_OF_COORDINATES, 'score': PROBABILITY, 'label': LABEL}, ...]
# Detect video
# batch_size is optional; defaults to 2
# show_progress is optional; defaults to True
detector.detect_video('path_to_video', batch_size=BATCH_SIZE, show_progress=BOOLEAN)
# fast mode is ~3x faster compared to default mode with slightly lower accuracy.
detector.detect_video('path_to_video', batch_size=BATCH_SIZE, show_progress=BOOLEAN, mode='fast')
# Returns {"metadata": {"fps": FPS, "video_length": TOTAL_N_FRAMES, "video_path": 'path_to_video'},
# "preds": {frame_i: {'box': LIST_OF_COORDINATES, 'score': PROBABILITY, 'label': LABEL}, ...], ....}}
```
# Notes:
- detect_video and classify_video first identify the "unique" frames in a video and run predictions on them for significant performance improvement.
- V1 of NudeDetector (available in master branch of this repo) was trained on 12000 images labelled by the good folks at cti-community.
- V2 (current version) of NudeDetector is trained on 160,000 entirely auto-labelled (using classification heat maps and various other hybrid techniques) images.
- The entire data for the classifier is available at https://archive.org/details/NudeNet_classifier_dataset_v1
- A part of the auto-labelled data (Images are from the classifier dataset above) used to train the base Detector is available at https://github.com/notAI-tech/NudeNet/releases/download/v0/DETECTOR_AUTO_GENERATED_DATA.zip
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/christianbrinkmann/nudenetv2",
"name": "NudeNetv2",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6.0",
"maintainer_email": null,
"keywords": null,
"author": "BEDAPUDI PRANEETH",
"author_email": "praneethbedapudi@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/dc/e8/db2beb7a93287c5f2b7edcfa4a7f08a5fda5817dc8eb446c168d74b808f6/NudeNetv2-2.0.10.tar.gz",
"platform": null,
"description": "\n# NudeNet: Neural Nets for Nudity Classification, Detection and selective censoring\n\nThis is a fork of the `v2` branch of [https://github.com/notAI-tech/NudeNet](https://github.com/notAI-tech/NudeNet).\n\nThis fork exists since the original branch is no longer functional, as it relies upon downloading the classifier model from the github release page, which now requires the user to be logged in.\n\nThe emphasis of this fork is to maintain a simple working nudenet python package for easy use, primarily for classification purposes. I also removed the indecent images from the readme, as in my probably prude opinion they do not belong onto the page of a project that's about censoring it.\n\n\n**Classifier classes:**\n|class name | Description |\n|--------|:--------------:\n|safe | Image/Video is not sexually explicit |\n|unsafe | Image/Video is sexually explicit|\n\n\n\n# As Python module\n**Installation**:\n```bash\npip install --upgrade NudeNetv2\n```\n\n**Classifier Usage**:\n```python\n# Import module\nfrom NudeNetv2 import NudeClassifier\n\n# initialize classifier (downloads the checkpoint file automatically the first time)\nclassifier = NudeClassifier()\n\n# Classify single image\nclassifier.classify('path_to_image_1')\n# Returns {'path_to_image_1': {'safe': PROBABILITY, 'unsafe': PROBABILITY}}\n# Classify multiple images (batch prediction)\n# batch_size is optional; defaults to 4\nclassifier.classify(['path_to_image_1', 'path_to_image_2'], batch_size=BATCH_SIZE)\n# Returns {'path_to_image_1': {'safe': PROBABILITY, 'unsafe': PROBABILITY},\n# 'path_to_image_2': {'safe': PROBABILITY, 'unsafe': PROBABILITY}}\n\n# Classify video\n# batch_size is optional; defaults to 4\nclassifier.classify_video('path_to_video', batch_size=BATCH_SIZE)\n# Returns {\"metadata\": {\"fps\": FPS, \"video_length\": TOTAL_N_FRAMES, \"video_path\": 'path_to_video'},\n# \"preds\": {frame_i: {'safe': PROBABILITY, 'unsafe': PROBABILITY}, ....}}\n\n```\n\nThanks to [Johnny Urosevic](https://github.com/JohnnyUrosevic), NudeClassifier is also available in tflite.\n\n**TFLite Classifier Usage**:\n```python\n# Import module\nfrom nudenet import NudeClassifierLite\n\n# initialize classifier (downloads the checkpoint file automatically the first time)\nclassifier_lite = NudeClassifierLite()\n\n# Classify single image\nclassifier_lite.classify('path_to_image_1')\n# Returns {'path_to_image_1': {'safe': PROBABILITY, 'unsafe': PROBABILITY}}\n# Classify multiple images (batch prediction)\n# batch_size is optional; defaults to 4\nclassifier_lite.classify(['path_to_image_1', 'path_to_image_2'])\n# Returns {'path_to_image_1': {'safe': PROBABILITY, 'unsafe': PROBABILITY},\n# 'path_to_image_2': {'safe': PROBABILITY, 'unsafe': PROBABILITY}}\n\n```\n\nUsing the tflite classifier from flutter: **https://github.com/ndaysinaiK/nude-test** \n\n**Detector Usage**:\n```python\n# Import module\nfrom NudeNetv2 import NudeDetector\n\n# initialize detector (downloads the checkpoint file automatically the first time)\ndetector = NudeDetector() # detector = NudeDetector('base') for the \"base\" version of detector.\n\n# Detect single image\ndetector.detect('path_to_image')\n# fast mode is ~3x faster compared to default mode with slightly lower accuracy.\ndetector.detect('path_to_image', mode='fast')\n# Returns [{'box': LIST_OF_COORDINATES, 'score': PROBABILITY, 'label': LABEL}, ...]\n\n# Detect video\n# batch_size is optional; defaults to 2\n# show_progress is optional; defaults to True\ndetector.detect_video('path_to_video', batch_size=BATCH_SIZE, show_progress=BOOLEAN)\n# fast mode is ~3x faster compared to default mode with slightly lower accuracy.\ndetector.detect_video('path_to_video', batch_size=BATCH_SIZE, show_progress=BOOLEAN, mode='fast')\n# Returns {\"metadata\": {\"fps\": FPS, \"video_length\": TOTAL_N_FRAMES, \"video_path\": 'path_to_video'},\n# \"preds\": {frame_i: {'box': LIST_OF_COORDINATES, 'score': PROBABILITY, 'label': LABEL}, ...], ....}}\n\n\n\n```\n\n# Notes:\n- detect_video and classify_video first identify the \"unique\" frames in a video and run predictions on them for significant performance improvement.\n- V1 of NudeDetector (available in master branch of this repo) was trained on 12000 images labelled by the good folks at cti-community.\n- V2 (current version) of NudeDetector is trained on 160,000 entirely auto-labelled (using classification heat maps and various other hybrid techniques) images. \n- The entire data for the classifier is available at https://archive.org/details/NudeNet_classifier_dataset_v1\n- A part of the auto-labelled data (Images are from the classifier dataset above) used to train the base Detector is available at https://github.com/notAI-tech/NudeNet/releases/download/v0/DETECTOR_AUTO_GENERATED_DATA.zip\n\n\n",
"bugtrack_url": null,
"license": "GPLv3",
"summary": "An ensemble of Neural Nets for Nudity Detection and Censoring",
"version": "2.0.10",
"project_urls": {
"Homepage": "https://gitlab.com/christianbrinkmann/nudenetv2"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "58b34c9228d5b0c455838edce5d97010f0cc21d394da87a44c913cb6853c78aa",
"md5": "931adc60a36e44be111c7423e173b039",
"sha256": "2b2230a08c8a1430a7c016f03c066939ce70490c45ab881577d62969a2f3d27d"
},
"downloads": -1,
"filename": "NudeNetv2-2.0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "931adc60a36e44be111c7423e173b039",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6.0",
"size": 21011,
"upload_time": "2024-08-05T10:41:13",
"upload_time_iso_8601": "2024-08-05T10:41:13.912216Z",
"url": "https://files.pythonhosted.org/packages/58/b3/4c9228d5b0c455838edce5d97010f0cc21d394da87a44c913cb6853c78aa/NudeNetv2-2.0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "dce8db2beb7a93287c5f2b7edcfa4a7f08a5fda5817dc8eb446c168d74b808f6",
"md5": "a788b8b9518c6408d856a3121903cea4",
"sha256": "45c24e49fcd6274438a2e6ce76af788c9109639edf85aa14abdc217105323cc4"
},
"downloads": -1,
"filename": "NudeNetv2-2.0.10.tar.gz",
"has_sig": false,
"md5_digest": "a788b8b9518c6408d856a3121903cea4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6.0",
"size": 10358,
"upload_time": "2024-08-05T10:41:15",
"upload_time_iso_8601": "2024-08-05T10:41:15.441669Z",
"url": "https://files.pythonhosted.org/packages/dc/e8/db2beb7a93287c5f2b7edcfa4a7f08a5fda5817dc8eb446c168d74b808f6/NudeNetv2-2.0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-05 10:41:15",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "christianbrinkmann",
"gitlab_project": "nudenetv2",
"lcname": "nudenetv2"
}