text: import tensorflow as tf
  from preprocessing import *
  from Encoder import *
  from Decoder import *
  
  
  def evaluate(sentence):
      attention_plot = np.zeros((max_length_targ, max_length_inp))
  
      sentence = preprocess_sentence(sentence)
  
      inputs = [inp_lang.word_index[i] for i in sentence.split(' ')]
      inputs = tf.keras.preprocessing.sequence.pad_sequences([inputs],
                                                             maxlen=max_length_inp,
                                                             padding='post')
      inputs = tf.convert_to_tensor(inputs)
  
      result = ''
  
      hidden = [tf.zeros((1, units))]
      enc_out, enc_hidden = encoder(inputs, hidden)
  
      dec_hidden = enc_hidden
      dec_input = tf.expand_dims([targ_lang.word_index['<start>']], 0)
  
      for t in range(max_length_targ):
          predictions, dec_hidden, attention_weights = decoder(dec_input,
                                                               dec_hidden,
                                                               enc_out)
  
          # storing the attention weights to plot later on
          attention_weights = tf.reshape(attention_weights, (-1, ))
          attention_plot[t] = attention_weights.numpy()
  
          predicted_id = tf.argmax(predictions[0]).numpy()
  
          result += targ_lang.index_word[predicted_id] + ' '
  
          if targ_lang.index_word[predicted_id] == '<end>':
              return result, sentence, attention_plot
  
          # the predicted ID is fed back into the model
          dec_input = tf.expand_dims([predicted_id], 0)
  
      return result, sentence, attention_plot
  
  
  def translate(sentence):
      result, sentence, attention_plot = evaluate(sentence)
  
      # print('Input: %s' % (sentence))
      # print('Predicted translation: {}'.format(result))
      return result[:-6]
  
  
  def image_to_txt():
      from google.colab import files
      uploaded = files.upload()
      # img_path='/content/won.png'
      for n in uploaded.keys():
          img_path = '/content/{}'.format(n)
      im = Image.open(img_path)
      display(im)
      info = pytesseract.image_to_string(Image.open(img_path))
      print("\n\n")
      print("Text from image: ", info)
      try:
          print("Translated text: ", translate(info))
      except:
          print("Can't translate.")