Created
August 10, 2020 00:32
-
-
Save geek-at/0a94f28654f1e6d8fbacc0e403488bdc to your computer and use it in GitHub Desktop.
Bash example for nsfw-categorize.it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Test image1.jpg | |
curl -s -F "image=@image1.jpg" "https://nsfw-categorize.it/api/upload" | |
# Let the API analyze an externally hosted image | |
curl -s "https://nsfw-categorize.it/api/upload?url=https://i.imgur.com/wubvFTM.jpeg" | |
# Classify all images in a folder and save results to files | |
for filename in /home/user/photos/*.jpg; do | |
photo=$(basename $filename) | |
result=$(curl curl -s -H "NSFWKEY:your-key-here" -s -F "image=@/home/user/photos/$photo" "https://nsfw-categorize.it/api/upload" | jq -r .data.classification ) | |
echo "$photo is classified as $result" | |
if [ "$result" = "porn" ]; then | |
echo "/home/user/photos/$photo" >> porn.txt | |
elif [ "$result" = "nsfw" ]; then | |
echo "/home/user/photos/$photo" >> nsfw.txt | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment