minskiter commited on
Commit
dab5952
•
1 Parent(s): 07eca22

feat(app.py): less code

Browse files
Files changed (1) hide show
  1. app.py +10 -14
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=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
- return ner_predictor(input)
 
26
 
27
- demo = gr.Interface(fn=ner_predictor_gradio, inputs="text", outputs="text")
 
 
 
 
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()