I examined Yuki Kashiwagi's facial features to understand TensorFlow and CNN (Convolutional Neural Network). I'm not a fan of Yuki Kashiwagi, but I'm not familiar with idols and actresses, so the reason I chose the person was that I came up with the face of a person who seems to have characteristics. It focuses on the learning part using TensorFlow Part 2 and explains the judgment part Part 2 Continue to .com / FukuharaYohei / items / 3f26bfe71fdb5720ce7e).
Yuki Kashiwagi's ** feature for TensorFlow was not the nose **. To be honest, I wasn't sure what kind of features TensorFlow judges. In order to narrow down the features, I tried to build a learning model to make the judgment method somewhat easy to understand without trying to improve the judgment accuracy. I'm looking at a model with 68% accuracy against the test data (the low accuracy is often a problem with the model I assembled and the training data). The image of the result of the second layer pooling process is predictive and makes such a difference. However, since it is the result of a beginner's execution, if an excellent person assembles it, it may be possible to make something like a highly accurate "nose judge".
We conducted this facial feature survey according to the following flow.
We use the Bing Image Search API to search and collect images. The total number of collected images is 2471, and the breakdown is as shown in the figure below. I searched for actresses and idols who seem to have many images. See the article Calling Bing Image Search API v5 from Python to collect images for run-time code and instructions.
"Face detection + cutout" was performed using OpenCV, and "false positive removal" was performed manually. In addition to "1. Image search", the following number of images are processed. The face detection rate is about 60% to 70%. I wrote the lessons learned in this part in the article "Tips for efficiently detecting faces with large numbers of images with openCV". Please note that manual "false positive removal" takes a long time.
I'm learning with TensorFlow. It is almost the same model as the tutorial for TensorFlow experts Deep MNIST for Experts. For the explanation, see the article ["[Explanation for beginners] TensorFlow Tutorial Deep MNIST"] Please refer to (http://qiita.com/FukuharaYohei/items/0aef74a0411273705512). For the image of the "Conclusion" part, the image of the pooling process result of the second layer is taken out using TensorBoard (Article ["[Introduction to TensorBoard: image] TensorFlow Image processing is visualized to deepen understanding"](http: //qiita.com/FukuharaYohei/items/fae6896e041235033454)).
I wish I had done my best to create teacher data, but each data looks like this. To be honest, it's terrible, even if accuracy isn't the goal. If you adjust hyperparameters etc. on the right side of the table as "For accuracy", it will be a little better.
item | Contents | Remarks | For accuracy |
---|---|---|---|
Teacher data | Approximately 1600 sheets(About 600 of them are correct(Yuki Kashiwagi)image) | there's only a little··· | Approximately 2500 sheets |
Training data | Approximately 1350 at random | Randomly picked up with EXCEL function | Approximately 2250 sheets |
test data | Approximately 250 at random | Randomly picked up with EXCEL function | About 250 sheets |
Correct answer rate for training data | 74% | Low··· | 85% |
Correct answer rate for test data | 70% | Also low ... | 84% |
The figure below shows the transition of the correct answer rate and error in learning. For output to TensorBoard, refer to the article "[Introduction to TensorBoard] Visualize TensorFlow processing to deepen understanding".
Learning will be explained in detail in the second part, including the code.
For image judgment, face detection + cropping using OpenCV and image judgment using TensorFlow are continued in the form shown in the figure below. The learned parameters saved in the process of "3. Learning" are used when judging the image.
The execution environment is as follows.
type | version |
---|---|
OS | Windows 10 64bit Pro |
Anaconda | Anaconda 4.4.0 |
Python | Python3.5 |
TensorFlow | TensorFlow 1.3 |
OpenCV | OpenCV 3.3 |
Recommended Posts