istassiy commited on
Commit
de1989c
·
1 Parent(s): e94b821

commit from

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import streamlit as st
2
  import numpy as np
3
- from tokenizers import Tokenizer
4
  from transformers import AutoTokenizer, AutoModel
5
 
6
  my_model_name = "istassiy/ysda_2022_ml2_hw3_distilbert_base_uncased"
@@ -80,11 +80,12 @@ paper_summary = st.text_area("Paper abstract")
80
  if not paper_title and not paper_summary:
81
  st.markdown(f"Must have non-empty title or summary")
82
  else:
83
- raw_predictions = model(
84
- **tokenizer(
85
- [paper_title + "." + paper_summary],
86
- padding=True, truncation=True, return_tensors="pt"
 
 
87
  )
88
- )
89
- results = get_top_predictions(raw_predictions[0].numpy())
90
- st.markdown(f"{results}")
 
1
  import streamlit as st
2
  import numpy as np
3
+ import torch
4
  from transformers import AutoTokenizer, AutoModel
5
 
6
  my_model_name = "istassiy/ysda_2022_ml2_hw3_distilbert_base_uncased"
 
80
  if not paper_title and not paper_summary:
81
  st.markdown(f"Must have non-empty title or summary")
82
  else:
83
+ with torch.no_grad():
84
+ raw_predictions = model(
85
+ **tokenizer(
86
+ [paper_title + "." + paper_summary],
87
+ padding=True, truncation=True, return_tensors="pt"
88
+ )
89
  )
90
+ results = get_top_predictions(raw_predictions[0].numpy())
91
+ st.markdown(f"{results}")