menikev commited on
Commit
21ac434
1 Parent(s): e3a293f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
+
4
+ @st.cache(allow_output_mutation=True)
5
+ def load_model():
6
+ tokenizer = AutoTokenizer.from_pretrained("./my_model")
7
+ model = AutoModelForSequenceClassification.from_pretrained("./my_model")
8
+ return model, tokenizer
9
+
10
+ model, tokenizer = load_model()
11
+
12
+ text_input = st.text_area("Enter text here:")
13
+ if st.button("Predict"):
14
+ inputs = tokenizer(text_input, return_tensors="pt")
15
+ outputs = model(**inputs)
16
+ prediction = outputs.logits.argmax(-1).item()
17
+ st.write(f"Prediction: {prediction}")