Spaces:
Sleeping
Sleeping
Commit
·
42d0b45
1
Parent(s):
b649cf6
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,16 +4,23 @@ import re
|
|
| 4 |
from simpletransformers.classification import ClassificationModel
|
| 5 |
from pythainlp import sent_tokenize
|
| 6 |
from thai_tokenization import ThaiTokenizer
|
|
|
|
| 7 |
|
| 8 |
-
tokenizer = ThaiTokenizer(vocab_file='th.wiki.bpe.op25000.vocab', spm_file='th.wiki.bpe.op25000.model')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
typeId = {'การเมือง': 0, 'กีฬา': 1, 'คุณภาพชีวิต': 2, 'ทั่วไทย': 3, 'ไลฟ์สไตล์': 4,
|
| 11 |
'อื่นๆ': 5, 'อาชญากรรม': 6, 'สิ่งแวดล้อม': 7, 'บันเทิง & วัฒนธรรม': 8, 'เศรษฐกิจ': 9,
|
| 12 |
'วิทยาศาสตร์ & การศึกษา': 10, 'สังคม': 11, 'unspecified': 12, 'ต่างประเทศ': 13}
|
| 13 |
|
| 14 |
loaded_model = ClassificationModel(
|
| 15 |
-
"
|
| 16 |
-
"SuperBigtoo/thainews-classification-
|
| 17 |
use_cuda=torch.cuda.is_available(),
|
| 18 |
num_labels=14,
|
| 19 |
)
|
|
|
|
| 4 |
from simpletransformers.classification import ClassificationModel
|
| 5 |
from pythainlp import sent_tokenize
|
| 6 |
from thai_tokenization import ThaiTokenizer
|
| 7 |
+
from transformers import AutoTokenizer
|
| 8 |
|
| 9 |
+
#tokenizer = ThaiTokenizer(vocab_file='th.wiki.bpe.op25000.vocab', spm_file='th.wiki.bpe.op25000.model')
|
| 10 |
+
|
| 11 |
+
#create tokenizer
|
| 12 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 13 |
+
'airesearch/wangchanberta-base-att-spm-uncased',
|
| 14 |
+
revision='main',
|
| 15 |
+
model_max_length=416,)
|
| 16 |
|
| 17 |
typeId = {'การเมือง': 0, 'กีฬา': 1, 'คุณภาพชีวิต': 2, 'ทั่วไทย': 3, 'ไลฟ์สไตล์': 4,
|
| 18 |
'อื่นๆ': 5, 'อาชญากรรม': 6, 'สิ่งแวดล้อม': 7, 'บันเทิง & วัฒนธรรม': 8, 'เศรษฐกิจ': 9,
|
| 19 |
'วิทยาศาสตร์ & การศึกษา': 10, 'สังคม': 11, 'unspecified': 12, 'ต่างประเทศ': 13}
|
| 20 |
|
| 21 |
loaded_model = ClassificationModel(
|
| 22 |
+
"camembert",
|
| 23 |
+
"SuperBigtoo/thainews-classification-wangchanberta",
|
| 24 |
use_cuda=torch.cuda.is_available(),
|
| 25 |
num_labels=14,
|
| 26 |
)
|