Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,35 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
|
6 |
-
demo = gr.load("xy4286/yang-grammer-check", src="models")
|
7 |
|
|
|
8 |
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
16 |
|
17 |
|
|
|
18 |
demo.launch()
|
19 |
|
20 |
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# demo = gr.load("xy4286/yang-grammer-check", src="models")
|
5 |
+
# def greet(name):
|
6 |
+
# return "Hello " + name + "!"
|
7 |
+
# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
8 |
+
# demo.launch()
|
9 |
|
10 |
|
|
|
11 |
|
12 |
+
pipe = pipeline("text-classification", model="xy4286/yang-grammer-check")
|
13 |
|
14 |
|
15 |
+
def predict(sentence):
|
16 |
+
result = pipe(sentence)
|
17 |
+
# print(result)
|
18 |
+
if result[0]['label'] == 'LABEL_1' and result[0]['score'] > 0.5:
|
19 |
+
return "Grammatically Correct"
|
20 |
+
elif result[0]['label'] == 'LABEL_0' and result[0]['score'] > 0.5:
|
21 |
+
return "Grammatically Incorrect"
|
22 |
+
return result[0]
|
23 |
|
24 |
+
demo = gr.Interface(
|
25 |
+
fn=predict,
|
26 |
+
inputs = gr.Textbox(label="Please input a sentence to check"),
|
27 |
+
outputs = gr.Label(label="check result")
|
28 |
+
|
29 |
+
)
|
30 |
|
31 |
|
32 |
+
# if __name__ == "__main__":
|
33 |
demo.launch()
|
34 |
|
35 |
|