# import os # from huggingface_hub import upload_folder # # Hugging Face 토큰을 환경 변수로 설정 # hf_token = os.getenv("HF_TOKEN") # # 현재 디렉토리 전체를 업로드 # folder_path = "." # 현재 디렉토리 # # Hugging Face 리포지토리에 폴더 업로드 # upload_folder( # folder_path=folder_path, # 업로드할 폴더 경로 # path_in_repo="", # 리포지토리 내 경로 (루트로 설정) # repo_id="yerang/txt2liveportrait", # 리포지토리 ID # token=hf_token # 환경 변수에서 토큰 사용 # ) import os from huggingface_hub import HfApi, upload_file from tqdm import tqdm # Hugging Face 토큰을 환경 변수로 설정 hf_token = os.getenv("HF_TOKEN") # 현재 디렉토리 전체를 업로드 folder_path = "." # 현재 디렉토리 repo_id = "yerang/txt2liveportrait" # 리포지토리 ID # Hugging Face API 인스턴스 생성 api = HfApi() # 제외할 폴더 및 파일 패턴 설정 exclude_dirs = {".git", ".ipynb_checkpoints"} exclude_files = {".gitignore", ".gitattributes", ".gitmodules"} # 파일 목록 가져오기 (필터링 포함) file_paths = [] for root, dirs, files in os.walk(folder_path): # 제외할 디렉토리를 탐색 대상에서 제외 dirs[:] = [d for d in dirs if d not in exclude_dirs] for file in files: if file not in exclude_files: # 제외할 파일 필터링 full_path = os.path.join(root, file) rel_path_in_repo = os.path.relpath(full_path, folder_path) file_paths.append((full_path, rel_path_in_repo)) # 파일 업로드 진행 상황 표시 for full_path, rel_path_in_repo in tqdm(file_paths, desc="Uploading files"): upload_file( path_or_fileobj=full_path, # 실제 파일 경로 path_in_repo=rel_path_in_repo, # 리포지토리 내 경로 repo_id=repo_id, # 리포지토리 ID token=hf_token # Hugging Face 토큰 )