|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pipe = pipeline("text-classification", model="xy4286/yang-grammer-check") |
|
|
|
|
|
def predict(sentence): |
|
result = pipe(sentence) |
|
|
|
if result[0]['label'] == 'LABEL_1' and result[0]['score'] > 0.5: |
|
return "Grammatically Correct" |
|
elif result[0]['label'] == 'LABEL_0' and result[0]['score'] > 0.5: |
|
return "Grammatically Incorrect" |
|
return result[0] |
|
|
|
demo = gr.Interface( |
|
fn=predict, |
|
inputs = gr.Textbox(label="Please input a sentence to check"), |
|
outputs = gr.Label(label="check result") |
|
|
|
) |
|
|
|
|
|
|
|
demo.launch() |
|
|
|
|
|
|