nickgardner commited on
Commit
25b8856
1 Parent(s): 77a996f

remove repeated call

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -16,6 +16,7 @@ tokenizer = get_tokenizer('spacy', language='en_core_web_sm')
16
  vocab = torch.load(hf_hub_download(repo_id="nickgardner/chatbot",
17
  filename="vocab.pth"))
18
  vocab_token_dict = vocab.get_stoi()
 
19
  pad_token = vocab_token_dict['<pad>']
20
  unknown_token = vocab_token_dict['<unk>']
21
  sos_token = vocab_token_dict['<sos>']
@@ -51,7 +52,7 @@ def respond(custom_string):
51
  outputs[i] = ix[0][0]
52
  if ix[0][0] == vocab_token_dict['<eos>']:
53
  break
54
- return ' '.join([vocab.get_itos()[ix] for ix in outputs[1:i]])
55
 
56
  iface = gr.Interface(fn=respond, inputs="text", outputs="text")
57
  iface.launch()
 
16
  vocab = torch.load(hf_hub_download(repo_id="nickgardner/chatbot",
17
  filename="vocab.pth"))
18
  vocab_token_dict = vocab.get_stoi()
19
+ indices_to_tokens = vocab.get_itos()
20
  pad_token = vocab_token_dict['<pad>']
21
  unknown_token = vocab_token_dict['<unk>']
22
  sos_token = vocab_token_dict['<sos>']
 
52
  outputs[i] = ix[0][0]
53
  if ix[0][0] == vocab_token_dict['<eos>']:
54
  break
55
+ return ' '.join([indices_to_tokens[ix] for ix in outputs[1:i]])
56
 
57
  iface = gr.Interface(fn=respond, inputs="text", outputs="text")
58
  iface.launch()