Created
January 11, 2017 11:47
-
-
Save moskomule/91cdc0d5fcace71e0c658730942794a4 to your computer and use it in GitHub Desktop.
create validation data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
import random | |
src_name = 'train/' | |
drc_name = 'val/' | |
src_dir = os.listdir(src_name)[1:] | |
for sub_src_dir in src_dir: | |
os.mkdir(drc_name+sub_src_dir) | |
files = os.listdir(src_name + sub_src_dir) | |
if len(files) > 10: | |
mov_files = random.sample(files, len(files)//4) | |
for f in mov_files: | |
shutil.move(src_name+sub_src_dir+"/"+f, drc_name+sub_src_dir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment