How to use Visual Recognition to get LINE ID from a girl

Introduction

This article participates in Teratail's Bulemix Advent Calendar.

I just entered the war because I was investigating Bluemix to have pepper serve customers.

This time, by using Visual Recognition and pepper in IBM's Bluemix, Here's how to get your LINE ID from a girl.

Overview

Now, let's show you the flow of getting the LINE ID from a girl easily.

Pepper takes a picture
        ↓
Analyze photos with Visual Recognition
        ↓
Determine if you are a girl and 18-27 years old (at your own taste)
     ↓         ↓
    true       false
     ↓         ↓
Pepper asks for LINE ID

It's very easy to understand.

VisualRecognition From Catalog Page

Detects the meaning contained in the image content. Analyze scenes, objects, facial images, and other content. Choose an off-the-shelf default model or create your own custom type. Detects similar images in the collection. Create smart applications to analyze the image content of images and video frames and understand what is happening.

Hmm, what is it really like?

How to use

API Reference and [Demo Page](http://visual-recognition-demo.mybluemix. You can get a general idea from net /).

It seems that you can do it like this ↓

Input image example

obama.jpg

Output example
{
    "images": [
        {
            "faces": [
                {
                    "age": {
                        "max": 54,
                        "min": 45,
                        "score": 0.372036
                    },
                    "face_location": {
                        "height": 75,
                        "left": 256,
                        "top": 93,
                        "width": 67
                    },
                    "gender": {
                        "gender": "MALE",
                        "score": 0.99593
                    },
                    "identity": {
                        "name": "Barack Obama",
                        "score": 0.989013,
                        "type_hierarchy": "/people/politicians/democrats/barack
obama"
                    }
                }
            ],
            "image": "prez.jpg "
        }
    ],
    "images_processed": 1
}

Oh!

--Maximum / minimum age --The location of the face in the image

Is coming out. It seems that object detection etc. is performed except for the human face.

Request in Python

Pepper seems to work with Python, so it was written by a Python beginner. Please tell me if there is something strange.

# -*- coding: utf-8 -*-

import json
from os.path import join, dirname
from os import environ
from watson_developer_cloud import VisualRecognitionV3
import os.path

#Rewrite as appropriate
api_key = ''
image_name = ''

visual_recognition = VisualRecognitionV3('2016-05-20', api_key={api_key})

jsonData = visual_recognition.detect_faces(images_file=open({image_name}))

print(json.dumps(jsonData, indent=2))

faces = jsonData['images'][0]['faces'][0]

gender = faces['gender']['gender']
age_min = faces['age']['min']
age_max = faces['age']['max']

print(gender)
print(str(age_min) + '~' + str(age_max) + 'age')

#Let pepper do it
if 18 <= age_min and age_max <= 27:
	print('Tell me your LINE ID?')
else :
	print('Hi, my pepper')

There is only a feeling of being forced to take it out from json ...

As a test

Try putting values in api_key and image_name.

Input image (bride)

kanna.jpg

result

{
  "images": [
    {
      "image": "kanna.jpg ",
      "faces": [
        {
          "gender": {
            "gender": "FEMALE",
            "score": 0.880797
          },
          "age": {
            "max": 24,
            "score": 0.502411,
            "min": 18
          },
          "face_location": {
            "width": 140,
            "top": 66,
            "left": 107,
            "height": 160
          }
        }
      ]
    }
  ],
  "images_processed": 1
}

FEMALE
18~24-years-old
Tell me your LINE ID

Yeah, perfect. All you have to do is let pepper do it!

Let pepper do it

It gets longer & the bug in pepper hasn't been fixed (help) so in another article             sorry                ∨ pepper500.png

URL:

Finally

I participated in Teratail's Advent calendar using Bluemix's Visual Recognition. Regarding image processing, I was honestly surprised that it was very easy to handle.

I was also doing a commercial called pepper x watson, so I hope it will be easy to work with. I want a LINE ID to be completed by Christmas (seriously)

Tomorrow is an entry for tokutoku393.

Recommended Posts

How to use Visual Recognition to get LINE ID from a girl
How to get a string from a command line argument in python
How to get results from id in Celery
How to get a list of links from a page from wikipedia
How to use SWIG from waf
[Python] How to get & change rows / columns / values from a table.
How to extract the desired character string from a line 4 commands
How to get a job as an engineer from your 30s
How to create a clone from Github
How to get parent id with sqlalchemy
[TF] How to use Tensorboard from Keras
How to get a stacktrace in python
How to create a repository from media
How to get a value from a parameter store in lambda (using python)
How to get a namespaced view name from a URL (path_info) in Django
How to get a sample report from a hash value using VirusTotal's API
A simple example of how to use ArgumentParser
How to code a drone using image recognition
How to open a web browser from python
Study from Python Hour7: How to use classes
[Bash] Use here-documents to get python power from bash
How to generate a Python object from JSON
How to extract coefficients from a fractional formula
How to measure line speed from the terminal
How to create a Kivy 1-line input box
How to use loc / iloc / ix to get by specifying a column in CASTable
How to use Python-shell
How to create an article from the command line
How to use tf.data
How to use virtualenv
How to use Seaboan
How to use shogun
A memo of how to use AIST supercomputer ABCI
How to use Pandas 2
[Python] How to draw a line graph with Matplotlib
How to use Keras ~ From simple model generation to CNN ~
How to use Virtualenv
How to use numpy.vectorize
How to use pytest_report_header
How to get a logged-in user with Django's forms.py
How to use Azure Table storage from Django (PTVS)
A memorandum on how to use keras.preprocessing.image in Keras
How to use partial
How to use Bio.Phylo
How to use SymPy
How to use x-means
How to use IPython
How to use virtualenv
How to use Matplotlib
How to use iptables
How to use numpy
How to use TokyoTechFes2015
How to use venv
How to use dictionary {}
How to use Pyenv
How to use list []
How to use python-kabusapi
How to use OptParse
How to post a ticket from the Shogun API
How to take a captured image from a video (OpenCV)
How to use return