Plagarism_Check / app.py
AamerAkhter's picture
Create app.py
9b77e1f verified
raw
history blame contribute delete
812 Bytes
import gradio as gr
from sentence_transformers import SentenceTransformer, util
# Load the model
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
# Define the function to check plagiarism
def check_plagiarism(student_text, reference_text):
embeddings = model.encode([student_text, reference_text], convert_to_tensor=True)
similarity = util.cos_sim(embeddings[0], embeddings[1]).item()
return f"Similarity Score: {similarity:.2f}"
# Create the Gradio interface
iface = gr.Interface(
fn=check_plagiarism,
inputs=["text", "text"],
outputs="text",
title="Plagiarism Checker",
description="Enter a student submission and a reference text to compare similarity. Higher scores indicate higher similarity (possible plagiarism)."
)
# Launch the app
iface.launch()