[PYTHON] A story about machine learning with Kyasuket

At PeerCast's creative event "Kyasuket", participants were asked to draw a large number of pictures, and based on that, an identification AI was created.

Kyasuket is like an online Comiket, a relative event where participants can publish their work and enjoy the work of others. The main contents are pictures, games and tools. It is held once every six months.

At this time (Autumn 2016), we asked them to draw pictures of multiple types of Sutatsu-san (the figure below, an example), and based on that data, we identified which type of Sutatsu-san. Created an AI to do. stamp1.png

UI We have prepared four pages: a page for writing pictures that will be data, a page for using AI, a page for information on how many posts have been posted, and a page for writing brief explanations.

Post page how_to_post.png AI page how_to_use_AI.png I did it like this.

Randomly draw 9 kinds of pictures and ask them to imitate them. On the contrary, AI decided to answer with probability which picture it was close to.

I don't think I'd see it in the old IE of some company, so I wrote it in ES2015 and placed it without compiling with babel, huh.

server

I pushed it into heroku's free tier. I used Flask in Python3. If the original size of the image data is the same, the data size will be large, so I made the image 32x32 and put it in heroku's PostgreSQL along with information about which picture it is.

I chose Python to use TensorFlow for machine learning, and I didn't intend to complicate it as a web app, so I used Flask. I used Flask-SQLAlchemy to work with the database.

It would be very painful to have to draw a picture and refresh the page, so I took the method of straightening the canvas after sending the data with Ajax. So, the page itself is almost static, and the server is mainly operated by json API.

AI The AI challenges are at the same level as mnist, so I made it a level that can be understood with a little work on the TensorFlow tutorial. The reason I made it safe without pushing my limits is that I will make adjustments within the period.

The model used softmax regression, multi-layer perceptron, and CNN, as shown in the TensorFlow tutorial, so that the user could select the model and see the results of each.

result

Currently, more than 4,500 data are collected. (Of which, I wrote about 1000) Many people wrote along with me as I was distributing the state of writing data with PeerCast, and most of the posts were at that time. .. I think that the event was lively with a reaction like PeerCast, which has a culture of enjoying repetitive work like this kind of training. (It would have been painful to continue writing the entire schedule for three days, but it was helpful because I collected enough data only on the first day to get enough learning results.) It was easy to write with a pen tab, but it is compatible with smartphones. It wasn't done, so maybe some people wrote it on their smartphones.

On the contrary, as expected, there must have been a story post that hindered learning. I'd like to try to detect material posts, but that's a future story. For the time being, I exposed the material-like things on Twitter when I saw it with my own eyes. In the udon picture, there are people who write fried rice, girls who seem to be girls, and other characters.

The accuracy of AI is about 70% for softmax regression and multi-layer perceptron, and 86% for CNN. Compared to mnist, the total amount of data is small for the large amount of data, so I think it's about this. Unlike the tutorial, the accuracy did not come out unless I tampered with the dimensions and parameters by myself, and I had to make various trials and errors. I didn't do it on the delivery because I was wondering if the results would come out after learning at midnight, but I regret that some people would have expected it. However, it takes time to learn CNN ...

The handling of data and source code will be considered in the future. I'm tired of drawing.

reaction

I didn't have a function to display the posted image, but after all, there were some people who wanted to see it. I was worried about how to show it, but I got a plan to display one when I posted it.

Some people wanted to try it from the outside with a smartphone, but what should I do because I don't have a smartphone?

There is also a comment that it was a service where humans learned how to write Sutatsu rather than AI. In fact, I wrote one in a few seconds.

from now on

What to do with the data. What to do with the public. At the next time, I will tackle another problem from the same data. Organize to publish the source code.

Take a break and think if you can reset your mind.

Recommended Posts

A story about machine learning with Kyasuket
A story about simple machine learning using TensorFlow
A story about data analysis by machine learning
A story about automating online mahjong (Mahjong Soul) with OpenCV and machine learning
A story about predicting exchange rates with Deep Learning
A story stuck with the installation of the machine learning library JAX
Machine learning A story about people who are not familiar with GBDT using GBDT in Python
A story about developing a machine learning model while managing experiments and models with Azure Machine Learning + MLflow
A story about implementing a login screen with django
Build a Python machine learning environment with a container
A story about making 3D space recognition with Python
A story about using Resona's software token with 1Password
Run a machine learning pipeline with Cloud Dataflow (Python)
About learning with google colab
Machine learning with Python! Preparation
A story about achieving a horse racing recovery rate of over 100% through machine learning
A story about making Hanon-like sheet music with Python
Let's feel like a material researcher with machine learning
A story about trying a (Golang +) Python monorepo with Bazel
About machine learning mixed matrices
Build a machine learning application development environment with Python
Machine learning Minesweeper with PyTorch
Build a machine learning environment
A story about how theano was moved with TSUBAME 2.0
Beginning with Python machine learning
Try machine learning with Kaggle
Create a machine learning environment from scratch with Winsows 10
Talk about improving machine learning algorithm bottlenecks with Cython
Build a machine learning scikit-learn environment with VirtualBox and Ubuntu
Create a machine learning app with ABEJA Platform + LINE Bot
A story about competing with a friend in Othello AI Preparation
A story about installing matplotlib using pip with an error
A story about an amateur making a breakout with python (kivy) ②
A story about how to deal with the CORS problem
A story about an amateur making a breakout with python (kivy) ①
Create a python machine learning model relearning mechanism with mlflow
A story about making a tanka by chance with Sudachi Py
A story about a 40-year-old engineer manager passing "Deep Learning for ENGINEER"
A story about a python beginner stuck with No module named'http.server'
A refreshing story about Python's Slice
I tried machine learning with liblinear
Machine learning with python (1) Overall classification
A sloppy story about Python's Slice
Try machine learning with scikit-learn SVM
Inversely analyze a machine learning model
A story about using Python's reduce
Quantum-inspired machine learning with tensor networks
Get started with machine learning with SageMaker
"Scraping & machine learning with Python" Learning memo
Building a Windows 7 environment for getting started with machine learning with Python
Machine learning
A story about developing a soft type with Firestore + Python + OpenAPI + Typescript
How to create a serverless machine learning API with AWS Lambda
A story about a student who does not know the machine learning machine learned machine learning (deep learning) for half a year
Predict power demand with machine learning Part 2
A story about remodeling Lubuntu into a Chromebook
Amplify images for machine learning with python
Machine learning imbalanced data sklearn with k-NN
Machine learning with python (2) Simple regression analysis
[Shakyo] Encounter with Python for machine learning
Personal notes and links about machine learning ① (Machine learning)