Spaces:
Build error
Build error
File size: 1,446 Bytes
106c79f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
import streamlit as st
import tensorflow as tf
import pickle
with open('models/svm.pkl', 'rb') as f:
svm = pickle.load(f)
with open('models/gnb.pkl', 'rb') as f:
gnb = pickle.load(f)
with open('models/vclf.pkl', 'rb') as f:
vclf = pickle.load(f)
with open('models/tfidf_vectorizer.pkl', 'rb') as file:
tfidf = pickle.load(file)
model=tf.keras.models.load_model('models/ANN.h5')
option = st.selectbox(
"\nSelect the model",
("Naive Bayes", "Support Vector Machine", "Voting Classifier","ANN model"))
st.title("Detect AI generated text")
st.image("images.png")
user_input = st.text_area("Enter or paste the text here")
if st.button("Predict"):
user_input = user_input.strip()
if user_input != '':
vectorized_text=tfidf.transform([user_input]).toarray()
match option:
case "Naive Bayes":
prediction=gnb.predict(vectorized_text)
case "Support Vector Machine":
prediction=svm.predict(vectorized_text)
case "Voting Classifier":
prediction=vclf.predict(vectorized_text)
case "ANN model":
temp_result=model.predict(vectorized_text)
prediction=1 if temp_result>0.5 else 0
output="AI generated data" if prediction else "not an AI generated data"
st.write(f"The text is predicted as {output}")
else:
st.warning("Please enter text to be predicted")
|