Spaces:
Build error
Build error
Upload 8 files
Browse files- app.py +41 -0
- images.png +0 -0
- models/ANN.h5 +3 -0
- models/gnb.pkl +3 -0
- models/svm.pkl +3 -0
- models/tfidf_vectorizer.pkl +3 -0
- models/vclf.pkl +3 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
import pickle
|
| 4 |
+
|
| 5 |
+
with open('models/svm.pkl', 'rb') as f:
|
| 6 |
+
svm = pickle.load(f)
|
| 7 |
+
with open('models/gnb.pkl', 'rb') as f:
|
| 8 |
+
gnb = pickle.load(f)
|
| 9 |
+
with open('models/vclf.pkl', 'rb') as f:
|
| 10 |
+
vclf = pickle.load(f)
|
| 11 |
+
with open('models/tfidf_vectorizer.pkl', 'rb') as file:
|
| 12 |
+
tfidf = pickle.load(file)
|
| 13 |
+
model=tf.keras.models.load_model('models/ANN.h5')
|
| 14 |
+
|
| 15 |
+
option = st.selectbox(
|
| 16 |
+
"Select the model",
|
| 17 |
+
("Naive Bayes", "Support Vector Machine", "Voting Classifier","ANN model"))
|
| 18 |
+
|
| 19 |
+
st.title("Detect AI generated text")
|
| 20 |
+
st.image("images.png")
|
| 21 |
+
user_input = st.text_area("Enter or paste the text here")
|
| 22 |
+
if st.button("Predict"):
|
| 23 |
+
user_input = user_input.strip()
|
| 24 |
+
if user_input != '':
|
| 25 |
+
vectorized_text=tfidf.transform([user_input]).toarray()
|
| 26 |
+
match option:
|
| 27 |
+
case "Naive Bayes":
|
| 28 |
+
prediction=gnb.predict(vectorized_text)
|
| 29 |
+
case "Support Vector Machine":
|
| 30 |
+
prediction=svm.predict(vectorized_text)
|
| 31 |
+
case "Voting Classifier":
|
| 32 |
+
prediction=vclf.predict(vectorized_text)
|
| 33 |
+
case "ANN model":
|
| 34 |
+
temp_result=model.predict(vectorized_text)
|
| 35 |
+
prediction=1 if temp_result>0.5 else 0
|
| 36 |
+
output="AI generated data" if prediction else "not an AI generated data"
|
| 37 |
+
st.write(f"The text is predicted as {output}")
|
| 38 |
+
else:
|
| 39 |
+
st.warning("Please enter text to be predicted")
|
| 40 |
+
|
| 41 |
+
|
images.png
ADDED
|
models/ANN.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d24c7d7dc84460107a6e506f18aa42709fe8d34f9e7c9627e2bcd08b93a36d70
|
| 3 |
+
size 397560
|
models/gnb.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ff0f19c41e34e82f5ddd6fd4bc3ac4f491790e81521f92bc88f3966537c4a9fa
|
| 3 |
+
size 5703
|
models/svm.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e60f9148260db17e8a1eb2e9fbafef418877926a69174b4cb7c7b72f743eec8c
|
| 3 |
+
size 7370949
|
models/tfidf_vectorizer.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:42053fa8a2c62fa3181a85e05c7710e311efb73e1ffed3af7eb87c33637eda72
|
| 3 |
+
size 23036611
|
models/vclf.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5ad7fa67bc82e6493d9c09b85e4c987ed76a4dd16bb1f0fff0db5ecbd8e22149
|
| 3 |
+
size 7379440
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit==1.36.0
|
| 2 |
+
scikit-learn==1.5.0
|
| 3 |
+
tensorflow==2.15.0
|