debugging 2
Browse files- Untitled.ipynb +7 -7
- app.py +3 -2
Untitled.ipynb
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
"execution_count": 1,
|
6 |
-
"id": "
|
7 |
"metadata": {},
|
8 |
"outputs": [
|
9 |
{
|
@@ -24,7 +24,7 @@
|
|
24 |
{
|
25 |
"cell_type": "code",
|
26 |
"execution_count": 18,
|
27 |
-
"id": "
|
28 |
"metadata": {},
|
29 |
"outputs": [],
|
30 |
"source": [
|
@@ -37,8 +37,8 @@
|
|
37 |
},
|
38 |
{
|
39 |
"cell_type": "code",
|
40 |
-
"execution_count":
|
41 |
-
"id": "
|
42 |
"metadata": {},
|
43 |
"outputs": [
|
44 |
{
|
@@ -52,7 +52,7 @@
|
|
52 |
" {'label': 'LABEL_3', 'score': 0.04354238137602806}]]"
|
53 |
]
|
54 |
},
|
55 |
-
"execution_count":
|
56 |
"metadata": {},
|
57 |
"output_type": "execute_result"
|
58 |
}
|
@@ -64,7 +64,7 @@
|
|
64 |
{
|
65 |
"cell_type": "code",
|
66 |
"execution_count": 6,
|
67 |
-
"id": "
|
68 |
"metadata": {},
|
69 |
"outputs": [],
|
70 |
"source": [
|
@@ -74,7 +74,7 @@
|
|
74 |
{
|
75 |
"cell_type": "code",
|
76 |
"execution_count": 11,
|
77 |
-
"id": "
|
78 |
"metadata": {},
|
79 |
"outputs": [
|
80 |
{
|
|
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
"execution_count": 1,
|
6 |
+
"id": "bdae1670",
|
7 |
"metadata": {},
|
8 |
"outputs": [
|
9 |
{
|
|
|
24 |
{
|
25 |
"cell_type": "code",
|
26 |
"execution_count": 18,
|
27 |
+
"id": "0e096b7a",
|
28 |
"metadata": {},
|
29 |
"outputs": [],
|
30 |
"source": [
|
|
|
37 |
},
|
38 |
{
|
39 |
"cell_type": "code",
|
40 |
+
"execution_count": 23,
|
41 |
+
"id": "6969c62c",
|
42 |
"metadata": {},
|
43 |
"outputs": [
|
44 |
{
|
|
|
52 |
" {'label': 'LABEL_3', 'score': 0.04354238137602806}]]"
|
53 |
]
|
54 |
},
|
55 |
+
"execution_count": 23,
|
56 |
"metadata": {},
|
57 |
"output_type": "execute_result"
|
58 |
}
|
|
|
64 |
{
|
65 |
"cell_type": "code",
|
66 |
"execution_count": 6,
|
67 |
+
"id": "db263028",
|
68 |
"metadata": {},
|
69 |
"outputs": [],
|
70 |
"source": [
|
|
|
74 |
{
|
75 |
"cell_type": "code",
|
76 |
"execution_count": 11,
|
77 |
+
"id": "bdb59ed1",
|
78 |
"metadata": {},
|
79 |
"outputs": [
|
80 |
{
|
app.py
CHANGED
@@ -19,7 +19,7 @@ labels = {'LABEL_0': 'toxic', 'LABEL_1': 'severe_toxic', 'LABEL_2': 'obscene', '
|
|
19 |
# make a dictionary of the labels with keys like "LABEL_0" and values like "toxic"
|
20 |
|
21 |
#text insert
|
22 |
-
input = st.text_area("
|
23 |
height=None, max_chars=None, key=None, help=None, on_change=None,
|
24 |
args=None, kwargs=None, placeholder=None, disabled=False,
|
25 |
label_visibility="visible")
|
@@ -36,7 +36,7 @@ if option == 'Fine-Tuned':
|
|
36 |
elif option == 'Roberta':
|
37 |
model = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
38 |
tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
39 |
-
classifier = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer)
|
40 |
else:
|
41 |
classifier = pipeline('sentiment-analysis')
|
42 |
|
@@ -46,6 +46,7 @@ if st.button('Analyze'):
|
|
46 |
print(result)
|
47 |
print(type(result))
|
48 |
output = None
|
|
|
49 |
if option == 'Fine-Tuned':
|
50 |
output = {'Toxic': result['LABEL_0']}
|
51 |
del result['LABEL_0']
|
|
|
19 |
# make a dictionary of the labels with keys like "LABEL_0" and values like "toxic"
|
20 |
|
21 |
#text insert
|
22 |
+
input = st.text_area("Insert text to be analyzed", value="Nice to see you today.",
|
23 |
height=None, max_chars=None, key=None, help=None, on_change=None,
|
24 |
args=None, kwargs=None, placeholder=None, disabled=False,
|
25 |
label_visibility="visible")
|
|
|
36 |
elif option == 'Roberta':
|
37 |
model = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
38 |
tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
39 |
+
classifier = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer, top_k=None)
|
40 |
else:
|
41 |
classifier = pipeline('sentiment-analysis')
|
42 |
|
|
|
46 |
print(result)
|
47 |
print(type(result))
|
48 |
output = None
|
49 |
+
result = result[0]
|
50 |
if option == 'Fine-Tuned':
|
51 |
output = {'Toxic': result['LABEL_0']}
|
52 |
del result['LABEL_0']
|