File size: 1,184 Bytes
a0c9221
 
 
 
 
24e006f
a0c9221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import gradio as gr
from transformers import pipeline

auth_token = os.environ.get("access_token")
pipeline_en = pipeline(task="text-classification", model="afroz14/demomodel")


def predict_en(text):
    res = pipeline_en(text)[0]
    return res['label'],res['score']



with gr.Blocks() as demo:
    with gr.Tab("English"):
        gr.Markdown("""
                    Note: Providing more text to the `Text` box can make the prediction more accurate!
                    """)
        t1 = gr.Textbox(lines=5, label='Text',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.")
        button1 = gr.Button("🤖 Predict!")
        label1 = gr.Textbox(lines=1, label='Predicted Label 🎃')
        score1 = gr.Textbox(lines=1, label='Prob')

    button1.click(predict_en, inputs=[t1], outputs=[label1,score1])


demo.launch()