Upload copy_folders_from_data.py with huggingface_hub
Browse files- copy_folders_from_data.py +41 -41
copy_folders_from_data.py
CHANGED
|
@@ -1,43 +1,43 @@
|
|
| 1 |
-
import os
|
| 2 |
import json
|
|
|
|
| 3 |
import shutil
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
| 1 |
import json
|
| 2 |
+
import os
|
| 3 |
import shutil
|
| 4 |
+
from tqdm import tqdm
|
| 5 |
+
|
| 6 |
+
JSON_PATH = "./egocamera/data.json"
|
| 7 |
+
SRC_ROOT = "/net/holy-isilon/ifs/rc_labs/ydu_lab/sycen/data/rh20t/RH20T_cfg5"
|
| 8 |
+
DST_ROOT = "./egocamera"
|
| 9 |
+
|
| 10 |
+
with open(JSON_PATH, "r") as f:
|
| 11 |
+
data = json.load(f)
|
| 12 |
+
|
| 13 |
+
copied = set() # 防止重复 copy
|
| 14 |
+
|
| 15 |
+
for item in tqdm(data):
|
| 16 |
+
# 解析路径
|
| 17 |
+
# id: task_xxx/.../cam_id/frame_id
|
| 18 |
+
parts = item["id"].split("/")
|
| 19 |
+
task_folder = parts[0]
|
| 20 |
+
cam_id = parts[1]
|
| 21 |
+
|
| 22 |
+
cam_folder = f"cam_{cam_id}"
|
| 23 |
+
|
| 24 |
+
src_path = os.path.join(SRC_ROOT, task_folder, cam_folder)
|
| 25 |
+
dst_path = os.path.join(DST_ROOT, task_folder, cam_folder)
|
| 26 |
+
|
| 27 |
+
key = (task_folder, cam_folder)
|
| 28 |
+
|
| 29 |
+
# 防止重复复制
|
| 30 |
+
if key in copied:
|
| 31 |
+
continue
|
| 32 |
+
copied.add(key)
|
| 33 |
+
|
| 34 |
+
if not os.path.exists(src_path):
|
| 35 |
+
print(f"❌ Missing: {src_path}")
|
| 36 |
+
continue
|
| 37 |
+
|
| 38 |
+
os.makedirs(os.path.dirname(dst_path), exist_ok=True)
|
| 39 |
+
|
| 40 |
+
print(f"Copying: {src_path} → {dst_path}")
|
| 41 |
+
shutil.copytree(src_path, dst_path, dirs_exist_ok=True)
|
| 42 |
+
|
| 43 |
+
print("✅ Done!")
|