Code Monkey home page Code Monkey logo

Comments (8)

githubharald avatar githubharald commented on May 18, 2024

you have to evaluate the output of the RNN with softmax applied, and then feed this into the decoder. Something like that (not tested):

  • After this line, define a new variable self.rnn_out_sm = tf.nn.softmax(self.ctcIn3dTBC, axis=2)
  • In the infer function, evaluate the variable defined before, rnn_out_sm_numpy = self.sess.run(self.rnn_out_sm, feedDict)
  • Create the word beam search object only once! So e.g. in the __init__ function of the Model
  • Then, feed the evaluated numpy array (rnn_out_sm_numpy) to the compute function

from ctcwordbeamsearch.

jjsr avatar jjsr commented on May 18, 2024

Step-1 Initialize above in init of Model.py
chars = str().join(self.charList) wordChars = open('../model/wordCharList.txt').read().splitlines()[0]
corpus = open('../data/corpus.txt').read() self.wbs=WordBeamSearch(25,'Words',0.0,corpus.encode('utf8'), chars.encode('utf8'), wordChars.encode('utf8'))

Step-2 in Model.py--> setupCTC() defined Point-1 Above
self.rnn_out_sm = tf.nn.softmax(self.ctcIn3dTBC, axis=2)

  • Commented everything from L128-L138
    Step-3-
    In inferBtach()
  • Commented Line-250 and Line-251 , Line-254, Line-255
  • Added self.rnn_out_sm_numpy = self.sess.run(self.rnn_out_sm, feedDict) evalRes=self.wbs.compute(self.rnn_out_sm_numpy) after Line-252
    Result- On running my program in debugging mode my ctcOutput array of Line 186 is [64,61,72,72,64,57]
    Observation-1 I did not get any label index as blank Line196 in my ctcOutput
    Observation-2 on manually finding out the index of ctcOut array in charList i have "mjuumf" instead of "little"

Sidenote- I am running code as(python main.py --wordbeamsearch) (using presaved model ,testing on a single image)
Kindly let me know what i am doing wrong if possible, i know i am messing things up ,a word of help still highly appreciated
I am getting the error on simply running the code after making changes in model,py -- int' object is not iterable -- on Line 196

Modified model.py I have uploaded on my git just for time being after that i will remove , I have also given your reference while uploading model.py

from ctcwordbeamsearch.

jjsr avatar jjsr commented on May 18, 2024

Thanks again for your earlier response sir

from ctcwordbeamsearch.

githubharald avatar githubharald commented on May 18, 2024

Hi,

at first sight code looks OK. I guess this line is wrong and can be removed (you want to pass all batch elements to the function decoderOutputToText and not just the one with index 0):
https://github.com/jjsr/SimpleHtr/blob/main/Model.py#L273

If this does not fix the problem: can you upload all of your code into your repository? So that I just have to download it and run it to reprocude the error.

from ctcwordbeamsearch.

jjsr avatar jjsr commented on May 18, 2024

Sir ,After your input I am able to somehow run it on "Word" , I am not quite confident in what patches i have made during the process is right or Its really worked , Beside it Sir may you please suggest into line segmentation(Breaking a page into lines ) approach ? (The approach you think would work best on IAM(Not quite complex scenario) with preferable code implementation link). Additionally I will upload the codes of the patches i try to work out , Kindly go through it sir once uploaded . Thanks again for your timely valuable feedbacks

from ctcwordbeamsearch.

githubharald avatar githubharald commented on May 18, 2024

you can try WordDetectorNN to detect handwritten words on a scanned page.

from ctcwordbeamsearch.

githubharald avatar githubharald commented on May 18, 2024

FYI: SimpleHTR is now using the Python package (numpy operation) instead of the TF operation.

from ctcwordbeamsearch.

jjsr avatar jjsr commented on May 18, 2024

from ctcwordbeamsearch.

Related Issues (20)

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.