Skip to content

Latest commit

 

History

History

digits-sklearn-opencv

Predicting the Values of Hand-Written Digits


This example creates a SVM classifier for the digits dataset using scikit-learn, and predicts the values of hand-written digits of an input image.

Original Experiment

The original experiment is composed by two steps:

  1. Classification: the SVM classifier is created.
  2. Prediction: the values of hand-written digits from the input file are predicted and recognized (output.jpg).

To run this experiment without ReproZip, you will need to first install scikit-learn and OpenCV 3.0.0, and then run each script with Python, in the aforementioned order.

ReproZip Package

The ReproZip package is available here (79.0 MB).

How to Reproduce

The experiment can be reproduced as follows:

$ reprounzip vagrant setup digits_sklearn_opencv.rpz digit-recognition/
$ reprounzip vagrant run digit-recognition/ classification
$ reprounzip vagrant run digit-recognition/ prediction

The input image with the predictions can be retrieved as follows:

$ reprounzip vagrant download digit-recognition/ output.jpg

You can also perform the same prediction with an alternate input file as follows:

$ reprounzip vagrant upload digit-recognition/ photo_2.jpg:photo.jpg
$ reprounzip vagrant run digit-recognition/ prediction

And finally download the results as follows:

$ reprounzip vagrant download digit-recognition/ output.jpg

Packing From Our Demo VM

If you are using our demo VM image, you can run the following:

$ vagrant ssh
$ workon digits-sklearn-opencv
$ cd reprozip-examples/digits-sklearn-opencv/
$ python generateClassifier.py
$ python performRecognition.py