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:
| Parameter | Type | Description |
|---|---|---|
img_path |
str / Path | Source image or path. |
out_path |
str / Path, optional | Destination path; if omitted you can still obtain the result via the return value when visualize=True. |
visualize |
bool, default False |
If True, the censored numpy.ndarray image is returned for display (cv2.imshow, etc.). |
parts_to_blur |
List[str], optional | Restrict 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.
Metadata
Release files for newd 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| newd-0.0.4.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| newd-0.0.4-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 16.8 kB
Release files / newd-0.0.4.tar.gz
| Download URL | newd-0.0.4.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba1e696a8bc3fcf1167dd708ddcfa3dffb0db787872a37e5ba363140dcd187c5
|
|
BLAKE2b-256 checksum How to use checksums |
b0607ea26d2c182dea8f5c5ac91db47101ad75e39d226a1e233e30320bb7fa90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.11
|
Release files / newd-0.0.4-py2.py3-none-any.whl
| Download URL | newd-0.0.4-py2.py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
bb4c8b5633f980a9a3afdf0a47094d57aacb097b0b822b9cb548c8f7693fc215
|
|
BLAKE2b-256 checksum How to use checksums |
6a378de45697a77827bcd96c886a0013c0a38a5967ce5aa0ed0261e685806652
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.11
|