JulianHame's picture
Update app.py
050c119
raw
history blame
686 Bytes
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)