File size: 686 Bytes
f6fe135
 
050c119
 
 
 
f6fe135
050c119
f6fe135
050c119
 
 
f6fe135
050c119
 
 
 
f6fe135
050c119
f6fe135
050c119
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st
from transformers import pipeline
import tensorflow as tf
import numpy as np
from tensorflow.keras.layers import TextVectorization
from tensorflow import keras

model = tf.keras.models.load_model('toxicity_model.h5')

df = pd.read_csv('train.csv')
X = df['comment_text']
y = df[df.columns[2:]].values

MAX_FEATURES = 200000
vectorizer = TextVectorization(max_tokens=MAX_FEATURES,
                               output_sequence_length=1800,
                               output_mode='int')

vectorizer.adapt(X.values)

input_str = vectorizer('I hate you.')
res = model.predict(np.expand_dims(input_str,0))
classification = res[0].tolist()
st.write(classification)