r/MachineLearning • u/dusklight00 • Feb 27 '22
Rule 6 - Beginner tutorial or project [P] I made live digit recognizer with machine learning and web technologies. (Live Demo in Comments...)
[removed] β view removed post
45
u/CluelessAnd23 Feb 27 '22
The initial estimate is always a 7 so does this imply that 7 is the average shape for all the numbers thereby being the optimal first choice?
27
u/dusklight00 Feb 27 '22 edited Feb 27 '22
Yeah, you could be right. The model is currently trained upon MNIST dataset, so there could be a slight chance of data influence due the the hand-writing of MNIST dataset creators. Training the model to datasets other than MNIST could help in confirming this fact. I'll give this some research in the future. Nice observation!
9
u/notapunnyguy Feb 27 '22
You can look in your features or ghosts and see if they look more like a 7 or a line.
4
11
u/e_j_white Feb 27 '22
I mean, when I played with the demo it barely got any of the numbers correct. Even a clear circular 0 was predicted as a 4, so I wouldn't read it into it that much.
5
u/dusklight00 Feb 27 '22
I can't say much, but have you tried slow drawing? Because then the canvas is able to capture more number of edges in the drawing, which results in more organic prediction.
4
u/michael-relleum Feb 27 '22
I've also tried to draw slow and correct, but most of the numbers are false. What model structure did you use? And what kind of val accuracy did you get?
6
u/dusklight00 Feb 27 '22
I have used MNIST dataset, and it was giving 95%+ validation accuracy. But yeah, validation data was from MNIST dataset as well.
2
u/airelfacil Feb 27 '22
Which mode/architecturel did you use?
1
u/dusklight00 Feb 27 '22
I have used CNN with MNIST dataset for this project.
5
u/airelfacil Feb 27 '22
Probably an overfitting issue then. Do you have a github for this project?
2
u/e_j_white Feb 27 '22
It's absolutely due to overfitting. It was trained/validated on one distribution, and here we come drawing digits with our mouse or trackpad.
It's a completely different distribution. So technically due feature drift. But in theory you could add the mouse-drawn digits to the training set, which is why I originally said overfitting.
16
u/dusklight00 Feb 27 '22 edited Feb 27 '22
Live Demo - https://live-digit-recognizer.herokuapp.com/
Github - https://github.com/dusklight00/live-digit-recognition
... maybe if you like it, give me a star on github, hehe
4
u/carlosTheMontgomery Feb 27 '22
hehe, no problem
3
u/dusklight00 Feb 27 '22
Thankss carlos!
3
u/Chinmay101202 Feb 27 '22
stared buddy, good job have a star, only because of the lucky star profile Pic
2
3
2
u/QuantumFTL Feb 28 '22
Done!
Sent it to ~6 people, hopefully it gets around. Lots of fun.
Looking forward to V2. Have you trained with rotated digits? It doesn't seem to like those. Try drawing a figure-8 at 45-degree angle.
2
u/dusklight00 Feb 28 '22
Thank you so much Quantum, I really appreciate. Yeah you are right. It is not yet trained on rotating, noised or half digit. Alot of improvement can be made to the model. Second version should have all these issues resolved.
1
u/QuantumFTL Feb 28 '22
Iteration is the name of the game! Thanks for sharing something imperfect but awesome!
Also, I think it's fun to see the limits of these algorithms, so it's not a bug, it's a feature :)
9
u/LigaenAvLegender Feb 27 '22
I'm not sure how the MNIST dataset looks like, but maybe you shold try to add some random noise. Your model can be 100% certian of a 6, but when I add a single dot at a random place, it sometime is 100% sure it's a 7 instead.
Cool project though, love that you have made it interactive!
5
u/dusklight00 Feb 27 '22
Wow, I didn't knew about this approach of applying random noise. Thank you ligen for suggesting it! I'll give it a try.
6
u/LigaenAvLegender Feb 27 '22
There are many ways of doing it, so I would recommend experimenting and combining different methods, and see what works best!
Some ideas might be:
random dots on some of the pictures
"painting" a quarter or half of some pictures fully black/white
combining same digits, i.e. top half of the picture of one 4 with the bottom half of another 4, and the other way around.
There are probably 100 other things you can think of, which would be nice to try as well! Good luck, and keep me updated :D
2
u/LigaenAvLegender Feb 27 '22
And you can of course test many different methods to see what works best, if you haven't already! :)
2
u/dusklight00 Feb 27 '22
Wow, thank you so much for this, really helped me learn a lot. I'll get back to you with the update after applying it.
4
4
4
3
u/carlosTheMontgomery Feb 27 '22
what 4 should look like? like here -> 4?
3
u/dusklight00 Feb 27 '22 edited Feb 27 '22
Simple 4, like in this font does it. It works for me. Although for some reason it needs a longer horizontal stroke in 4 to differentiate with 2... my apologies
3
3
3
u/Firehead1971 Feb 27 '22
Did you use a framework for creating the web interface or is this plain vanilla javascript?
2
u/dusklight00 Feb 27 '22
Yes it's a plain vanilla javascript in combination with flask as server-side framework. You can have a look at the html / css and javascript of the page in the
staticfolder of the repository.
3
3
u/alonsogp2 Feb 27 '22
You could train it on drawing trajectories instead of the image of a full number, in the next iteration. Good work!
1
u/dusklight00 Feb 27 '22
Yeah that would really speed up the app. I will do this in the future versions. Thank you for the suggestion alonsogp2!
3
u/MegaRiceBall Feb 27 '22
You may add these to the training dataset
1
u/dusklight00 Feb 27 '22
Thanks Mega! I'll add these, and do a more robust training in the next version.
2
u/qwe1972 Feb 27 '22
It will not work correct if write at normal speed. But nonetheless it's good idea
1
2
2
2
2
u/singularity_matrix Feb 27 '22
Is the code public on git?
2
2
u/emilbm Feb 28 '22
0/10 success rate for me :(
1
u/dusklight00 Feb 28 '22
My apologies emilbm. I'll try making a better model in next version of the app.
2
u/Alberiman Feb 28 '22
What features are you using?
1
u/dusklight00 Feb 28 '22
Right now the features are simple image. When you draw anything in the canvas it get cropped and in the background to only the portion where drawing has been made, then this cropped image is used to predict the digit using mnist model CNN.
2
u/LOLTROLDUDES Feb 28 '22
What optimizations are used that take advantage of the fact that the input is live?
2
u/dusklight00 Feb 28 '22
Right now, there are none. I would try to think of some in the future version of the app. Right now, I did a one-hot training in the beginning of the app and convert the trained model into
.tflifefile. This .tflite file is used for prediction each time it gets a new drawing.
1
u/aslanfth Feb 27 '22
Since the handwriting data is sequential, you can also use RNNs or other sequential architectures to predict the digits. For this task, you can train it using character trajectories dataset.
1
0
Feb 27 '22
[deleted]
9
u/dusklight00 Feb 27 '22
Thanks Drago, I will try to improve the model, and, maybe use a better dataset than MNIST.
5
Feb 27 '22
I've always wondered about MNIST. Technically it's "solved". Pretty easy to get 99.6% accuracy and apparently a lot of the errors are just mislabeled. But is it really that good?
What accuracy do you get on MNIST?
8
u/dusklight00 Feb 27 '22
Yes you are right, it is quite easy to get 99+ accuracy on mnist dataset. But through this project I have realised, it takes more than just simple gradient decent to make a model that can be deployed into the real world. Techniques like noising or predicting upon just the half image of a certain digit really makes the model a alot robust. I'm planning to apply all these training technique in the next version of live-digit-recognizer. This would make the prediction more accurate.
57
u/[deleted] Feb 27 '22
Fails to recognize negative space
https://i.imgur.com/X8QUtnR.png