Skip to content

Commit

Permalink
0.3.13, ignore broken images
Browse files Browse the repository at this point in the history
  • Loading branch information
yaroslaff committed Apr 12, 2023
1 parent 295ffba commit 9b0deed
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@

# 0.3.11
- fixed --workdir / --resume in docker image

# 0.3.13
- Catch errors (and not crash) with broken images
- Load nudenet classifier only when needed


5 changes: 4 additions & 1 deletion bin/nudecrawler
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import requests
from dotenv import load_dotenv

import nudecrawler
from nudecrawler import Page, Unbuffered
from nudecrawler import Page, Unbuffered, load
from nudecrawler.page import get_processed_images, context_fields
from nudecrawler.version import version
from nudecrawler.cache import cache
Expand Down Expand Up @@ -434,6 +434,9 @@ def main():
print(f"# No cache file {stats['cache_path']}, start with empty cache")

# processing could start here

nudecrawler.load()

# --url1
if args.url1:
p = analyse(args.url1)
Expand Down
16 changes: 13 additions & 3 deletions build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,25 @@ echo mode: $MODE

# sudo docker build --build-arg VERSION=0.3.10 -t yaroslaff/nudecrawler:0.3.10 -f docker/Dockerfile .

VERSION=`python -c 'import nudecrawler.version; print(nudecrawler.version.version)'`
echo version: $VERSION

if [ "$MODE" == "dev" ]
then
echo build development mode
sudo docker build -t yaroslaff/nudecrawler:dev -f docker/DevDockerfile .
else
elif [ "$MODE" == "publish" ]
then
echo publish version $VERSION
python3 setup.py bdist_wheel sdist
twine upload dist/nudecrawler*$VERSION*

echo build version $MODE
echo === $MODE
sudo docker build --build-arg VERSION=$MODE -t yaroslaff/nudecrawler:$MODE -f docker/Dockerfile .
sudo docker build --build-arg VERSION=$VERSION -t yaroslaff/nudecrawler:$VERSION -f docker/Dockerfile .

echo === LATEST
sudo docker build --build-arg VERSION=$MODE -t yaroslaff/nudecrawler:latest -f docker/Dockerfile .
sudo docker build --build-arg VERSION=$VERSION -t yaroslaff/nudecrawler:latest -f docker/Dockerfile .
else
echo dev of publish?
fi
4 changes: 4 additions & 0 deletions nudecrawler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from .page import Page
from .remoteimage import RemoteImage
from .unbuffered import Unbuffered

def load():
remoteimage._load()

9 changes: 1 addition & 8 deletions nudecrawler/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,7 @@ def is_nude(self, url):
try:
self.do_detect_image(url)
except Exception as e:
if verbose.send_bugreports:
verbose.bugreport(page_url=self.url, image_url=url, detector=self.detect_image, exception=str(e))
else:
print("Please run with --bugreport option to send automatical and anonymous bugreport (I will not see your IP)")
print("Detector:", self.detect_image)
print("Problem page:", self.url)
print("Problem image:", url)
sys.exit(1)
printv("Broken image:", url)
return


Expand Down
17 changes: 11 additions & 6 deletions nudecrawler/remoteimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@

# detector_address = 'http://localhost:9191/api/v1/detect'

try:
from nudenet import NudeClassifier
print("Loading nudenet classifier....")
nudenet_classifier = NudeClassifier()
nudenet_classifier = None

def _load():
global nudenet_classifier
try:
from nudenet import NudeClassifier
print("Loading nudenet classifier....")
nudenet_classifier = NudeClassifier()
except ModuleNotFoundError:
nudenet_classifier = None


except ModuleNotFoundError:
nudenet_classifier = None

class RemoteImage:
def __init__(self, url):
Expand Down
2 changes: 1 addition & 1 deletion nudecrawler/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version="0.3.12"
version="0.3.13"

0 comments on commit 9b0deed

Please sign in to comment.