grammer / app.py
xy4286's picture
Update app.py
d8d2d48 verified
raw
history blame contribute delete
No virus
839 Bytes
import gradio as gr
from transformers import pipeline
# demo = gr.load("xy4286/yang-grammer-check", src="models")
# def greet(name):
# return "Hello " + name + "!"
# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
# demo.launch()
pipe = pipeline("text-classification", model="xy4286/yang-grammer-check")
def predict(sentence):
result = pipe(sentence)
# print(result)
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")
)
# if __name__ == "__main__":
demo.launch()
# gr.Textbox()