Updating download instructions
Browse files
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
|
| 77 |
-
import os
|
| 78 |
-
import shutil
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
|
| 83 |
-
#
|
| 84 |
-
|
|
|
|
| 85 |
|
| 86 |
-
#
|
| 87 |
-
|
|
|
|
|
|
|
| 88 |
|
| 89 |
-
#
|
| 90 |
-
|
|
|
|
| 91 |
|
| 92 |
-
|
| 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 |
|