File size: 839 Bytes
db2f6ec
bcaf841
db2f6ec
d8d2d48
 
 
 
 
6308316
 
bcaf841
d8d2d48
db2f6ec
d735449
d8d2d48
 
 
 
 
 
 
 
35a0487
d8d2d48
 
 
 
 
 
35a0487
 
d8d2d48
0aaaa8b
db2f6ec
 
0aaaa8b
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
29
30
31
32
33
34
35
36
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()