I will explain how to use TokyoTechFes2015. I hope it will be helpful for you to practice the demo and improve the script.
Face image category discrimination is performed by machine learning.
By learning by changing the dataset
folder and below, any face image category can be determined.
First, clone from git.
git clone https://github.com/Arudori5001/TokyoTechFes2015.git
cd TokyoTechFes2015
ImageMagick It is an application to take a picture with a PC camera. It is available at http://cactuslab.com/imagemagick/ (Mac).
OpenCV http://qiita.com/zabeth129/items/f065f79b1322a82edb1d Please try to install by referring to.
python dependent library All are available on pip. Please note that the version of chainer is quite old.
pip install cv2==1.0
pip install pillow==2.9.7
pip install chainer==1.3.2
pip install matplotlib==1.4.3
Next, unzip dataset.zip
and you're ready to go.
unzip dataset.zip
The directory structure of the dataset
folder created by decompressing is as follows (only the folder is displayed).
$ tree dataset -d
dataset
├── Baysters
├── Buffealoes
├── Carp
├── Dragons
├── Eagles
├── Fighters
├── Giants
├── Hawks
├── Lions
├── Marines
├── Swallows
└── Tigers
I think the names of the 12 baseball teams are lined up. Each folder contains facial images of the players of each team.
If you make a prediction with the default settings, it will predict "Which team of the 12 teams the face in the given image is close to the face of the player".
What you expect can be changed by changing the dataset
folder and below (see below).
python bbteam_pred.py (path of the image you want to predict)
cannot detect!
.Here, as an example, suppose that the image ʻeagles_koyama.jpg already in the
sample` folder is the image taken in step 1, and you want to make a prediction.
By the way, this person is Koyama of Rakuten Eagles as the file name suggests.
python bbteam_pred.py sample/eagles_koyama.jpg
The captured image will appear on the screen. There is a frame around the face.
When you close the image of the displayed frame with the X button on the upper left, two new screens will appear (one may be hidden in the other window).
From the image above, we can see that Koyama is correctly predicted to be close to the face of the Eagles player, with a 95% certainty. The image below also shows confidence in teams other than Eagles. Besides the Eagles being 95%, the Carp seems to be about 5% confident.
By the way, the same output is also output to the console.
predicted categoriy : Eagles
certainty factor of predicted categoriy : 0.954637289047
certainty factors of each categories :
Baysters :
0.00%
Buffealoes :
0.00%
Carp :
4.51%
Dragons :
0.00%
Eagles :
95.46%
Fighters :
0.00%
Giants :
0.00%
Hawks :
0.02%
Lions :
0.00%
Marines :
0.00%
Swallows :
0.00%
Tigers :
0.00%
If you want to change what you expect, you need to change the dataset before training.
The dataset uses files with a fixed directory structure in the dataset
folder for learning and testing.
In the default case, as mentioned above, the directory structure is as follows.
$ tree dataset -d
dataset
├── Baysters
├── Buffealoes
├── Carp
├── Dragons
├── Eagles
├── Fighters
├── Giants
├── Hawks
├── Lions
├── Marines
├── Swallows
└── Tigers
The name of each directory directly under the dataset
folder (Baysters
, Buffealoes
, ...) represents the category name. By default, Baysters
has Baystars in one category.
Images are lined up directly under folders such as Baysters
.
$ tree dataset/Baysters
dataset/Baysters
├── 1000003_ss.jpg
├── 1000007_ss.jpg
├── 1000117_ss.jpg
├── 1000118_ss.jpg
├── 1000119_ss.jpg
...
These images are face images that belong to their respective categories.
Face images of Baystars players are lined up in Baysters
. Please change the directory structure referring to the above.
For example, if you want to judge whether it is a man or a woman, do as follows. Save the female face image in Female
and the male face image in Male
.
$ tree dataset -d
dataset
├── Female
└── Male
Learning is done with the following command.
python Learning.py (number of data used for learning)(Number of data used for testing)
By default, there are 680 images in the dataset. If you want to use 520 sheets for learning and 120 sheets for testing, do as follows.
python Learning.py 520 130
Recommended Posts