Spaces:
Sleeping
Sleeping
Update app.py
Browse files36 unmodified lines37383940414243444041422 unmodified lines454647534849501 unmodified line5253546155565758595 unmodified lines6566676869707136 unmodified lines 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"
2 unmodified linesmem_before = process.memory_info().rss / (1024 * 1024)print(f"📦 모델 다운로드 전 메모리 사용량: {mem_before:.2f} MB")
# 모델 가중치 다운로드try: model_path = hf_hub_download(repo_id=HF_MODEL_REPO_ID, filename=HF_MODEL_FILENAME) print(f"✅ 모델 파일 다운로드 성공: {model_path}")1 unmodified line mem_after_dl = process.memory_info().rss / (1024 * 1024) print(f"📦 모델 다운로드 후 메모리 사용량: {mem_after_dl:.2f} MB")
# state_dict 로드 # 모델 구성 및 state_dict 로드 model = CustomClassifier() state_dict = torch.load(model_path, map_location=device) model.load_state_dict(state_dict) model.eval()5 unmodified lines print(f"❌ Error: 모델 로드 중 오류 발생: {e}") sys.exit(1)
# 예측 API@app.post("/predict")async def predict_api(request: Request):app.py+3-7