aaronmarkham commented on a change in pull request #13769:  Clojure example for 
fixed label-width captcha recognition 
URL: https://github.com/apache/incubator-mxnet/pull/13769#discussion_r246211781
 
 

 ##########
 File path: contrib/clojure-package/examples/captcha/README.md
 ##########
 @@ -0,0 +1,62 @@
+# Captcha
+
+This is the clojure version of [captcha 
recognition](https://github.com/xlvector/learning-dl/tree/master/mxnet/ocr)
+example by xlvector and mirrors the R captcha example. It can be used as an
+example of multi-label training. For a captcha below, we consider it as an
+image with 4 labels and train a CNN over the data set.
+
+![](captcha_example.png)
+
+## Installation
+
+Before you run this example, make sure that you have the clojure package
+installed. In the main clojure package directory, do `lein install`.
+Then you can run `lein install` in this directory.
+
+## Usage
+
+### Training
+
+First the OCR model needs to be trained based on [labeled 
data](https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/data/captcha_example.zip).
+The training can be started using:
+```
+$ lein train [:cpu|:gpu] [num-devices]
+```
+which downloads the training/evaluation data using the `get_data.sh` script
+before starting training.
+
+I encountered some out-of-memory issues while training using :gpu on Ubuntu
+linux (18.04). However, the command `lein train` (training on one CPU) worked
+well for me.
+
+The training runs for 10 iterations by default and saves the model with the
+prefix `ocr-`. I was able to achieve an exact match accuracy of ~0.954 and
+~0.628 on training and validation data respectively.
+
+### Inference
+
+Once the model has been saved, it can be used for prediction. This can be done
+by running:
+```
+$ lein infer
+INFO  MXNetJVM: Try loading mxnet-scala from native path.
+INFO  MXNetJVM: Try loading mxnet-scala-linux-x86_64-gpu from native path.
+INFO  MXNetJVM: Try loading mxnet-scala-linux-x86_64-cpu from native path.
+WARN  MXNetJVM: MXNet Scala native library not found in path. Copying native 
library from the archive. Consider installing the library somewhere in the path 
(for Windows: PATH, for Linux: LD_LIBRARY_PATH), or specifying by Java cmd 
option -Djava.library.path=[lib path].
+WARN  org.apache.mxnet.DataDesc: Found Undefined Layout, will use default 
index 0 for batch axis
+INFO  org.apache.mxnet.infer.Predictor: Latency increased due to batchSize 
mismatch 8 vs 1
+WARN  org.apache.mxnet.DataDesc: Found Undefined Layout, will use default 
index 0 for batch axis
+WARN  org.apache.mxnet.DataDesc: Found Undefined Layout, will use default 
index 0 for batch axis
+CAPTCHA output: 6643
+INFO  org.apache.mxnet.util.NativeLibraryLoader: Deleting 
/tmp/mxnet6045308279291774865/libmxnet.so
+INFO  org.apache.mxnet.util.NativeLibraryLoader: Deleting 
/tmp/mxnet6045308279291774865/mxnet-scala
+INFO  org.apache.mxnet.util.NativeLibraryLoader: Deleting 
/tmp/mxnet6045308279291774865
+```
+The model is run on `captcha_example.png` by default.
 
 Review comment:
   ```suggestion
   The model runs on `captcha_example.png` by default.
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to