Spaces:
Running
on
Zero
Running
on
Zero
File size: 779 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 |
import os, sys, shutil
import random
if __name__ == "__main__":
base_dataset_path = "../datasets_rob/Bridge_v1_raw"
test_store_path = "../datasets_rob/Bridge_v1_test_raw"
split_ratio = 0.1 # [0, 1] range
# Prepare the folder
if os.path.exists(test_store_path):
shutil.rmtree(test_store_path)
os.makedirs(test_store_path)
full_img_lists = os.listdir(base_dataset_path)
random.shuffle(full_img_lists)
target_test_length = int(len(full_img_lists) * split_ratio)
test_img_lists = full_img_lists[-1 * target_test_length : ]
# Move the lists based on test_img_lists
for test_img_name in test_img_lists:
shutil.move(os.path.join(base_dataset_path, test_img_name), os.path.join(test_store_path, test_img_name))
|