minskiter's picture
feat(app.py): less code
dab5952
raw
history blame contribute delete
675 Bytes
from transformers import AutoTokenizer,AutoModel,BertTokenizer
from transformers.pipelines import pipeline
import gradio as gr
from huggingface_hub import login
import os
login(os.environ["HF_Token"])
ner_predictor = pipeline(
task="nerpipe",
model="minskiter/resume-token-classification",
device="cpu",
trust_remote_code=True,
use_auth_token=True
)
def ner_predictor_gradio(input):
entities = ner_predictor(input)
return {"text":input, "entities":entities}
demo = gr.Interface(
fn=ner_predictor_gradio,
inputs=gr.Textbox(lines=5, label="่พ“ๅ…ฅไฝ ็š„็ฎ€ๅŽ†"),
outputs=gr.HighlightedText(label="็ฎ€ๅŽ†่ฏ†ๅˆซ็ป“ๆžœ"),
)
demo.launch()