Ejemplo n.º 1
0
def find_images(images, num_images):  #save_directory,
    facepp = FacePP(api_key='prYP6L8GFA06ycwOYdRGpOowEOLWrhr5',
                    api_secret='aCrsKLu_tnC-3srCI4B2ID6NrXhV1WA_',
                    url='https://api-us.faceplusplus.com')
    genderDic = {}
    ethnicityDic = collections.Counter()
    genderDic["Male"] = 0
    genderDic["Female"] = 0
    print("analyzing pictures")

    for i, (url, image_type) in enumerate(images):
        print("Next image!")
        print("Url: " + url)
        try:
            image = facepp.image.get(image_url=url,
                                     return_attributes=['gender'])
            print("True value: " + image.faces[0].gender['value'])
            if (image.faces[0].gender['value'] == "Male"):
                print("Stored male")
                genderDic["Male"] += 1
            elif (image.faces[0].gender['value'] == "Female"):
                print("Stored female")
                genderDic["Female"] += 1
            ethnicityDic[image.faces[0].ethnicity['value']] += 1

        except Exception as e:
            logger.exception(e)

    updateSheets(genderDic, ethnicityDic)
Ejemplo n.º 2
0
def main():
    facepp = FacePP(api_key='prYP6L8GFA06ycwOYdRGpOowEOLWrhr5',
                    api_secret='aCrsKLu_tnC-3srCI4B2ID6NrXhV1WA_',
                    url='https://api-us.faceplusplus.com')
    parser = argparse.ArgumentParser()
    parser.add_argument('-s', '--search', default='JohnSmith', type=str)
    parser.add_argument('-n', '--num_images', default=1, type=int)
    args = parser.parse_args()
    run_program(args.search, args.num_images)
Ejemplo n.º 3
0
from facepplib import FacePP

facepp = FacePP(api_key='CD6RZlJuI8PostJBrrnkvGngb-gnSJbs',
                api_secret='lHp0GrPsZvxMHdgYUtEiAExZ_JFPKia4')
url = 'https://api-us.faceplusplus.com/facepp/v3/detect'
image_url = 'https://www.faceplusplus.com/scripts/demoScript/images/demo-pic6.jpg'
image = facepp.image.get(image_url=image_url,
                         return_attributes=['smiling', 'age'])
print(image.image_id)
Ejemplo n.º 4
0
# define global variables
face_detection = ""
faceset_initialize = ""
face_search = ""
face_landmarks = ""
dense_facial_landmarks = ""
face_attributes = ""
beauty_score_and_emotion_recognition = ""
#####
api_key = 'xQLsTmMyqp1L2MIt7M3l0h-cQiy0Dwhl'
api_secret = 'TyBSGw8NBEP9Tbhv_JbQM18mIlorY6-D'

# create a logo of app by using iteration,
# unicode and emoji module-------------
# call api
app_ = FacePP(api_key=api_key, api_secret=api_secret)
funcs = [
    face_detection,
    #face_comparing_localphoto,
    #face_comparing_websitephoto,
    faceset_initialize,
    face_search,
    face_landmarks,
    dense_facial_landmarks,
    face_attributes,
    beauty_score_and_emotion_recognition
]


# define transfer function for transfer images to ftp server
def transfer(frame):
from facepplib import FacePP
import os
import sys, traceback
import csv
from datetime import datetime
import inspect
import boto3

API_KEY = '<Insert-API-Key-here>'
API_SECRET_KEY = '<Insert-API-Secret-Key-here>'
BUCKET_NAME = '<Insert-S3-bucket-name-here>'
S3_URL = "https://<Insert-S3-bucket-name-here>.s3.eu-west-2.amazonaws.com/"

facepp = FacePP(api_key=API_KEY, api_secret=API_SECRET_KEY)


def collect_urls():
    image_urls = []
    s3 = boto3.resource('s3')
    nimstim_bucket = s3.Bucket(BUCKET_NAME)
    for file in nimstim_bucket.objects.all():
        image_urls.append(S3_URL + file.key)
    return image_urls


def log_output(image_url, content):
    content = str(content)
    name = get_file_name(image_url).split(".")[0]
    print("The name is " + name)
    name = "face++_logs/[{}] {}.txt".format(datetime.now(), name)
    print(name)
Ejemplo n.º 6
0
from database import mydatabase
from facepplib import FacePP
import threading, time
import math

dbms = mydatabase.MyDatabase(mydatabase.SQLITE, dbname='mydb.sqlite')
# dbms.create_db_tables()

facepp = FacePP(api_key='g06BZoz_VFEJxvzaLPTlQI-ZsbhCbRbU',
                api_secret='EHoHJiGyJn-IoeHNBMGNlUFBKhoLmyci')


def get_face_Images():

    lop = math.ceil(3635 / 2)
    x = 1
    counter = 1
    for i in range(lop):
        # ----
        query = "SELECT * from imagelist where id Between {} and {};".format(
            x, counter * 2)
        x = counter * 2 + 1
        counter = counter + 1
        imageList = dbms.get_all_data('', query)
        # imageList = dbms.get_all_data('imagelist','')
        # print(imageList)
        for img in imageList:
            # print(image)
            image = facepp.image.get(image_file=img[1],
                                     return_attributes=[
                                         'gender', 'smiling', 'age', 'emotion',
Ejemplo n.º 7
0
def imageUpload(request):

    if request.method == "POST":

        # Get files
        image = request.FILES['image']

        # Save file
        file_name = default_storage.save("Users\\DPS\\" + image.name, image)

        # Openning file process
        filey = default_storage.open(file_name)
        current_path = os.path.dirname(__file__)
        relative_path = path.uploadedImage() + str(image.name)
        abs_path = os.path.join(current_path, relative_path)

        # Opening image from the absolute path
        image_data = open(abs_path, "rb")

        # Converting image to base64 string
        converted_string = "data:image/jpeg;base64, " + str(
            base64.b64encode(image_data.read()).decode('utf-8'))

        # Absolute path for checking image
        relative_path = path.avgImgCheckPath()
        absolute_path_check = os.path.join(current_path, relative_path)

        vals = list()
        characters = cl.checkListAvengers(absolute_path_check)
        for character in characters:
            # Absolute path for showing image
            relative_path = path.avgImgShowPath() + str(character[1])
            absolute_path_show = os.path.join(current_path, relative_path)

            new_image = open(absolute_path_show, "rb")

            app_ = FacePP(api_key=sc.getAPIKey(), api_secret=sc.getAPISecret())
            image1 = "https://media.geeksforgeeks.org/wp-content/uploads/20200216230843/img45.jpg"
            image2 = 'https://media.geeksforgeeks.org/wp-content/uploads/20200216224036/img210.jpg'
            vals.append(cp.face_comparing(app_, image1, image2))
        vals = json.dumps(vals)
        return HttpResponse(str(vals))
    else:
        print("Smething went wrong")
        return HttpResponse("Something went wrong")


#         app_ = FacePP(api_key = api_key,
#                       api_secret = api_secret)
#         funcs = [
#             face_detection,
#             face_comparing_localphoto,
#             face_comparing_websitephoto,
#             faceset_initialize,
#             face_search,
#             face_landmarks,
#             dense_facial_landmarks,
#             face_attributes,
#             beauty_score_and_emotion_recognition
#         ]

#         # Pair 1
#         image1 = 'Image 1 link'
#         image2 = 'Image 2 link'
#         face_comparing(app_, image1, image2)