anuragshas commited on
Commit
5648a79
1 Parent(s): cc4f03e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -7,7 +7,6 @@ from huggingface_hub import from_pretrained_keras
7
  import numpy as np
8
  import gradio as gr
9
 
10
- characters = {'b', 'n', 'w', 'c', '3', '5', '8', '7', '6', 'x', 'e', 'm', '2', 'd', 'f', 'y', '4', 'g', 'p'}
11
  max_length = 5
12
  img_width = 200
13
  img_height = 50
@@ -18,14 +17,12 @@ prediction_model = keras.models.Model(
18
  model.get_layer(name="image").input, model.get_layer(name="dense2").output
19
  )
20
 
21
- # Mapping characters to integers
22
- char_to_num = layers.StringLookup(
23
- vocabulary=list(characters), mask_token=None
24
- )
25
 
26
  # Mapping integers back to original characters
27
  num_to_char = layers.StringLookup(
28
- vocabulary=char_to_num.get_vocabulary(), mask_token=None, invert=True
29
  )
30
 
31
  def decode_batch_predictions(pred):
 
7
  import numpy as np
8
  import gradio as gr
9
 
 
10
  max_length = 5
11
  img_width = 200
12
  img_height = 50
 
17
  model.get_layer(name="image").input, model.get_layer(name="dense2").output
18
  )
19
 
20
+ with open("vocab.txt", "r") as f:
21
+ vocab = f.read().splitlines()
 
 
22
 
23
  # Mapping integers back to original characters
24
  num_to_char = layers.StringLookup(
25
+ vocabulary=vocab, mask_token=None, invert=True
26
  )
27
 
28
  def decode_batch_predictions(pred):