I tried scoring a transvestite contest using Face ++'s Detect API

This article is the 20th day article of Hands Lab Advent Calendar 2019


Self-introduction

My name is @jxxpsame and I joined the company in October of this year. I touch Unicage mystery technology every day.

I haven't output anything in a blog-like format like this since yahoo! Blog when I was in junior high school, so I'm nervous.


Overview

I used Face ++'s Detect API to score a crossdressing contest for a certain team.


Motivation

――Because there was a tendency to learn python with the team I belong to, I was studying ――Because you are a fan of a certain team --I wanted to try something using the API ―― ~~ I wish I could be happy because I only need my relatives ~~


environment


What is Face ++

The name of the face recognition platform developed by Megvii in Beijing. Face ++'s Detect API can authenticate faces and get various attributes. This time, we will score using the attribute called Beauty Score from among those attributes.

In addition, I referred to the following article for how to use Face ++. I analyzed Pairs with python ~ Face photo ~ Introduction of Face ++ API that detects the face when you send a photo and tells you the facial deviation value


Target of scoring

7 participants in a crossdressing contest of a certain team (Imamura Ishikawa Takahashi Yamashita Togoh Naoe Yokogawa) I used the image uploaded below. Instagram


Source

import requests
import json
import pprint

# API
# key:Person name value:Declare the URL of the image as a dictionary
url_dict = {'Person name:Image URL'}

#Number loop of target people
for img_data in url_dict.items():
    response = requests.post(
        'https://api-us.faceplusplus.com/facepp/v3/detect',
        {
            'api_key': "[Face++API Key obtained from]",
            'api_secret': "[Face++API Seacret obtained from]",
            'image_url': img_data[1], #Image URL
            'return_attributes': 'beauty' #Attributes you want to get
        }
    )

    #json plastic surgery
    json_dict = json.loads(response.text)
    print(img_data[0]) #Person name output
    pprint.pprint(json_dict['faces'][0]['attributes']['beauty'])

result

Please refer to the link of the Instagram post page for each player's name. Imamura {'female_score': 77.524, 'male_score': 78.338} Ishikawa {'female_score': 88.169, 'male_score': 84.546} Takahashi {'female_score': 79.26, 'male_score': 76.487} Yamashita {'female_score': 76.926, 'male_score': 78.077} Togoh {'female_score': 82.532, 'male_score': 81.738} Naoe {'female_score': 78.401, 'male_score': 79.444} Yokogawa {'female_score': 71.818, 'male_score': 69.508}

This time, we will hire the femele_score because it is a transvestite contest. ** The winner was Ishikawa! ** **


By the way

Compared with the actual ranking, it is as follows.

Actual ranking Face++Ranking given in
Ishikawa First place First place
Imamura 2nd place 5th place
Takahashi 3rd place 3rd place
Naoe 4th 4th
Yamashita 5th place 6th place
Togoh 6th place 2nd place
Yokokawa 7th place 7th place

reference 7 giants dressed as beautiful women! 1st place Shingo Ishikawa and others makeover

Except for Togoh and Imamura, the results were almost the same as the actual ranking. Face ++ Scary.


bonus

I was reluctant to use only the face of another person for sample data, so I measured the beauty score of my own face (25 years old, male).

'beauty': {'female_score': 67.239, 'male_score': 62.417},

Cusso is low ... Since femele_score was higher, I added gender (gender) and age (age) to the attributes to be acquired, and measured again. {'age': {'value': 34}, 'beauty': {'female_score': 67.253, 'male_score': 62.442}, 'gender': {'value': 'Female'}}

Everyone at Hands Lab. I look forward to working with you as a 34-year-old woman.


Hands Lab Advent Calendar 2019 Day 21 is @jnuank: clap :: clap:

Recommended Posts

I tried scoring a transvestite contest using Face ++'s Detect API
I tried face recognition using Face ++
I tried using the checkio API
I tried using Twitter api and Line api
I tried playing a ○ ✕ game using TensorFlow
I tried using YOUTUBE Data API V3
I tried drawing a line using turtle
I tried using UnityCloudBuild API from Python
I tried to make a Web API
I tried using pipenv, so a memo
I tried using the BigQuery Storage API
I tried using Remote API on GAE / J
I tried using the Google Cloud Vision API
I tried using Pythonect, a dataflow programming language.
I tried reading a CSV file using Python
I tried using a database (sqlite3) with kivy
I tried to make a ○ ✕ game using TensorFlow
I tried using parameterized
I tried using argparse
I tried using mimesis
I tried using anytree
I tried to notify the update of "Become a novelist" using "IFTTT" and "Become a novelist API"
I tried using aiomysql
I tried using Summpy
I tried using coturn
I tried using Pipenv
I tried hosting a Pytorch sample model using TorchServe
I tried using matplotlib
I tried using "Anvil".
I tried using Hubot
I tried using ESPCN
I tried using openpyxl
I tried using Ipython
I tried using PyCaret
I tried APN (remote notification) using Parse.com REST API
I tried using cron
I tried using the API of the salmon data project
I tried using ngrok
I tried using face_recognition
[Python] I tried running a local server using flask
I tried drawing a pseudo fractal figure using Python
I tried using Jupyter
I tried using PyCaret
I tried reading data from a file using Node.js.
I tried using Heapq
I tried using doctest
I tried using Python (3) instead of a scientific calculator
I tried using folium
I tried using jinja2
I tried using folium
PyTorch Learning Note 2 (I tried using a pre-trained model)
I tried using time-window
I tried to draw a configuration diagram using Diagrams
I tried to automate the construction of a hands-on environment using IBM Cloud's SoftLayer API
I tried to search videos using Youtube Data API (beginner)
[Professional competition] I tried At Coder Beginner Contest 175 (A ~ C)
I tried face recognition of the laughter problem using Keras.
I tried hosting a TensorFlow deep learning model using TensorFlow Serving
I tried using Tensorboard, a visualization tool for machine learning
I tried to automate [a certain task] using Raspberry Pi
[Python] I tried collecting data using the API of wikipedia