lucyparsons / OpenOversight

Police oversight and accountability through public data 👮
https://openoversight.com
GNU General Public License v3.0
237 stars 79 forks source link

Automatic face detection #6

Open redshiftzero opened 8 years ago

redshiftzero commented 8 years ago

Do face detection automatically with images submitted by users and those that are scraped from social media

redshiftzero commented 8 years ago

Openface is a good solution for this, e.g. https://cmusatyalab.github.io/openface/usage/#api-documentation

JoshuaOpolko commented 7 years ago

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.

redshiftzero commented 7 years ago

Let's use the code added in PR #112 to get this into our workflow. Requires #5.

redshiftzero commented 6 years ago

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

redshiftzero commented 6 years ago

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

redshiftzero commented 6 years ago

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