Spaces:
Runtime error
Runtime error
Commit ·
09ffd87
1
Parent(s): 3d8f9f7
Update app.py
Browse files10 unmodified lines11121314151617181920 unmodified lines40414243444546474810 unmodified lines# @st.cachedef predict_topic_by_title_and_abstract(text):tokenized_text = tokenizer(text, return_tensors='pt', truncation=True)with torch.no_grad():logits = model(**tokenized_text).logitsprobs = torch.nn.functional.softmax(logits[0], dim=0).numpy() * 100ans = list(zip(probs,labels.values()))ans.sort(reverse=True)20 unmodified linesst.markdown("##### This app predicts the probabilities of the article belonging to the following topics: \'biology\', \'computer science\', \'economics\', \'electrics\', \'finance\', \'math\', \'physics\', \'statistics\'.")st.markdown("##### To get an article topic prediction, please write down it's title, abstract, or both.")title = st.text_area("Write article title:", height=30)abstract = st.text_area("Write article abstract:", height=60)input_text = title + " " + abstract10 unmodified lines11121314151617181920 unmodified lines40414243444546474810 unmodified lines# @st.cachedef predict_topic_by_title_and_abstract(text):tokens = tokenizer(text, return_tensors='pt', truncation=True)with torch.no_grad():logits = model(**tokens).logitsprobs = torch.nn.functional.softmax(logits[0], dim=0).numpy() * 100ans = list(zip(probs,labels.values()))ans.sort(reverse=True)20 unmodified linesst.markdown("##### This app predicts the probabilities of the article belonging to the following topics: \'biology\', \'computer science\', \'economics\', \'electrics\', \'finance\', \'math\', \'physics\', \'statistics\'.")st.markdown("##### To get an article topic prediction, please write down it's title, abstract, or both.")title = st.text_area("Write article title:", height=30, unsafe_allow_html=True)abstract = st.text_area("Write article abstract:", height=60, unsafe_allow_html=True)input_text = title + " " + abstract
app.py+4-4