arnaldog12 / Deep-Learning

Study and implementation about deep learning models, architectures, applications and frameworks
84 stars 45 forks source link

Larger Data set #9

Closed ZaidSaid12 closed 3 years ago

ZaidSaid12 commented 3 years ago

i am so grateful for your work in this model, but can i get access to a larger dataset? or can you explain how did you create the toy database, as it's not available to get more face images and convert them to facial encodings etc.. thanks in advance

arnaldog12 commented 3 years ago

Hi, @ZaidSaid12 Thank you for the interest. You can take a look at my Medium Article for more details.

ZaidSaid12 commented 3 years ago

@arnaldog12 First of all, thanks for your quick response, greatly appreciated I've already read your article before checking the code, you mentioned that you used amazon face detection API, so can you please provide the code for generating the dataset {samples.pkl}, i already followed the hyper link of amazon's api

ZaidSaid12 commented 3 years ago

I intend to increase the accuracy of this model, but it seems i might need a larger dataset

arnaldog12 commented 3 years ago

Hi, @ZaidSaid12 I'm sorry. I looked for the code that generates the dataset this weekend, but I don't have it anymore.

but, I still have the code to work with API. I don't know if still works, but you can try:

import boto3
class AmazonAPI():
    def __init__(self, region='us-east-2'):
        self._api = boto3.client("rekognition", region)

    def classify_image(self, image_file):
        return self._api.detect_labels(Image={'Bytes': open(image_file, 'rb').read()})

    def detect_faces(self, image_file):
        return self._api.detect_faces(Image={'Bytes': open(image_file, 'rb').read()})

    def to_rects(self, json_res, img_size=None):
        assert(img_size), "You must provide img_size as (height, width)"
        assert(len(img_size) == 2), 'img_size must be (height, width)'

        height, width = img_size
        rects = []
        for details in json_res['FaceDetails']:
            rect = details['BoundingBox']
            rect_x, rect_y = int(rect['Left']*width), int(rect['Top']*height)
            rect_w, rect_h = int(rect['Width']*width), int(rect['Height']*height)
            rects.append(Rect(rect_x, rect_y, rect_w, rect_h))
        return rects

and the code to parse Amazon responses:

def parser_amazon(json_file):
    pose_dict = json_file['FaceDetails'][0]['Pose']
    return pose_dict['Roll'], pose_dict['Pitch'], pose_dict['Yaw']

I hope it helps!

arnaldog12 commented 3 years ago

@ZaidSaid12, just to make sure you get the edited code.

ZaidSaid12 commented 3 years ago

@arnaldog12 Thank you, greatly appreciated