ShAnSantosh commited on
Commit
e9775e0
·
1 Parent(s): 120c541

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -12,6 +12,7 @@ tokenizer=BertTokenizer.from_pretrained("./")
12
 
13
 
14
  def predict(text=None) -> dict:
 
15
  model.eval()
16
  inputs = tokenizer(text, return_tensors="pt")
17
  input_ids = inputs["input_ids"].to(device)
@@ -23,7 +24,8 @@ def predict(text=None) -> dict:
23
  top_5_tokens = torch.topk(mask_token_logits, NUM_CLASSES, dim=1).indices[0].tolist()
24
  score = torch.nn.functional.softmax(mask_token_logits)[0]
25
  top_5_score = torch.topk(score, NUM_CLASSES).values.tolist()
26
- return {tokenizer.decode([tok]): score for tok, score in zip(top_5_tokens, top_5_score)}
 
27
 
28
  gr.Interface(fn=predict,
29
  inputs=gr.inputs.Textbox(lines=2, placeholder="Your Text… "),
 
12
 
13
 
14
  def predict(text=None) -> dict:
15
+ print(text)
16
  model.eval()
17
  inputs = tokenizer(text, return_tensors="pt")
18
  input_ids = inputs["input_ids"].to(device)
 
24
  top_5_tokens = torch.topk(mask_token_logits, NUM_CLASSES, dim=1).indices[0].tolist()
25
  score = torch.nn.functional.softmax(mask_token_logits)[0]
26
  top_5_score = torch.topk(score, NUM_CLASSES).values.tolist()
27
+ print(top_5_tokens)
28
+ return {tokenizer.decode([tok]): float(score) for tok, score in zip(top_5_tokens, top_5_score)}
29
 
30
  gr.Interface(fn=predict,
31
  inputs=gr.inputs.Textbox(lines=2, placeholder="Your Text… "),