[PYTHON] Memorandum of means when you want to make machine learning with 50 images

Overview

I'm a super beginner in machine learning, so I came up with a web application that uses images. "If you use deep learning, you can do something about it ~" I thought that it didn't work, and I consulted with a famous machine learning senior in the company.

What I want to do this time

** A website where you can answer when asked "Who is your favorite type of entertainer?" At a drinking party **

Required UX

  1. A user visits a website
  2. Images of about 50 models will appear, so select and enter one of "Type", "Slightly like", "Normal", "Slightly weak", and "Very weak" for each one.
  3. From the result, you will see a photo of the celebrity's face that the user will like and the words "You will like this one".
  4. ** At the drinking party, you can answer "I was told that Maki Horikita was the type of artificial intelligence" **

Don't you really want it? That standard question at a drinking party has been quite troublesome since I became a member of society, so I really want you to be able to answer like a story like this.

Pre-verification

For the time being, I had some knowledge about deep learning, so what I thought about to achieve this requirement was

--Deep learning for "model image" so that the judgment result is "5 grade evaluation of users such as type and weakness"

By that

――You can predict which of the five levels will be evaluated for the "image of a celebrity".

It was to create a learning model like this. However, if there are tens of thousands of learning data such as JINS BRAIN, the prediction accuracy will increase again, but this time, "about 50" Since it is learned from "the image of the model of", the number of sheets was too small and the prediction could not be made at all.

And

When I commented in the in-house daily report that "I am suffering because the learning accuracy does not improve with 50 sheets", I received comments from senior engineers who are knowledgeable about AI in the company and synchronization, so I paired the contents with my impressions I would like to summarize it. It's just a memo, so there is nothing in particular, but I hope that similar machine learning super beginners can see it and realize the depth of this world.

Image padding

First of all, it is not a fundamental solution to this case, but if the number of images is small, the standard technique is to generate similar images in a programmable manner and inflate them. http://qiita.com/bohemian916/items/9630661cd5292240f8c7 You can learn by changing the contrast by referring to this article. However, relying too much on padding can easily lead to overfitting and should not be overfitted.

Addition of features

I also received such a comment.

If it is determined by a simple DNN implementation, 50 sheets is not possible. However, the accuracy can be improved even with a small amount of data by adding not only images but also features that can be easily inserted as training data. For example, if you want to determine whether it is an apartment, an apartment, or a detached house from a photograph of the exterior of the building, but only 50 image data can be collected, the image data and the number of floors and amount of the building can be taken separately. Add the amount to increase the accuracy.

I see, in this example, the features are black hair or big eyes.

I think there is a way to extract feature points from an image and process it (put it in a classifier such as SVM).

Hmmm, there are other ways to classify images besides DNN. Of course, I've asked about SVM, but I personally thought that it was in the development of artificial intelligence and was a legacy of the past.

Use image classification techniques other than machine learning

For example, if it is something like "If a certain logo is included, it will be unique", I think that sift, surf features may be used. Personally, I feel that "image recognition = machine learning" has stopped thinking.

That's right. There is also a view that machine learning is not necessary if you can explain in words what kind of features a human face has. The sirf and surf features were new to me. Reference: https://www.slideshare.net/lawmn/siftsurf

Collaborative filtering

Since what we are trying to do this time is to output people who will like it in the future based on past input, we received the opinion that it is close to the recommendation sensuously. ▼ Reference http://qiita.com/ynakayama/items/59beb40b7c3829cc0bf2

However, when it comes to collaborative filtering, we make predictions by referring to the input information of other people, so we decided that it did not meet the service requirements this time. For example, in a music app, after some time has passed since its release, users who like this song should generally like this song as well.

Principal component analysis

When it came to this area, I didn't really get my head around. However, I will make a note for the time being. http://blog.amedama.jp/entry/2017/04/02/130530 I don't have a head, but is it a mechanism that can reduce the dimension of multidimensional data and reduce the loss of meaning as much as possible? If this can be done, the features of the image can be expressed in two dimensions ...?

Factorization Machines http://qiita.com/wwacky/items/b402a1f3770bee2dd13c ???? It's no longer clear whether it will be used for any purpose. .. .. I will ask you again. I can't understand it once. .. ..

Cluster analysis (K-means method)

http://pythondatascience.plavox.info/scikit-learn/%E3%82%AF%E3%83%A9%E3%82%B9%E3%82%BF%E5%88%86%E6%9E%90-k-means This is what came to me when I thought about the service specifications this time. It seems to be classified as unsupervised learning It seems that it is possible to classify the image of the model and find out in advance which image the celebrity's image is close to by this method. In other words, you can think about which of the classes is closest to your taste in the image entered by the user and output it. Rather than creating a trained model, it feels like a really simple classification.

It's different from the image I originally thought, but if the technology that can classify images can be realized other than deep learning, there seems to be no need to use deep learning.

The problem is how to classify this, but ... Is it just like using the pixel value of an image as a value, or evaluating skin color, hair color, eye size, etc. and quantifying them to classify them?

Reinforcement learning

http://qiita.com/PonDad/items/2410c55b2d21e7cad7bc I feel that reinforcement learning is also a relatively possible method. Load the image, and if it is "type", give a reward, and if it is "not good", give a punishment. However, I feel that the purpose is different, so I concluded that there is no reason to adopt this rather than cluster analysis.

Naive bayes classifier

http://qiita.com/ynakayama/items/ca3f5e9d762bbd50ad1f It seems that people who like this model will learn that there is a high probability that they will also like this model. However, although this can be used when growing the service, I feel that it cannot be introduced in the initial release. It was similar to collaborative filtering.

Image classification

As an extension of the idea of clustering, even the similarity of the images is calculated, and the similarity between the image of the model for the sample and the face of the celebrity is calculated in advance, and it is the most similar to the user's input. The idea came up that we should choose a celebrity with a high total degree. I feel like I can do it after reading the following articles.

--Face recognition without deep learning 3 CNN edition --Blog (Hatena branch office) programmed by NEET http://suzuichiblogpg.hatenadiary.jp/entry/2016/10/31/220809

――Let's judge "regular" from the face image using AI! | Future Tech Blog --Future Architect https://future-architect.github.io/articles/20170526/ #future_architect @future_techblog

--Calculate image similarity with Python + OpenCV by @best_not_best on @Qiita http://qiita.com/best_not_best/items/c9497ffb5240622ede01

In particular, the article that classifies Shiba Inu with Python + OpenCV seems to be close to the use case of finding a favorite entertainer from a human face photo.

--Deep Learning that permeates recommendations: An overview of the latest algorithms from practical examples of major services | DeepAge https://deepage.net/deep_learning/2016/09/26/recommend_deeplearning.html

It feels like a quick search, and the articles around here are likely to be helpful.

Conclusion

I thought that there was only deep learning, but when I heard various means, it seems most realistic to use an algorithm that finds the similarity of images.

Impressions

I was surprised that there were so many ways to do it because I didn't have enough means. Although I knew the name and outline of some of them, I decided that it was a fossilized technology in the process of making AI, but I will keep in mind that it is also the right person in the right place. I did.

Recommended Posts

Memorandum of means when you want to make machine learning with 50 images
Personal best practice template to use when you want to make MVP with Flask
Settings when you want to run python-mecab with travis
When you want to filter with Django REST framework
The first step of machine learning ~ For those who want to implement with python ~
Solution when you want to use cv_bridge with python3 (virtualenv)
[Django] A memorandum when you want to communicate asynchronously [Python3]
[AWS] What to do when you want to pip with Lambda
For those who want to start machine learning with TensorFlow2
How to increase the number of machine learning dataset images
When you want to register Django's initial data with relationships
Make a note of what you want to do in the future with Raspberry Pi
A site to see when you want to read a machine learning paper but it seems difficult
When you want to print to standard output with print while testing with pytest
When you want to save the result of the callback function somewhere
[Introduction to StyleGAN] Unique learning of anime with your own machine ♬
When you want to send an object with requests using flask
When you want to adjust the axis scale interval with APLpy
I tried to make Othello AI with tensorflow without understanding the theory of machine learning ~ Introduction ~
I tried to make Othello AI with tensorflow without understanding the theory of machine learning ~ Implementation ~
Memorandum of Understanding when migrating with GORM
[Introduction to machine learning] Until you run the sample code with chainer
When you want to use it as it is when using it with lambda memo
Gist repository to use when you want to try a little with ansible
When you want to replace a column with a missing value (NaN) column by column
Python Note: When you want to know the attributes of an object
When you want to change the HTTP headers of Flask's test client
I want to solve the problem of memory leak when outputting a large number of images with Matplotlib
I tried to make Othello AI with tensorflow without understanding the theory of machine learning ~ Battle Edition ~
[Python] Easy introduction to machine learning with python (SVM)
Classification of guitar images by machine learning Part 1
A memorandum to make WebDAV only with nginx
Machine learning starting with Python Personal memorandum Part2
Machine learning starting with Python Personal memorandum Part1
I want to display multiple images with matplotlib.
I want to make a game with Python
When you want to update the chrome driver.
[OpenCV] When you want to check if it is read properly with imread
Machine learning beginners tried to make a horse racing prediction model with python
[Python] Collect images with Icrawler for machine learning [1000 images]
What you want to memorize with the basic "string manipulation" grammar of python
One liner to make Lena images with scipy
Classification of guitar images by machine learning Part 2
I'm an amateur on the 14th day of python, but I want to try machine learning with scikit-learn
If you want to make a discord bot with python, let's use a framework
Arrangement of self-mentioned things related to machine learning
How to make a face image data set used in machine learning (2: Frame analysis of video to obtain candidate images)
I tried to make a real-time sound source separation mock with Python machine learning
Create a dataset of images to use for learning
Key points of "Machine learning with Azure ML Studio"
I want to detect images of cats from Instagram
I want to climb a mountain with reinforcement learning
Try to predict forex (FX) with non-deep machine learning
Links to do what you want with Sublime Text
Predict the gender of Twitter users with machine learning
When you want to play a game via Proxy
Machine Learning with Caffe -1-Category images using reference model
Machine learning beginners try to make a decision tree
Site summary to learn machine learning with English video
Summary of the basic flow of machine learning with Python
Record of the first machine learning challenge with Keras