edit : hugging face login 로컬에 로그인되어있으면 무시

This commit is contained in:
2025-12-04 15:24:49 +09:00
parent ff54e1cc2d
commit fce9eedfae
2 changed files with 26 additions and 8 deletions

View File

@@ -31,6 +31,8 @@ import os, sys
from transformers import CLIPProcessor, CLIPModel
from huggingface_hub import login as huggingface_login
from huggingface_hub import whoami, logout
from huggingface_hub.utils import LocalTokenNotFoundError
"""
Package: custom
@@ -104,7 +106,18 @@ class FEOpenAIClipViT(FEM.FeatureExtractionModel):
# huggingface token
if self.huggingface_token:
huggingface_login(fem_arguments.token)
"""
토큰이 있다면 로그인이 되어있는지 확인
안되어있다면 로그인 시도
"""
try:
user_info = whoami()
except Exception as LocalTokenNotFoundError:
huggingface_login(fem_arguments.token)
except Exception as e:
log.error(f'Huggingface login error: {e}')
raise e
# model path check
if not os.path.exists(fem_arguments.trained_model):