Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from sentence_transformers import SentenceTransformer, util
|
| 3 |
+
|
| 4 |
+
model = SentenceTransformer("paraphrase-MiniLM-L6-v2")
|
| 5 |
+
|
| 6 |
+
def check_similarity(text1, text2):
|
| 7 |
+
emb1 = model.encode(text1)
|
| 8 |
+
emb2 = model.encode(text2)
|
| 9 |
+
score = util.cos_sim(emb1, emb2).item() * 100
|
| 10 |
+
return f"Similarity: {score:.2f}%"
|
| 11 |
+
|
| 12 |
+
demo = gr.Interface(
|
| 13 |
+
fn=check_similarity,
|
| 14 |
+
inputs=[gr.Textbox(lines=6, label="Text 1"), gr.Textbox(lines=6, label="Text 2")],
|
| 15 |
+
outputs="text",
|
| 16 |
+
title="Free AI Plagiarism Checker",
|
| 17 |
+
description="Compare two texts using an AI model from Hugging Face."
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
demo.launch()
|