Giter Club home page Giter Club logo

how-did-i-write-an-own-ocr-program-using-keras-and-tensorflow-in-python's Introduction

Hi ๐Ÿ‘‹, I'm Trung Anh Dang

I unlock computer scientists to make the impossible possible

housecricket

housecricket

  • ๐Ÿ”ญ Iโ€™m currently working on EvoCC

  • ๐ŸŒฑ Iโ€™m currently learning everything

  • ๐Ÿ‘ฏ Iโ€™m looking to collaborate on EvoCluster

  • ๐Ÿ“ I regularly write articles on https://junryo.xyz

  • ๐Ÿ’ฌ Ask me about software architecture, machine learning, nodejs, react, swift, kotlin, mvvm and so on

  • ๐Ÿ“ซ How to reach me [email protected]

Connect with me:

mrhousecricket @dangtrunganh

Languages and Tools:

android angular angularjs arduino aws azure bootstrap c canvasjs cassandra chartjs circleci cplusplus css3 d3js docker erlang firebase gcp git go grafana hadoop hive html5 illustrator ionic java javascript jenkins kibana kotlin kubernetes linux mongodb mssql mysql nginx nodejs objectivec oracle postgresql python pytorch react reactnative redis sketch spring sqlite swift tensorflow travisci typescript unity vagrant xd zapier

housecricket

ย housecricket

housecricket

how-did-i-write-an-own-ocr-program-using-keras-and-tensorflow-in-python's People

Contributors

housecricket avatar laptq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

how-did-i-write-an-own-ocr-program-using-keras-and-tensorflow-in-python's Issues

Indentation bug in your load_az_dataset method

You have a bug in your load_az_dataset method. As I understand last 2 paragraphs should NOT be in for:

Instead of

    for row in open(dataset_path):
        <iterate over each row code here>

        # convert the data and labels to NumPy arrays
        data = np.array(data, dtype="float32")
        labels = np.array(labels, dtype="int")

        # return a 2-tuple of the A-Z data and labels
        return (data, labels)

It should be:

    for row in open(dataset_path):
        <iterate over each row code here>


    # convert the data and labels to NumPy arrays
    data = np.array(data, dtype="float32")
    labels = np.array(labels, dtype="int")

    # return a 2-tuple of the A-Z data and labels
    return (data, labels)

Returning "ValueError: Number of classes, 11, does not match size of target_names, 36. Try specifying the labels parameter"

When I run the code with

python train_model.py --az A_Z_Handwritten_Data.csv --model trained_ocr.model

It progresses through Epoch 50/50, but then returns

[INFO] evaluating network...
Traceback (most recent call last):
  File "C:\Users\achmiel\Downloads\How-did-I-write-an-own-OCR-program-using-Keras-and-TensorFlow-in-Python-master\How-did-I-write-an-own-OCR-program-using-Keras-and-TensorFlow-in-Python-master\train_model.py", line 113, in <module>
    print(classification_report(testY.argmax(axis=1),
  File "C:\Users\achmiel\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 63, in inner_f
    return f(*args, **kwargs)
  File "C:\Users\achmiel\Anaconda3\lib\site-packages\sklearn\metrics\_classification.py", line 1991, in classification_report
    raise ValueError(
ValueError: Number of classes, 11, does not match size of target_names, 36. Try specifying the labels parameter

I understand that this means I have more target names than classes, but I don't know what is the root o the problem.

Another indentation bug in train_model.py

Identation mistake. Instead of:

# randomly select a few testing characters
for i in np.random.choice(np.arange(0, len(testY)), size=(49,)):
    # classify the character
    probs = model.predict(testX[np.newaxis, i])
prediction = probs.argmax(axis=1)
label = labelNames[prediction[0]]

# extract the image from the test data and initialize the text
# label color as green (correct)
image = (testX[i] * 255).astype("uint8")
color = (0, 255, 0)

# otherwise, the class label prediction is incorrect
if prediction[0] != np.argmax(testY[i]):
    color = (0, 0, 255)

# merge the channels into one image, resize the image from 32x32
# to 96x96 so we can better see it and then draw the predicted
# label on the image
image = cv2.merge([image] * 3)
image = cv2.resize(image, (96, 96), interpolation=cv2.INTER_LINEAR)
cv2.putText(image, label, (5, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.75,
color, 2)

# add the image to our list of output images
images.append(image)

It should be:

# randomly select a few testing characters
for i in np.random.choice(np.arange(0, len(testY)), size=(49,)):
    # classify the character
    probs = model.predict(testX[np.newaxis, i])
    prediction = probs.argmax(axis=1)
    label = labelNames[prediction[0]]
    
    # extract the image from the test data and initialize the text
    # label color as green (correct)
    image = (testX[i] * 255).astype("uint8")
    color = (0, 255, 0)
    
    # otherwise, the class label prediction is incorrect
    if prediction[0] != np.argmax(testY[i]):
        color = (0, 0, 255)
    
    # merge the channels into one image, resize the image from 32x32
    # to 96x96 so we can better see it and then draw the predicted
    # label on the image
    image = cv2.merge([image] * 3)
    image = cv2.resize(image, (96, 96), interpolation=cv2.INTER_LINEAR)
    cv2.putText(image, label, (5, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.75,
    color, 2)
    
    # add the image to our list of output images
    images.append(image)

cant load the A-Z dataset

for some reason the label and the data are empty after load the CSV
there is another way to load the CSV a-z file?
or what could be the issues ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.