arabeh commited on
Commit
ee3e4ce
·
2 Parent(s): 6de4dbc 9ee0fca

Merge branch 'main' of https://huggingface.co/datasets/BGLab/FlowBench

Browse files
Files changed (1) hide show
  1. README.md +14 -21
README.md CHANGED
@@ -73,32 +73,25 @@ pip install huggingface_hub
73
  The following script demonstrates how to download a directory from the Hugging Face Hub:
74
 
75
  ```python
76
- from huggingface_hub import HfApi, hf_hub_download
77
- import os
78
- import shutil
79
 
80
- REPO_ID = "BGLab/FlowBench"
81
- DIRECTORY = "LDC_NS_2D"
82
 
83
- # Initialize the Hugging Face API
84
- api = HfApi()
 
85
 
86
- # List files in the directory
87
- files_list = api.list_repo_files(repo_id=REPO_ID, repo_type="dataset")
 
 
88
 
89
- # Filter the files in the specified directory
90
- files_to_download = [f for f in files_list if f.startswith(DIRECTORY)]
 
91
 
92
- # Create local directory if it doesn't exist
93
- os.makedirs(DIRECTORY, exist_ok=True)
94
-
95
- # Download each file
96
- for file in files_to_download:
97
- file_path = hf_hub_download(repo_id=REPO_ID, filename=file, repo_type="dataset")
98
- # Copy the file to the local directory using shutil.copy2
99
- shutil.copy2(file_path, os.path.join(DIRECTORY, os.path.basename(file_path)))
100
-
101
- print("Files downloaded successfully.")
102
 
103
  ```
104
 
 
73
  The following script demonstrates how to download a directory from the Hugging Face Hub:
74
 
75
  ```python
76
+ from huggingface_hub import login, snapshot_download
 
 
77
 
78
+ # Hugging Face access token (replace with your token)
79
+ hf_token = ""
80
 
81
+ # Login to Hugging Face using the token
82
+ print("Logging into Hugging Face...")
83
+ login(token=hf_token)
84
 
85
+ # Specify repository and folder details
86
+ repo_id = "BGLab/FlowBench" # Repository ID on Hugging Face
87
+ dataset_path = "FPO_NS_2D_1024x256" # Folder path within the repository
88
+ output_dir = "./downloaded_folder" # Local directory to save the folder
89
 
90
+ # Download the entire repository or specific folder
91
+ print(f"Downloading folder '{dataset_path}' from repository '{repo_id}'...")
92
+ snapshot_download(repo_id, repo_type="dataset", local_dir=output_dir, allow_patterns=[f"{dataset_path}/*"])
93
 
94
+ print(f"Folder downloaded successfully to {output_dir}!")
 
 
 
 
 
 
 
 
 
95
 
96
  ```
97