LoginSignup
9
12

More than 5 years have passed since last update.

Chainer+Tkinterで、自分で手書きした数字を認識してみる

Last updated at Posted at 2016-08-18

こんな人向けです

  • Chainerのexampleを実行できた!けどちゃんと学習できたのか、いまいちよくわからない
  • 自分で書いた数字を認識してみたい

作ったもの

左側に数字を書くと、右側に認識結果が表示されます。
Screen Shot 2016-09-12 at 8.21.17 AM.png

参考

VisualizeChainer

コードを置いたので実行してみてください。
https://github.com/nabehide/VisualizeChainer

動作確認した環境

  • Mac OSX El Capitan
  • Python 2.7.10
  • chainer 1.13.0
  • h5py 2.6.0
  • numpy 1.11.1
  • pillow 3.3.0

入っていない場合はpipなどでインストールしてください。

実行方法

コマンドの実行に必要なものです。

  • Git : https://git-scm.com/
  • wget :
    • Macであれば brew install wget でインストールできます

下記コマンドでGUIが起動します。

$ git clone https://github.com/nabehide/VisualizeChainer
$ cd VisualizeChainer/MNIST
$ wget https://github.com/nabehide/VisualizeChainer/releases/download/v1.0.0/20160818_MNIST.model.zip
$ unzip 20160818_MNIST.model.zip
$ python main.py

左側のcanvasに数字を書いて、左下のjudgeボタンを押すと、右側のresultに認識結果が表示されます
Screen Shot 2016-09-12 at 8.21.17 AM.png

コードの説明

canvasの見た目はTkinterですが、裏でPILのキャンバス(?)にも同時に描画しています。
「judge」ボタンを押すと、裏キャンバスのデータをpngに変換 → 28×28にリサイズ → データをNNに入力 → 認識結果を得る
という流れです。
かなり回りくどいんじゃないかと思うので、今後シンプルにしたいです。

9
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
12