Spaces:
Sleeping
Sleeping
Update app.py
Browse files22 unmodified lines2324252627282926272829303132333435363738394041424344454622 unmodified linestokenizer = AutoTokenizer.from_pretrained("skt/kobert-base-v1")print("โ
ํ ํฌ๋์ด์ ๋ก๋ ์ฑ๊ณต.")
# ๋ชจ๋ธ ๊ตฌ์กฐ ์ฌ์ ์num_labels = len(category) # ๋ถ๋ฅํ ํด๋์ค ์์ ๋ฐ๋ผmodel = BertForSequenceClassification.from_pretrained("skt/kobert-base-v1", num_labels=num_labels)model.to(device)class CustomClassifier(torch.nn.Module): def __init__(self): super().__init__() # ์ ์ํ๋ ๊ตฌ์กฐ ๊ทธ๋๋ก ๋ณต์ํด์ผ ํจ self.bert = BertModel.from_pretrained("skt/kobert-base-v1") self.classifier = torch.nn.Linear(768, len(category))
def forward(self, input_ids, attention_mask=None, token_type_ids=None): outputs = self.bert(input_ids=input_ids, attention_mask=attention_mask, token_type_ids=token_type_ids) pooled_output = outputs[1] # CLS ํ ํฐ return self.classifier(pooled_output)
model = CustomClassifier()model.load_state_dict(torch.load(model_path, map_location=device))model.eval()
HF_MODEL_REPO_ID = "hiddenFront/TextClassifier"HF_MODEL_FILENAME = "textClassifierModel.pt"app.py+18-4