NLP
huggingface repository create / delete / clone / push
thisisw
2024. 3. 28. 15:35
# jupyter notebook에서 hugging face 로그인
from huggingface_hub import notebook_login
notebook_login()
# repository 생성 / 삭제
from huggingface_hub import create_repo
# Repository 생성
create_repo(name=REPO_NAME)
# Repository 삭제
delete_repo(name=REPO_NAME)
# 원격 저장소 clone
from huggingface_hub import Repository
# LOCAL_DIR_NAME : 저장할 로컬 저장소 이름
# NAMESPACE/REPO_NAME : huggingface의 repository 이름
repo = Repository(LOCAL_DIR_NAME, clone_from=NAMESPACE/REPO_NAME)
# git clone https://huggingface.co/username/repository_name
# 내가 로컬에서 train한 model을 clone한 폴더로 옮긴 뒤, git으로 push
!cp -r model/* LOCAL_DIR_NAME
repo.git_add()
repo.git_commit('update model') # 커밋메시지 작성
repo.git_push()