项目作者: RayXie29

项目描述 :
Mnist/Drawing/Image Digit recognizer
高级语言: Python
项目地址: git://github.com/RayXie29/MNIST_DRAW_PREDICT.git
创建时间: 2019-05-08T01:09:46Z
项目社区:https://github.com/RayXie29/MNIST_DRAW_PREDICT

开源协议:

下载


CNN Mnist/Draw/Image Train/Predict



This repo is using CNN model to train a digit recognizer for some interesting applcation. The Whole model is built by Keras sequential module.

Train folder

Contain several training python file, including model training by dataset


1.Csv file: This training dataset is the same format as the digit recognizer competition in Kaggle. The first column would be the training label and the rest of the column would be the pixel values of digit image.


2.Image: This format of data will received by using the ImageDigitTrain.py. It will use DigitParser class to parse the digit image in the input image.


3.Draw: In DrawTrain.py, it is implement by openCV module. The input images are drawn by the user and the digit data will in an ascending order.




train.py :


Train the module by csv file. It can show some data visualized information(label counts, confusion matrix, accuracy/loss curve….) by setting the show_flag to true. Only the bacth_size and the epochs are tunable, if further adjustment wants to do, then you can modify the source code for this purpose. After training the model, it will save a model file. Also you can import the trained model for further training by setting the model_path argument


alt text




DrawTrain.py :


This python file will train the model by your own drawing picture. You need to draw 10 digits in an ascending order(0~9), and the model will trained by the digits image you draw. But this might has very little effect, since the training data is too less, but it will use cv2.dilate to make the digits thicker and ImageDataGenerator for expanding the dataset.


alt text




ImageDigitTrain.py :


This python file will take an image for input and use DigitParser class to parse the digits in the image, and you need to label the digits by yourself. The DigitParser class is written by several openCV functions, but it might only can handle some simple situation(Normal size digits in a simple backgound).


alt text




Predict folder

Contain severl python files which are for predicting the result.



predict.py :

This python file is for csv file data prediction. Simple input the model path adn the test data, it will output a prediction.csv for result. The test data should have the same format as Kaggle`s(784 columns, eacj column represent pixel value)


predictDraw.py :

This python file will predict the digit result you draw. By the way, the canvas is maded by openCV function, every time you press the left mouse button, it will draw an small circle on the black image. When there are many small circle connect togetherm it will look like a line.


alt text




ImageDigitPredict.py :

This python file is very similar to ImageDigitTrain.py. It will take an image and model for input, then it will use DigitParser to parse the digit images in the input image. Then use the model to predict the digit images and show the result on the original input image.


alt text




extra_modules folder

Some modules for image processing