Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 5 |
+
'airesearch/wangchanberta-base-att-spm-uncased'
|
| 6 |
+
)
|
| 7 |
+
model = AutoModelForSequenceClassification.from_pretrained(
|
| 8 |
+
'airesearch/wangchanberta-base-att-spm-uncased',
|
| 9 |
+
revision='finetuned@wisesight_sentiment-v1.1',
|
| 10 |
+
)
|
| 11 |
+
text_cls_pipeline = pipeline(task='sentiment-analysis',
|
| 12 |
+
tokenizer=tokenizer,
|
| 13 |
+
model=model,
|
| 14 |
+
return_all_scores=True)
|
| 15 |
+
|
| 16 |
+
def main():
|
| 17 |
+
st.title("Text")
|
| 18 |
+
|
| 19 |
+
with st.form("text_field"):
|
| 20 |
+
text = st.text_area('enter some text:')
|
| 21 |
+
# clicked==True only when the button is clicked
|
| 22 |
+
clicked = st.form_submit_button("Submit")
|
| 23 |
+
if clicked:
|
| 24 |
+
results = text_cls_pipeline([text])
|
| 25 |
+
st.json(results)
|
| 26 |
+
|
| 27 |
+
if __name__ == "__main__":
|
| 28 |
+
main()
|