Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,44 +1,35 @@
|
|
1 |
import streamlit as st
|
2 |
-
import
|
3 |
-
import numpy as np
|
4 |
-
import pandas as pd
|
5 |
-
from sentence_transformers import SentenceTransformer, util
|
6 |
|
7 |
-
#
|
8 |
-
model = SentenceTransformer('paraphrase-MiniLM-L6-v2')
|
9 |
|
10 |
-
|
11 |
-
def check_plagiarism(text, stored_texts):
|
12 |
-
documents = stored_texts + [text]
|
13 |
-
embeddings = model.encode(documents, convert_to_tensor=True)
|
14 |
-
similarity_matrix = util.pytorch_cos_sim(embeddings[-1], embeddings[:-1])
|
15 |
-
|
16 |
-
highest_similarity = np.max(similarity_matrix.numpy())
|
17 |
-
return highest_similarity * 100
|
18 |
|
19 |
-
#
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
return df["text"].tolist()
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
32 |
|
33 |
-
#
|
34 |
-
st.
|
35 |
-
|
|
|
|
|
|
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
st.success("Text added to database for future reference.")
|
|
|
1 |
import streamlit as st
|
2 |
+
import requests
|
|
|
|
|
|
|
3 |
|
4 |
+
HF_BACKEND_URL = "https://your-backend-url.hf.space" # Update this with your backend link
|
|
|
5 |
|
6 |
+
st.title("π Plagiarism & AI Detector")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
# Text Plagiarism
|
9 |
+
st.subheader("π Check Text Plagiarism")
|
10 |
+
text = st.text_area("Enter text to check for plagiarism")
|
11 |
+
if st.button("Check Plagiarism"):
|
12 |
+
response = requests.post(f"{HF_BACKEND_URL}/check_text", params={"text": text})
|
13 |
+
st.json(response.json())
|
|
|
14 |
|
15 |
+
# Code Plagiarism
|
16 |
+
st.subheader("π» Check Code Plagiarism")
|
17 |
+
code = st.text_area("Paste code to check plagiarism")
|
18 |
+
if st.button("Check Code Plagiarism"):
|
19 |
+
response = requests.post(f"{HF_BACKEND_URL}/check_code", params={"code": code})
|
20 |
+
st.json(response.json())
|
21 |
|
22 |
+
# AI Detection
|
23 |
+
st.subheader("π€ Detect AI-Generated Content")
|
24 |
+
ai_text = st.text_area("Enter text to check AI detection")
|
25 |
+
if st.button("Detect AI"):
|
26 |
+
response = requests.post(f"{HF_BACKEND_URL}/detect_ai", params={"text": ai_text})
|
27 |
+
st.json(response.json())
|
28 |
|
29 |
+
# PDF Upload
|
30 |
+
st.subheader("π Upload PDF for Plagiarism Check")
|
31 |
+
pdf = st.file_uploader("Upload a PDF file", type=["pdf"])
|
32 |
+
if pdf:
|
33 |
+
files = {"file": pdf.getvalue()}
|
34 |
+
response = requests.post(f"{HF_BACKEND_URL}/upload_pdf", files=files)
|
35 |
+
st.json(response.json())
|
|