Spaces:
Running
on
Zero
Running
on
Zero
File size: 873 Bytes
59b2a81 |
1 2 3 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 |
import os, shutil
import random
if __name__ == "__main__":
start_idx = 950
end_idx = 1020
select_num = 70
label_start_idx = 632
input_parent_dir = "../Bridge"
store_dir = "../bridge_select3"
if os.path.exists(store_dir):
shutil.rmtree(store_dir)
os.makedirs(store_dir)
for idx in range(start_idx, end_idx):
folder_path = os.path.join(input_parent_dir, str(idx))
select_idx = random.randint(0, len(os.listdir(folder_path)))
for idx, img_name in enumerate(os.listdir(folder_path)):
if idx == select_idx and img_name != "policy_out.pkl":
img_path = os.path.join(folder_path, img_name)
target_path = os.path.join(store_dir, str(label_start_idx) + ".jpg")
label_start_idx += 1
shutil.copy(img_path, target_path)
|