oracat commited on
Commit
7365e02
·
1 Parent(s): c77734f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -3,18 +3,25 @@ import streamlit as st
3
 
4
 
5
  @st.cache_data
6
- def prepare():
 
 
 
7
  tokenizer = AutoTokenizer.from_pretrained("oracat/bert-paper-classifier")
8
  model = AutoModelForSequenceClassification.from_pretrained("oracat/bert-paper-classifier")
 
9
 
10
 
11
  def process(text):
 
 
 
12
  pipe = pipeline("text-classification", model=model, tokenizer=tokenizer)
13
  result = pipe(text)[0]
14
  return results['label']
15
 
16
 
17
- prepare()
18
 
19
  st.markdown("### Hello, paper classifier!")
20
 
 
3
 
4
 
5
  @st.cache_data
6
+ def prepare_model():
7
+ """
8
+ Prepare the tokenizer and the model for classification.
9
+ """
10
  tokenizer = AutoTokenizer.from_pretrained("oracat/bert-paper-classifier")
11
  model = AutoModelForSequenceClassification.from_pretrained("oracat/bert-paper-classifier")
12
+ return (tokenizer, model)
13
 
14
 
15
  def process(text):
16
+ """
17
+ Translate incoming text to tokens and classify it
18
+ """
19
  pipe = pipeline("text-classification", model=model, tokenizer=tokenizer)
20
  result = pipe(text)[0]
21
  return results['label']
22
 
23
 
24
+ tokenizer, model = prepare_model()
25
 
26
  st.markdown("### Hello, paper classifier!")
27