Read captcha image with TensorFlow. Tutorial
Image generated:(4 or 5 random en char or digit, multi-color, random roate 0 ~ 4 degree)
Make it binary:
Get shapes with opencv.findContours:
Then feed to tensorflow.keras
Result:
# (trainData, trainLabels) = createData(8000)
# (testData, testLabels) = createData(2000)
Epoch 25/25
36029/36029 [==============================] - 2s 54us/step - loss: 0.0752 - acc: 0.9669
8970/8970 [==============================] - 0s 29us/step
evaluate test data set:
test_loss: 0.28423821404674937
test_acc: 0.9385730211817168
predict example-image(example-images/example-captcha.png):
['l', '8', 'V', 'T']
It can be improved by add more train data or add more epochs.
# install Helper libraries, for ubuntu 16.04 only
sudo apt-get install python3-pip python3-tk
pip3 install tensorflow numpy Pillow scipy opencv-python --user
# clone the repo
git clone [email protected]:zxdong262/tf-captcha-reader.git
cd tf-captcha-reader
npm i
python3 main.py