Spaces:
Runtime error
Runtime error
add zh
Browse files
app.py
CHANGED
|
@@ -5,8 +5,8 @@ from transformers import pipeline
|
|
| 5 |
auth_token = os.environ.get("access_token")
|
| 6 |
pipeline_en = pipeline(task="text-classification", model="MeiJuice/CheckGPT",
|
| 7 |
use_auth_token=auth_token)
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
| 11 |
|
| 12 |
def predict_en(text):
|
|
@@ -14,9 +14,9 @@ def predict_en(text):
|
|
| 14 |
return res['label'], res['score']
|
| 15 |
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
|
| 21 |
|
| 22 |
with gr.Blocks() as demo:
|
|
@@ -29,22 +29,22 @@ with gr.Blocks() as demo:
|
|
| 29 |
button1 = gr.Button("🤖 Predict!")
|
| 30 |
label1 = gr.Textbox(lines=1, label='Predicted Label 🎃')
|
| 31 |
score1 = gr.Textbox(lines=1, label='Prob')
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
button1.click(predict_en, inputs=[t1], outputs=[label1, score1], api_name='predict_en')
|
| 43 |
-
|
| 44 |
|
| 45 |
# # Page Count
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
|
| 50 |
demo.launch()
|
|
|
|
| 5 |
auth_token = os.environ.get("access_token")
|
| 6 |
pipeline_en = pipeline(task="text-classification", model="MeiJuice/CheckGPT",
|
| 7 |
use_auth_token=auth_token)
|
| 8 |
+
pipeline_zh = pipeline(task="text-classification", model="MeiJuice/CheckGPT-Chinese",
|
| 9 |
+
use_auth_token=auth_token)
|
| 10 |
|
| 11 |
|
| 12 |
def predict_en(text):
|
|
|
|
| 14 |
return res['label'], res['score']
|
| 15 |
|
| 16 |
|
| 17 |
+
def predict_zh(text):
|
| 18 |
+
res = pipeline_zh(text)[0]
|
| 19 |
+
return res['label'], res['score']
|
| 20 |
|
| 21 |
|
| 22 |
with gr.Blocks() as demo:
|
|
|
|
| 29 |
button1 = gr.Button("🤖 Predict!")
|
| 30 |
label1 = gr.Textbox(lines=1, label='Predicted Label 🎃')
|
| 31 |
score1 = gr.Textbox(lines=1, label='Prob')
|
| 32 |
+
with gr.Tab("中文版"):
|
| 33 |
+
gr.Markdown("""
|
| 34 |
+
注意: 在`文本`栏中输入更多的文本,可以让预测更准确哦!
|
| 35 |
+
""")
|
| 36 |
+
t2 = gr.Textbox(lines=5, label='文本',
|
| 37 |
+
value="对于OpenAI大力出奇迹的工作,自然每个人都有自己的看点。我自己最欣赏的地方是ChatGPT如何解决 “AI校正(Alignment)“这个问题。这个问题也是我们课题组这两年在探索的学术问题之一。")
|
| 38 |
+
button2 = gr.Button("🤖 预测!")
|
| 39 |
+
label2 = gr.Textbox(lines=1, label='预测结果 🎃')
|
| 40 |
+
score2 = gr.Textbox(lines=1, label='模型概率')
|
| 41 |
|
| 42 |
button1.click(predict_en, inputs=[t1], outputs=[label1, score1], api_name='predict_en')
|
| 43 |
+
button2.click(predict_zh, inputs=[t2], outputs=[label2, score2], api_name='predict_zh')
|
| 44 |
|
| 45 |
# # Page Count
|
| 46 |
+
gr.Markdown("""
|
| 47 |
+
<center><a href='https://clustrmaps.com/site/1bsdc' title='Visit tracker'><img src='//clustrmaps.com/map_v2.png?cl=080808&w=a&t=tt&d=NXQdnwxvIm27veMbB5F7oHNID09nhSvkBRZ_Aji9eIA&co=ffffff&ct=808080'/></a></center>
|
| 48 |
+
""")
|
| 49 |
|
| 50 |
demo.launch()
|