Rksafaryan commited on
Commit
5f7b93c
·
1 Parent(s): 338da22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -9
app.py CHANGED
@@ -3,7 +3,6 @@ import streamlit as st
3
  st.markdown("### Article Classifier")
4
  st.markdown("<img width=200px src='https://rozetked.me/images/uploads/dwoilp3BVjlE.jpg'>", unsafe_allow_html=True)
5
  st.markdown("This is a tool for classifying article category by it's title and summary. \n Follow the instructions below")
6
- # ^-- можно показывать пользователю текст, картинки, ограниченное подмножество html - всё как в jupyter
7
  from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
8
  import torch
9
  import numpy as np
@@ -13,9 +12,7 @@ model = AutoModelForSequenceClassification.from_pretrained("Wi/arxiv-topics-dist
13
  title = st.text_area("Put the title here")
14
  abstract = st.text_area("Put the abstract here")
15
  if st.button('Press when ready'):
16
-
17
  text = 'Title:' + title + '\n' + 'Abstract:' + abstract
18
- # ^-- показать текстовое поле. В поле text лежит строка, которая находится там в данный момент
19
 
20
  inputs = tokenizer(text, return_tensors="pt")
21
  with torch.no_grad():
@@ -29,12 +26,9 @@ if st.button('Press when ready'):
29
  while sum < 0.95:
30
  predicted_class_id.append(order[i])
31
  sum += probs[order[i]]
 
32
 
33
- #predicted_class_id = logits.argmax().item()
34
- # тут уже знакомый вам код с huggingface.transformers -- его можно заменить на что угодно от fairseq до catboost
35
  for id in predicted_class_id:
36
  st.markdown(model.config.id2label[id])
37
- st.markdown(id)
38
-
39
- #st.markdown(model.config.id2label[predicted_class_id])
40
- # выводим результаты модели в текстовое поле, на потеху пользователю
 
3
  st.markdown("### Article Classifier")
4
  st.markdown("<img width=200px src='https://rozetked.me/images/uploads/dwoilp3BVjlE.jpg'>", unsafe_allow_html=True)
5
  st.markdown("This is a tool for classifying article category by it's title and summary. \n Follow the instructions below")
 
6
  from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
7
  import torch
8
  import numpy as np
 
12
  title = st.text_area("Put the title here")
13
  abstract = st.text_area("Put the abstract here")
14
  if st.button('Press when ready'):
 
15
  text = 'Title:' + title + '\n' + 'Abstract:' + abstract
 
16
 
17
  inputs = tokenizer(text, return_tensors="pt")
18
  with torch.no_grad():
 
26
  while sum < 0.95:
27
  predicted_class_id.append(order[i])
28
  sum += probs[order[i]]
29
+ i+=1
30
 
31
+
 
32
  for id in predicted_class_id:
33
  st.markdown(model.config.id2label[id])
34
+