Spaces:
Sleeping
Sleeping
Update app.py
Browse files8 unmodified lines9101112131415161718192021222324252641 unmodified lines686970717273748 unmodified linesimport collectionsimport logging # 로깅 모듈 임포트# transformers의 AutoTokenizer 및 BertModel 임포트from transformers import AutoTokenizer, BertModelfrom torch.utils.data import Dataset, DataLoaderfrom huggingface_hub import hf_hub_download# --- 로깅 설정 ---# INFO 레벨 이상의 로그를 출력하도록 설정합니다.# 실제 배포 환경에서는 로그 레벨을 WARNING이나 ERROR로 높여 불필요한 로그를 줄일 수 있습니다.logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')logger = logging.getLogger(__name__)# --- 1. BERTClassifier 모델 클래스 정의 ---class BERTClassifier(torch.nn.Module):def __init__(self,bert,41 unmodified linesdef __len__(self):return len(self.labels)# --- 3. FastAPI 앱 및 전역 변수 설정 ---app = FastAPI()device = torch.device("cpu") # Hugging Face Spaces의 무료 티어는 주로 CPU를 사용합니다.8 unmodified lines910111213141516171819202141 unmodified lines6364656667688 unmodified linesimport collectionsimport logging # 로깅 모듈 임포트from transformers import AutoTokenizer, BertModelfrom torch.utils.data import Dataset, DataLoaderfrom huggingface_hub import hf_hub_downloadlogging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')logger = logging.getLogger(__name__)class BERTClassifier(torch.nn.Module):def __init__(self,bert,41 unmodified linesdef __len__(self):return len(self.labels)app = FastAPI()device = torch.device("cpu") # Hugging Face Spaces의 무료 티어는 주로 CPU를 사용합니다.
app.py-6