Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,17 +2,11 @@ import streamlit as st
|
|
2 |
import pandas as pd
|
3 |
import torch
|
4 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
5 |
-
import csv
|
6 |
import random as r
|
7 |
import gradio as gr
|
8 |
|
9 |
gr.Interface.load("models/APJ23/MultiHeaded_Sentiment_Analysis_Model").launch()
|
10 |
|
11 |
-
with open('test.csv','r') as f:
|
12 |
-
read = csv.reader(f)
|
13 |
-
data = [row for row in read]
|
14 |
-
df = pd.DataFrame(data[1:],columns=data[0])
|
15 |
-
tweet = df['comment_text'][r.randint(0,1000)]
|
16 |
tokenizer = AutoTokenizer.from_pretrained("APJ23/MultiHeaded_Sentiment_Analysis_Model", local_files_only=True)
|
17 |
model = AutoModelForSequenceClassification.from_pretrained("APJ23/MultiHeaded_Sentiment_Analysis_Model")
|
18 |
|
@@ -43,7 +37,7 @@ def create_table(predictions):
|
|
43 |
return df
|
44 |
|
45 |
st.title('Toxicity Prediction App')
|
46 |
-
st.
|
47 |
if st.button('Predict'):
|
48 |
predicted_class_label, predicted_prob = predict_toxicity(tweet, model, tokenizer)
|
49 |
prediction_text = f'Prediction: {predicted_class_label} ({predicted_prob:.2f})'
|
|
|
2 |
import pandas as pd
|
3 |
import torch
|
4 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
|
5 |
import random as r
|
6 |
import gradio as gr
|
7 |
|
8 |
gr.Interface.load("models/APJ23/MultiHeaded_Sentiment_Analysis_Model").launch()
|
9 |
|
|
|
|
|
|
|
|
|
|
|
10 |
tokenizer = AutoTokenizer.from_pretrained("APJ23/MultiHeaded_Sentiment_Analysis_Model", local_files_only=True)
|
11 |
model = AutoModelForSequenceClassification.from_pretrained("APJ23/MultiHeaded_Sentiment_Analysis_Model")
|
12 |
|
|
|
37 |
return df
|
38 |
|
39 |
st.title('Toxicity Prediction App')
|
40 |
+
tweet=st.text_input('Enter a tweet to check for toxicity')
|
41 |
if st.button('Predict'):
|
42 |
predicted_class_label, predicted_prob = predict_toxicity(tweet, model, tokenizer)
|
43 |
prediction_text = f'Prediction: {predicted_class_label} ({predicted_prob:.2f})'
|