Nucha commited on
Commit
24a30b7
·
verified ·
1 Parent(s): af76ff0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -15
app.py CHANGED
@@ -1,25 +1,12 @@
1
- import streamlit as st
2
  from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
3
- from accelerate import init_empty_weights, load_checkpoint_and_dispatch
4
 
5
  model_name = "Nucha/Nucha_ITSkillNER_BERT"
6
-
7
- # โหลด tokenizer
8
  tokenizer = AutoTokenizer.from_pretrained(model_name)
 
9
 
10
- # โหลด model แบบ meta และโหลด weights อย่างถูกต้อง
11
- with init_empty_weights():
12
- model = AutoModelForTokenClassification.from_pretrained(model_name)
13
-
14
- model = load_checkpoint_and_dispatch(
15
- model,
16
- model_name,
17
- device_map="auto"
18
- )
19
-
20
- # สร้าง NER pipeline
21
  ner_pipeline = pipeline("ner", model=model, tokenizer=tokenizer)
22
 
 
23
  # Mapping สีของ Entity
24
  ENTITY_COLORS = {
25
  "HSKILL": "#FFD700", # ทักษะเชิงเทคนิค
 
 
1
  from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
 
2
 
3
  model_name = "Nucha/Nucha_ITSkillNER_BERT"
 
 
4
  tokenizer = AutoTokenizer.from_pretrained(model_name)
5
+ model = AutoModelForTokenClassification.from_pretrained(model_name)
6
 
 
 
 
 
 
 
 
 
 
 
 
7
  ner_pipeline = pipeline("ner", model=model, tokenizer=tokenizer)
8
 
9
+
10
  # Mapping สีของ Entity
11
  ENTITY_COLORS = {
12
  "HSKILL": "#FFD700", # ทักษะเชิงเทคนิค