Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,30 @@
|
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
import gradio as gr
|
3 |
+
from transformers import pipeline
|
4 |
|
5 |
+
auth_token = os.environ.get("access_token")
|
6 |
+
pipeline_en = pipeline(task="text-classification", model="Hello-SimpleAI/chatgpt-detector-roberta",use_auth_token=auth_token)
|
7 |
+
|
8 |
+
|
9 |
+
def predict_en(text):
|
10 |
+
res = pipeline_en(text)[0]
|
11 |
+
label = res['label']
|
12 |
+
score = round(res['score']*100, 2)
|
13 |
+
return "%d%% chance"%score, label
|
14 |
+
|
15 |
+
|
16 |
+
with gr.Blocks() as demo:
|
17 |
+
gr.Markdown("""
|
18 |
+
# π€ Detect AI Plagiarism with Jurnee
|
19 |
+
Paste in the text you want to check and get a holistic score for how much of the document is written by AI. We recommend that educators take these results as one of many pieces in their assessment of student work. This model is based on Hello Simple's paper [arxiv: 2301.07597](https://arxiv.org/abs/2301.07597) and Github project [Hello-SimpleAI/chatgpt-comparison-detection](https://github.com/Hello-SimpleAI/chatgpt-comparison-detection).
|
20 |
+
""")
|
21 |
+
with gr.Tab("Try it out π"):
|
22 |
+
gr.Markdown("""
|
23 |
+
Note: Providing more text to the `Text` box can make the prediction more accurate!
|
24 |
+
""")
|
25 |
+
t1 = gr.Textbox(lines=5, label='Paste the text you want to check',value="There are a few things that can help protect your credit card information from being misused when you give it to a restaurant or any other business:\n\nEncryption: Many businesses use encryption to protect your credit card information when it is being transmitted or stored. This means that the information is transformed into a code that is difficult for anyone to read without the right key.")
|
26 |
+
button1 = gr.Button("π See results")
|
27 |
+
score1 = gr.Textbox(lines=1, label='There is a')
|
28 |
+
label1 = gr.Textbox(lines=1, label='That this text is written entirely by a')
|
29 |
+
|
30 |
+
button1.click(predict_en, inputs=[t1], outputs=[score1, label1])
|