original_docstring: feed a batch into the NN to recognize the texts
docstring: feed a batch into the NN to recognize the texts
docstring_tokens: feed a batch into the NN to recognize the texts
code: def inferBatch(self, batch, calcProbability=False, probabilityOfGT=False):
          """feed a batch into the NN to recognize the texts"""
  
          # decode, optionally save RNN output
          batch_imgs = batch.imgs
          if batch_imgs[0].shape == Model.imgSize[::-1]:
              batch_imgs = [cv2.transpose(img) for img in batch_imgs]
  
          batch_imgs = np.stack(batch_imgs, axis=0)
          numBatchElements = len(batch.imgs)
  
          # put tensors to be evaluated into list
          evalList = []
          evalList.append(self.decoder)
  
          if self.dump or calcProbability:
              evalList.append(self.ctcIn3dTBC)
  
          # dict containing all tensor fed into the model
          feedDict = {self.inputImgs: batch_imgs, self.seqLen: [Model.maxTextLen] * numBatchElements,
                      self.is_train: False}
  
          # evaluate model
          evalRes = self.sess.run(evalList, feedDict)
  
          # TF decoders: decoding already done in TF graph
          decoded = evalRes[0]
  
          # map labels (numbers) to character string
          texts = self.decoderOutputToText(decoded, numBatchElements)
  
          # feed RNN output and recognized text into CTC loss to compute labeling probability
          probs = None
          if calcProbability:
              sparse = self.toSparse(batch.gtTexts) if probabilityOfGT else self.toSparse(texts)
              ctcInput = evalRes[1]
              evalList = self.lossPerElement
              feedDict = {self.savedCtcInput: ctcInput, self.gtTexts: sparse,
                          self.seqLen: [Model.maxTextLen] * numBatchElements, self.is_train: False}
              lossVals = self.sess.run(evalList, feedDict)
              probs = np.exp(-lossVals)
  
          # dump the output of the NN to CSV file(s)
          if self.dump:
              self.dumpNNOutput(evalRes[1])
  
          return texts, probs
code_tokens: def inferBatch ( self , batch , calcProbability = False , probabilityOfGT = False ) : batch_imgs = batch . imgs if batch_imgs [ 0 ] . shape == Model . imgSize [ : : - 1 ] : batch_imgs = [ cv2 . transpose ( img ) for img in batch_imgs ] batch_imgs = np . stack ( batch_imgs , axis = 0 ) numBatchElements = len ( batch . imgs ) evalList = [ ] evalList . append ( self . decoder ) if self . dump or calcProbability : evalList . append ( self . ctcIn3dTBC ) feedDict = { self . inputImgs : batch_imgs , self . seqLen : [ Model . maxTextLen ] * numBatchElements , self . is_train : False } evalRes = self . sess . run ( evalList , feedDict ) decoded = evalRes [ 0 ] texts = self . decoderOutputToText ( decoded , numBatchElements ) probs = None if calcProbability : sparse = self . toSparse ( batch . gtTexts ) if probabilityOfGT else self . toSparse ( texts ) ctcInput = evalRes [ 1 ] evalList = self . lossPerElement feedDict = { self . savedCtcInput : ctcInput , self . gtTexts : sparse , self . seqLen : [ Model . maxTextLen ] * numBatchElements , self . is_train : False } lossVals = self . sess . run ( evalList , feedDict ) probs = np . exp ( - lossVals ) if self . dump : self . dumpNNOutput ( evalRes [ 1 ] ) return texts , probs
short_docstring: feed a batch into the NN to recognize the texts
short_docstring_tokens: feed a batch into the NN to recognize the texts
comment: """feed a batch into the NN to recognize the texts"""$SEP$# decode, optionally save RNN output$SEP$# put tensors to be evaluated into list$SEP$# dict containing all tensor fed into the model$SEP$# evaluate model$SEP$# TF decoders: decoding already done in TF graph$SEP$# map labels (numbers) to character string$SEP$# feed RNN output and recognized text into CTC loss to compute labeling probability$SEP$# dump the output of the NN to CSV file(s)