zjuJish commited on
Commit
876e66b
·
verified ·
1 Parent(s): b772857

Upload layer_diff_dataset/move_file.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. layer_diff_dataset/move_file.py +57 -0
layer_diff_dataset/move_file.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import subprocess
3
+
4
+ # source_directory = "/mnt/workspace/workgroup/sihui.jsh/pose_transfer_3/exp/pose_transfer"
5
+ # target_directory = "exp/pose_transfer"
6
+ def copy_without_folder(source_dir, target_dir, exclude_folder):
7
+ # 确保目标目录存在
8
+ # subprocess.run(["ossutil", "mb", target_dir], stderr=subprocess.PIPE)
9
+
10
+ # 获取源目录中的所有文件和子文件夹
11
+ items = os.listdir(source_dir)
12
+
13
+ for item in items:
14
+ source_item_path = os.path.join(source_dir, item)
15
+ # if not os.path.isdir(source_item_path):
16
+ # continue
17
+ # 如果是要排除的文件夹,则跳过
18
+ if item in exclude_folder:
19
+ # print(f"Skipping folder: {source_item_path}")
20
+ continue
21
+ target_item_path = os.path.join(target_dir, item)
22
+ print(item)
23
+ if os.path.isdir(source_item_path):
24
+ sub_items = os.listdir(source_item_path)
25
+ for sub_item in sub_items:
26
+ print(sub_item)
27
+ sub_source_item_path = os.path.join(source_item_path, sub_item)
28
+ sub_target_item_path = os.path.join(target_item_path, sub_item)
29
+ # 使用 cp -r 复制目录
30
+ print(f"Copied folder: {sub_source_item_path} to {sub_target_item_path}")
31
+ subprocess.run(["huggingface-cli", "upload", "zjuJish/layer_diff_dataset", sub_source_item_path, sub_target_item_path], stderr=subprocess.PIPE)
32
+ else:
33
+ # 使用 cp -r 复制目录
34
+ print(f"Copied folder: {source_item_path} to {target_item_path}")
35
+ subprocess.run(["huggingface-cli", "upload", "zjuJish/layer_diff_dataset", source_item_path, target_item_path], stderr=subprocess.PIPE)
36
+
37
+ if __name__ == "__main__":
38
+ # source_directory = "/mnt/workspace/workgroup/sihui.jsh/codes/CogVideo"
39
+ source_directory = "/mnt/workspace/workgroup/sihui.jsh/layer_diff_dataset"
40
+ target_directory = "layer_diff_dataset"
41
+
42
+ # # 打开文件并读取每行内容
43
+ # file_path = "move_list.txt" # 替换为你的文件路径
44
+ # lines_list = []
45
+
46
+ # with open(file_path, 'r', encoding='utf-8') as file:
47
+ # # 逐行读取文件并存入列表
48
+ # lines_list = file.readlines()
49
+
50
+ # # 去掉每行的换行符
51
+ # exclude_folder_name = [line.strip() for line in lines_list]
52
+
53
+ # exclude_folder_name = ["sat", "CogVideoX-2b-sat"]
54
+
55
+ # exclude_folder_name = [".ossutil_checkpoint", "ckpts_2b", "ckpts_2b_lora", "ossutil_output"]
56
+ exclude_folder_name = ["Transparant_dragdata_550","train"]
57
+ copy_without_folder(source_directory, target_directory, exclude_folder_name)