A web server that checks if an image is NSFW.
It's just the NSFW crate (https://github.com/fyko/nsfw) with an actix web server.
| Function | Method | URL | Parameters | Return format | Returns |
|---|---|---|---|---|---|
| Check image from URL | GET | /check |
url as query parameter to read image from |
JSON | Classification result |
| Upload and check image | POST | /check |
image: Image as form file |
JSON | Classification result |
| Is image allowed (=not NSFW) | GET | /is_allowed |
url as query parameter to read image from |
JSON | boolean |
| Is image allowed (=not NSFW) | POST | /is_allowed |
image: Image as form file |
JSON | boolean |
- Classifications result example:
[
{ "metric": "Drawings", "score": 0.00016305158 },
{ "metric": "Hentai", "score": 4.0540633e-7 },
{ "metric": "Neutral", "score": 0.9997923 },
{ "metric": "Porn", "score": 0.0000022404822 },
{ "metric": "Sexy", "score": 0.000042102398 }
]See under examples/requests.html for an interactive example.
Warning
Many official sites protect their images from web scraping. A typical error for this would be Format error decoding Jpeg: Error parsing image. Illegal start bytes:506C. For the GET methods use sources you know you can use.
-
GET:
http://localhost:6969/check?url=https://picsum.photos/id/1/200/300 -
POST:
http://localhost:6969/checkwith form data -
GET:
http://localhost:6969/is_allowed?url=https://picsum.photos/id/1/200/300 -
POST:
http://localhost:6969/is_allowedwith form data
- Pull:
docker pull serveny/nsfw-check-server(Build available for arm & amd) - Run:
docker run -p 6969:6969 --rm --name ncs serveny/nsfw-check-server
- Download this repository and open terminal inside the repository directory
- Build:
docker build -t nsfw-check-server . - Run:
docker run -p 6969:6969 --rm --name ncs nsfw-check-server