Chih-Hsu Lin commited on
Commit
2512f99
1 Parent(s): 7c3fcab

Fixed typo

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -20,13 +20,14 @@ def pred_is_elon_musk(text):
20
  masks = torch.Tensor([masks]).to(device, dtype=torch.int32)
21
  results = model(input_ids=ids, token_type_ids=None,
22
  attention_mask=masks)
23
- logis = results['logits']
24
  prob = F.softmax(logis, dim=1)[0]
25
- prediction = np.argmax(logis.detach().numpy(), axis=1).flatten()
26
  if prediction[0] == 1:
27
- return f"It's from Elon Musk with {prob[0]*100: 0.2f}% probability."
28
  else:
29
- return "It's NOT from Elon Musk with {prob[1]*100: 0.2f}% probability."
 
30
 
31
  iface = gr.Interface(pred_is_elon_musk, inputs="text",
32
  outputs="text", title='“Is the tweet from Elon Musk?” Classifier',
 
20
  masks = torch.Tensor([masks]).to(device, dtype=torch.int32)
21
  results = model(input_ids=ids, token_type_ids=None,
22
  attention_mask=masks)
23
+ logis = results['logits'].detach()
24
  prob = F.softmax(logis, dim=1)[0]
25
+ prediction = np.argmax(logis.numpy(), axis=1).flatten()
26
  if prediction[0] == 1:
27
+ output = f"It's from Elon Musk with {prob[0]*100: 0.2f}% probability."
28
  else:
29
+ output = f"It's NOT from Elon Musk with {prob[1]*100: 0.2f}% probability."
30
+ return output
31
 
32
  iface = gr.Interface(pred_is_elon_musk, inputs="text",
33
  outputs="text", title='“Is the tweet from Elon Musk?” Classifier',