diff --git a/src/api.py b/src/api.py index f9ae1b8..330b496 100644 --- a/src/api.py +++ b/src/api.py @@ -1,6 +1,6 @@ from fastapi import FastAPI, UploadFile, Response import gc -from . import blur +from . import blur_monolith as blur import json app = FastAPI() diff --git a/src/blur/blur.py b/src/blur/blur.py index 5566bdf..0ab0f78 100755 --- a/src/blur/blur.py +++ b/src/blur/blur.py @@ -10,7 +10,7 @@ jpeg = turbojpeg.TurboJPEG() -crop_save_dir = '/data/crops' +crop_save_dir = '/tmp/sgblur/crops' def blurPicture(picture, keep): """Blurs a single picture by detecting faces and licence plates. diff --git a/src/blur.py b/src/blur_monolith.py similarity index 98% rename from src/blur.py rename to src/blur_monolith.py index 42b5e87..348d774 100755 --- a/src/blur.py +++ b/src/blur_monolith.py @@ -14,7 +14,7 @@ model.names[1] = 'plate' model.names[2] = 'face' -crop_save_dir = '/data/crops' +crop_save_dir = '/tmp/sgblur/crops' def blurPicture(picture, keep): """Blurs a single picture by detecting faces and licence plates. @@ -36,7 +36,10 @@ def blurPicture(picture, keep): if 'SGBLUR_GPUS' in os.environ: gpu = pid % int(os.environ['SGBLUR_GPUS']) else: - gpu = pid % torch.cuda.device_count() + if torch.cuda.device_count() > 0: + gpu = pid % torch.cuda.device_count() + else: + gpu = None # copy received JPEG picture to temporary file tmp = '/dev/shm/blur%s.jpg' % pid