Spaces:
Runtime error
Runtime error
File size: 1,300 Bytes
1e4d53d |
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 37 38 39 40 41 42 43 44 |
from predictor import Predictor
from transformers import pipeline
from huggingface_hub import login
from datetime import date
import os
import gradio as gr
login(os.environ["HF_Token"])
paths = [
"data/W020230619818476939351.xls",
"data/W020230619818476975218.xls"
]
predictor = Predictor(
pipelines={
"name": pipeline("nerpipe", model="minskiter/resume-token-classification-name-0708",trust_remote_code=True,use_auth_token=True),
"common": pipeline("nerpipe",model="minskiter/resume-token-classification",trust_remote_code=True,use_auth_token=True)
},
paths=paths,
today=date(2023,4,1)
)
def ner_predictor_gradio(input):
entities = predictor(input)
# flattern entities
flatterns = []
for key in entities:
if isinstance(entities[key],list):
for item in entities[key]:
if isinstance(item,list):
for subitem in item:
flatterns.append(subitem)
else:
flatterns.append(item)
return {"text":input, "entities": flatterns}
demo = gr.Interface(
fn=ner_predictor_gradio,
inputs=gr.Textbox(lines=5, label="è¾“å…¥ä½ çš„ç®€åŽ†"),
outputs=gr.HighlightedText(label="简历识别结果"),
)
demo.launch()
|