beyond's picture
Update app.py
ac2870e
import gradio as gr
from transformers import pipeline
pipeline_en = pipeline(task="text-classification", model="Hello-SimpleAI/chatgpt-qa-detector-distil",use_auth_token=access_token)
# pipeline_en = pipeline_zh
# pipeline_zh = pipeline(task="text2text-generation", model="beyond/genius-base-chinese")
def predict_en(q,a):
res = pipeline_en({"text":q, "text_pair":a})
return res['label'],res['score']
def predict_zh(sketch):
# generated_text = pipeline_zh(sketch, num_beams=3, do_sample=True, max_length=200)[0]['generated_text']
# return generated_text.replace(' ','')
return ''
with gr.Blocks() as demo:
gr.Markdown("""
## ChatGPT detector
""")
with gr.Tab("English"):
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.")
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:\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.")
label = gr.Textbox(lines=1, label='Predicted Label πŸŽƒ')
score = gr.Textbox(lines=1, label='Prob')
button1 = gr.Button("πŸ€– Predict!")
# with gr.Tab("Chinese"):
# input2 = gr.Textbox(lines=5, value="")
# output2 = gr.Textbox(lines=5)
# output2 = output2
# button2 = gr.Button("Generate")
# with gr.Accordion("Open for More!"):
# gr.Markdown("Look at me...")
button1.click(predict_en, inputs=[q1,a1], outputs=[label,score])
# button2.click(predict_zh, inputs=input2, outputs=output2)
demo.launch()