Spaces:
Sleeping
Sleeping
Asanaly commited on
Update app.py
Browse files12346 unmodified lines11121314151633 unmodified lines505152535455# app.pyimport gradio as grimport torchimport numpy as np6 unmodified linestokenizer = AutoTokenizer.from_pretrained(model_checkpoint)model = AutoModelForTokenClassification.from_pretrained(model_checkpoint, num_labels=7)label_list = ["O", "B-PER", "I-PER", "B-ORG", "I-ORG", "B-LOC", "I-LOC"]# ============================33 unmodified linescolor = "blue"elif label.startswith("LOC"):color = "green"colored_text = colored_text.replace(word, f"<span style='color:{color}; font-weight:bold'>{word}</span>")return colored_text123456 unmodified lines1213141516171833 unmodified lines52535455565758# app.pyimport gradio as grimport torchimport numpy as np6 unmodified linestokenizer = AutoTokenizer.from_pretrained(model_checkpoint)model = AutoModelForTokenClassification.from_pretrained(model_checkpoint, num_labels=7)# Қазақ NER үшін label тізіміlabel_list = ["O", "B-PER", "I-PER", "B-ORG", "I-ORG", "B-LOC", "I-LOC"]# ============================33 unmodified linescolor = "blue"elif label.startswith("LOC"):color = "green"# Мәтіндегі сөзді HTML span тегпен орауcolored_text = colored_text.replace(word, f"<span style='color:{color}; font-weight:bold'>{word}</span>")return colored_text
app.py+3