Spaces:
Runtime error
Runtime error
Matt C
commited on
Commit
·
bf79d0d
1
Parent(s):
632c54c
add chart
Browse files- app.py +6 -3
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
3 |
import torch
|
4 |
-
|
|
|
5 |
|
6 |
txt = st.text_area('Text to analyze', '''
|
7 |
It was the best of times, it was the worst of times, it was
|
@@ -19,4 +19,7 @@ model = AutoModelForSequenceClassification.from_pretrained("s-nlp/roberta_toxici
|
|
19 |
batch = tokenizer.encode('txt', return_tensors='pt')
|
20 |
|
21 |
# inference
|
22 |
-
model(batch)
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
|
|
2 |
import torch
|
3 |
+
import plotly.express as px
|
4 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
5 |
|
6 |
txt = st.text_area('Text to analyze', '''
|
7 |
It was the best of times, it was the worst of times, it was
|
|
|
19 |
batch = tokenizer.encode('txt', return_tensors='pt')
|
20 |
|
21 |
# inference
|
22 |
+
result = model(batch)
|
23 |
+
|
24 |
+
fig = px.bar(result, x="", y="", orientation='h')
|
25 |
+
fig.show()
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
transformers
|
2 |
-
torch
|
|
|
|
1 |
transformers
|
2 |
+
torch
|
3 |
+
plotly
|