Spaces:
Runtime error
Runtime error
feat(app.py): less code
Browse files
app.py
CHANGED
@@ -4,25 +4,21 @@ import gradio as gr
|
|
4 |
from huggingface_hub import login
|
5 |
import os
|
6 |
login(os.environ["HF_Token"])
|
7 |
-
model = AutoModel.from_pretrained(
|
8 |
-
"minskiter/resume-token-classification",
|
9 |
-
use_auth_token=True,
|
10 |
-
trust_remote_code=True
|
11 |
-
)
|
12 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
13 |
-
"hfl/chinese-bert-wwm"
|
14 |
-
)
|
15 |
ner_predictor = pipeline(
|
16 |
task="nerpipe",
|
17 |
-
model=
|
18 |
-
config=model.config,
|
19 |
-
tokenizer=tokenizer,
|
20 |
device="cpu",
|
21 |
-
trust_remote_code=True
|
|
|
22 |
)
|
23 |
|
24 |
def ner_predictor_gradio(input):
|
25 |
-
|
|
|
26 |
|
27 |
-
demo = gr.Interface(
|
|
|
|
|
|
|
|
|
28 |
demo.launch()
|
|
|
4 |
from huggingface_hub import login
|
5 |
import os
|
6 |
login(os.environ["HF_Token"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
ner_predictor = pipeline(
|
8 |
task="nerpipe",
|
9 |
+
model="minskiter/resume-token-classification",
|
|
|
|
|
10 |
device="cpu",
|
11 |
+
trust_remote_code=True,
|
12 |
+
use_auth_token=True
|
13 |
)
|
14 |
|
15 |
def ner_predictor_gradio(input):
|
16 |
+
entities = ner_predictor(input)
|
17 |
+
return {"text":input, "entities":entities}
|
18 |
|
19 |
+
demo = gr.Interface(
|
20 |
+
fn=ner_predictor_gradio,
|
21 |
+
inputs=gr.Textbox(lines=5, label="è¾“å…¥ä½ çš„ç®€åŽ†"),
|
22 |
+
outputs=gr.HighlightedText(label="简历识别结果"),
|
23 |
+
)
|
24 |
demo.launch()
|