Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
from torch.nn.functional import softmax
|
|
|
4 |
import requests
|
5 |
from bs4 import BeautifulSoup
|
6 |
from sklearn.metrics.pairwise import cosine_similarity
|
@@ -11,9 +12,9 @@ tokenizer = RobertaTokenizer.from_pretrained(model_dir)
|
|
11 |
model = RobertaForSequenceClassification.from_pretrained(model_dir)
|
12 |
tokenizer1 = RobertaTokenizer.from_pretrained('roberta-base')
|
13 |
model1 = RobertaModel.from_pretrained('roberta-base')
|
|
|
14 |
#pipe = pipeline("text-classification", model="thugCodeNinja/robertatemp")
|
15 |
-
pipe = pipeline("text-classification",model=model,tokenizer=tokenizer)
|
16 |
-
threshold = 0.5
|
17 |
def process_text(input_text):
|
18 |
if input_text:
|
19 |
text = input_text
|
@@ -72,11 +73,11 @@ def process_text(input_text):
|
|
72 |
if similarity > threshold:
|
73 |
similar_articles.append([link,similarity])
|
74 |
similar_articles = sorted(similar_articles, key=lambda x: x[1], reverse=True)
|
75 |
-
|
76 |
return similar_articles[:5]
|
77 |
|
78 |
# prediction = pipe([text])
|
79 |
-
# explainer = shap.
|
80 |
# shap_values = explainer([text])
|
81 |
# shap_plot_html = HTML(shap.plots.text(shap_values, display=False)).data
|
82 |
similar_articles = find_plagiarism(text)
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
from torch.nn.functional import softmax
|
4 |
+
import shap
|
5 |
import requests
|
6 |
from bs4 import BeautifulSoup
|
7 |
from sklearn.metrics.pairwise import cosine_similarity
|
|
|
12 |
model = RobertaForSequenceClassification.from_pretrained(model_dir)
|
13 |
tokenizer1 = RobertaTokenizer.from_pretrained('roberta-base')
|
14 |
model1 = RobertaModel.from_pretrained('roberta-base')
|
15 |
+
threshold=0.5
|
16 |
#pipe = pipeline("text-classification", model="thugCodeNinja/robertatemp")
|
17 |
+
# pipe = pipeline("text-classification",model=model,tokenizer=tokenizer)
|
|
|
18 |
def process_text(input_text):
|
19 |
if input_text:
|
20 |
text = input_text
|
|
|
73 |
if similarity > threshold:
|
74 |
similar_articles.append([link,similarity])
|
75 |
similar_articles = sorted(similar_articles, key=lambda x: x[1], reverse=True)
|
76 |
+
#threshold = 0.5 # Adjust the threshold as needed
|
77 |
return similar_articles[:5]
|
78 |
|
79 |
# prediction = pipe([text])
|
80 |
+
# explainer = shap.DeepExplainer(model,[text])
|
81 |
# shap_values = explainer([text])
|
82 |
# shap_plot_html = HTML(shap.plots.text(shap_values, display=False)).data
|
83 |
similar_articles = find_plagiarism(text)
|