paulm0016 commited on
Commit
4a46432
·
verified ·
1 Parent(s): 3df0dc4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # 使用 Hugging Face 的 fill-mask 模型
5
+ classifier = pipeline("fill-mask")
6
+
7
+ def fill_mask(text):
8
+ results = classifier(text, top_k=5)
9
+ return [f"{res['sequence']} (score: {res['score']:.4f})" for res in results]
10
+
11
+ # 创建 Gradio 界面
12
+ demo = gr.Interface(fn=fill_mask, inputs="text", outputs="text")
13
+
14
+ # 启动应用
15
+ demo.launch()