Open redshiftzero opened 8 years ago
Openface is a good solution for this, e.g. https://cmusatyalab.github.io/openface/usage/#api-documentation
I've started to use the Google Vision API to automatically remove the images that have no faces. The first batch has been uploaded to cpd_pictures/Memorial.Parade.faces A minority of the photos have not been uploaded it seems because they were over the 4MB limit for using the API. I'll resize them and upload too. So far approx 1000 images have been succesfully detected. It takes a few seconds per image roughly. I'm using the simple face detection script, no ocr or other objects recognized yet.
Let's use the code added in PR #112 to get this into our workflow. Requires #5.
Initially we'd want to:
Note that what to do with the face depends on whether it is of an officer or not. If it is, then it should be extracted for identification, else, it should be blurred (with the original image kept unmodified).
Related to: #8
Once a photo is uploaded, we should submit a face detection task to a worker queue which will do:
rekog_client=boto3.client('rekognition')
response = client.detect_faces(
Image={'S3Object':{'Bucket':current_app.config['S3_BUCKET_NAME'],
'Name':s3_path}},Attributes=['ALL'])
The number of faces detected in the image will be the len(response['FaceDetails'])
.
For each detected face, we can save the bounding box in the database for display when the image is accessed again later by volunteers, e.g. here's the bounding box for the first face in a test officer image I uploaded to S3:
response['FaceDetails'][0]['BoundingBox']
{u'Width': 0.16750000417232513, u'Top': 0.34427767992019653, u'Left': 0.5299999713897705, u'Height': 0.25046902894973755}
I was thinking of modifying the Face
table to store this information, but maybe adding another table AutoFace
is the way to go here
there's a working prototype in branch face-detection
(you gotta install redis in the dev env to test it): upon images being submitted, a task is submitted to a worker queue, which detects faces in the image using Rekognition and adds them to the database. Next step is to display the faces on the images on the volunteer classification/identification pages
Do face detection automatically with images submitted by users and those that are scraped from social media