コード例 #1
0
def get_galleries_names_object():
    validate_settings()

    auth_headers = {'app_id': settings.app_id, 'app_key': settings.app_key}

    response = requests.post(_galleries_list_url, headers=auth_headers)
    json_response = response.json()
    if response.status_code != 200 or 'Errors' in json_response:
        raise exceptions.ServiceRequestError(response.status_code,
                                             json_response, None)

    return json_response['gallery_ids']
コード例 #2
0
ファイル: detect.py プロジェクト: krishamehta/refugee
def detect_face(url=None, file=None, additional_arguments={}):
    validate_settings()
    validate_file_and_url_presence(file, url)

    auth_headers = {
        'app_id': settings.app_id,
        'app_key': settings.app_key
    }
    payload = _build_payload(url, file, additional_arguments)

    response = requests.post(_detect_base_url, json=payload, headers=auth_headers)
    json_response = response.json()
    if response.status_code != 200 or 'Errors' in json_response:
        raise exceptions.ServiceRequestError(response.status_code, json_response, payload)

    return json_response
コード例 #3
0
def get_gallery_object(gallery_name):
    validate_settings()
    _validate_gallery_name(gallery_name)

    auth_headers = {'app_id': settings.app_id, 'app_key': settings.app_key}

    payload = {'gallery_name': gallery_name}
    response = requests.post(_gallery_base_url,
                             json=payload,
                             headers=auth_headers)
    json_response = response.json()
    if response.status_code != 200 or 'Errors' in json_response:
        raise exceptions.ServiceRequestError(response.status_code,
                                             json_response, payload)

    return KairosFaceGallery(gallery_name, json_response['subject_ids'])
コード例 #4
0
ファイル: remove.py プロジェクト: krishamehta/refugee
def remove_face(subject_id, gallery_name):
    validate_settings()
    _validate_arguments_presence(gallery_name, subject_id)

    auth_headers = {'app_id': settings.app_id, 'app_key': settings.app_key}

    payload = _build_payload(gallery_name, subject_id)

    response = requests.post(_remove_base_url,
                             json=payload,
                             headers=auth_headers)
    json_response = response.json()
    if response.status_code != 200 or 'Errors' in json_response:
        raise exceptions.ServiceRequestError(response.status_code,
                                             json_response, payload)

    return json_response
コード例 #5
0
def remove_face(subject_id, gallery_name):
    validate_settings()
    _validate_arguments_presence(gallery_name, subject_id)

    auth_headers = {
        'app_id': settings.app_id,
        'app_key': settings.app_key
    }

    payload = _build_payload(gallery_name, subject_id)

    response = requests.post(_remove_base_url, json=payload, headers=auth_headers)
    json_response = response.json()
    if response.status_code != 200 or 'Errors' in json_response:
        raise exceptions.ServiceRequestError(response.status_code, json_response, payload)

    return json_response