Created
July 20, 2018 21:51
-
-
Save mikaelweave/3b8a598ebd790362d3e9d2eaa1a5a13b to your computer and use it in GitHub Desktop.
Taken files in a directory, get a random subset of them
This file contains hidden or 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, random | |
#Where the image folders live | |
hardshell_path = "gear_images/hardshell_jackets/" | |
insulated_path = "gear_images/insulated_jackets/" | |
#Play around with ratio training to run | |
train_ratio = 0.5 | |
set_hardshell = set(os.listdir(hardshell_path)) | |
set_insulated = set(os.listdir(insulated_path)) | |
train_hardshell = random.sample(set_hardshell, int(len(set_hardshell) * train_ratio)) | |
train_insulated = random.sample(set_insulated, int(len(set_insulated) * train_ratio)) | |
test_hardshell = set(set_hardshell) - set(train_hardshell) | |
test_insulated = set(set_insulated) - set(train_insulated) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment