You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

newd

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

newd

Nudity detection through deep learning

0.0.4
Source
pipPyPI
Maintainers
1

Overview

newd analyzes images and identifies specific NSFW body parts with high accuracy. It can also optionally censor detected areas.

Installation

pip install newd

Usage

Basic Detection

from newd import detect

# Standard detection with default settings
results = detect('path/to/image.jpg')
print(results)

Advanced Options

# Faster detection with slightly reduced accuracy
results = detect('image.jpg', mode="fast")

# Adjust detection sensitivity
results = detect('image.jpg', min_prob=0.3)  # Lower threshold catches more potential matches

# Combine options
results = detect('image.jpg', mode="fast", min_prob=0.3)

Compatible Input Types

The detect() function accepts:

  • String file paths
  • Images loaded with OpenCV (cv2)
  • Images loaded with PIL/Pillow

Output Format

Detection results are returned as a list of dictionaries:

[
  {
    'box': [x1, y1, x2, y2],  # Bounding box coordinates (top-left, bottom-right)
    'score': 0.825,           # Confidence score (0-1)
    'label': 'EXPOSED_BREAST_F'  # Classification label
  },
  # Additional detections...
]

First-Time Use

When importing newd for the first time, it will download a 139MB model file to your home directory (~/.newd/). This happens only once.

Performance Notes

  • Standard mode: Best accuracy, normal processing speed
  • Fast mode: ~3x faster processing with slightly reduced accuracy

Censoring / Redacting Detected Regions

newd.censor() masks detected NSFW regions with solid black rectangles. Use it when you need to create a safe-for-work version of an image.

from newd import censor

# Censor all detected areas and write the result
censored_img = censor(
    'image.jpg',
    out_path='image_censored.jpg'  # file will be written to disk
)

# Only censor specific labels (e.g. exposed anus & male genitals)
selected_parts = ['EXPOSED_ANUS_F', 'EXPOSED_GENITALIA_M']
censored_img = censor(
    'image.jpg',
    out_path='image_censored.jpg',
    parts_to_blur=selected_parts
)

Function parameters:

ParameterTypeDescription
img_pathstr / PathSource image or path.
out_pathstr / Path, optionalDestination path; if omitted you can still obtain the result via the return value when visualize=True.
visualizebool, default FalseIf True, the censored numpy.ndarray image is returned for display (cv2.imshow, etc.).
parts_to_blurList[str], optionalRestrict censoring to given label names. When empty, all detected labels are censored.

If neither out_path nor visualize=True is supplied, the function exits early because there is nowhere to deliver the censored image.

Keywords

nsfw nudity detection computer vision ai

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts