Spaces:
Runtime error
Runtime error
Added model prediction
Browse files
app.py
CHANGED
@@ -1,22 +1,24 @@
|
|
1 |
import json
|
2 |
|
3 |
import streamlit as st
|
4 |
-
from transformers import AutoTokenizer, RobertaForSequenceClassification
|
5 |
|
6 |
|
7 |
with open("config.json") as f:
|
8 |
cfg = json.loads(f.read())
|
9 |
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
st.title("RoBERTa Marathi")
|
17 |
|
18 |
-
|
19 |
-
# generator, tokenizer = load_model()
|
20 |
|
21 |
input_text = st.text_input("Text:")
|
22 |
|
@@ -25,4 +27,5 @@ predict_button = st.button("Predict")
|
|
25 |
if predict_button:
|
26 |
with st.spinner("Generating prediction..."):
|
27 |
# Get prediction here
|
28 |
-
|
|
1 |
import json
|
2 |
|
3 |
import streamlit as st
|
4 |
+
from transformers import AutoTokenizer, RobertaForSequenceClassification, pipeline
|
5 |
|
6 |
|
7 |
with open("config.json") as f:
|
8 |
cfg = json.loads(f.read())
|
9 |
|
10 |
|
11 |
+
@st.cache(allow_output_mutation=True)
|
12 |
+
def load_model(input_text):
|
13 |
+
tokenizer = AutoTokenizer.from_pretrained(cfg["model_name_or_path"])
|
14 |
+
model = RobertaForSequenceClassification.from_pretrained(cfg["model_name_or_path"])
|
15 |
+
|
16 |
+
nlp = pipeline("text-classification", model=model, tokenizer=tokenizer)
|
17 |
+
result = nlp(input_text)
|
18 |
+
return result
|
19 |
|
|
|
20 |
|
21 |
+
st.title("RoBERTa Marathi")
|
|
|
22 |
|
23 |
input_text = st.text_input("Text:")
|
24 |
|
27 |
if predict_button:
|
28 |
with st.spinner("Generating prediction..."):
|
29 |
# Get prediction here
|
30 |
+
result = load_model(input_text)
|
31 |
+
st.write(result)
|