Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
auth_token = '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'
|
5 |
+
pipeline_en = pipeline(task="text-classification", model="Hello-SimpleAI/chatgpt-qa-detector-distil",use_auth_token=auth_token)
|
6 |
+
# pipeline_en = pipeline_zh
|
7 |
+
# pipeline_zh = pipeline(task="text2text-generation", model="beyond/genius-base-chinese")
|
8 |
+
|
9 |
+
|
10 |
+
def predict_en(q,a):
|
11 |
+
res = pipeline_en({"text":q, "text_pair":a})
|
12 |
+
return res['label'],res['score']
|
13 |
+
|
14 |
+
def predict_zh(sketch):
|
15 |
+
# generated_text = pipeline_zh(sketch, num_beams=3, do_sample=True, max_length=200)[0]['generated_text']
|
16 |
+
# return generated_text.replace(' ','')
|
17 |
+
return ''
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
|
22 |
+
with gr.Blocks() as demo:
|
23 |
+
gr.Markdown("""
|
24 |
+
## ChatGPT detector
|
25 |
+
""")
|
26 |
+
with gr.Tab("English"):
|
27 |
+
q1 = gr.Textbox(lines=2, label='Question',value="What stops a restaurant from noting down my credit card info and using it ? No offense to restaurants . Can be generalized to anyone who I give my credit card info to . Explain like I'm five.")
|
28 |
+
a1 = gr.Textbox(lines=5, label='Answer',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")
|
29 |
+
label = gr.Textbox(lines=1, label='Predicted Label 🎃')
|
30 |
+
score = gr.Textbox(lines=1, label='Prob')
|
31 |
+
button1 = gr.Button("🤖 Predict!")
|
32 |
+
# with gr.Tab("Chinese"):
|
33 |
+
# input2 = gr.Textbox(lines=5, value="")
|
34 |
+
# output2 = gr.Textbox(lines=5)
|
35 |
+
# output2 = output2
|
36 |
+
# button2 = gr.Button("Generate")
|
37 |
+
|
38 |
+
# with gr.Accordion("Open for More!"):
|
39 |
+
# gr.Markdown("Look at me...")
|
40 |
+
|
41 |
+
button1.click(predict_en, inputs=[q1,a1], outputs=[label,score])
|
42 |
+
# button2.click(predict_zh, inputs=input2, outputs=output2)
|
43 |
+
|
44 |
+
demo.launch()
|