Skip to content

Instantly share code, notes, and snippets.

@gabrielgarza
Last active January 6, 2019 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielgarza/a5c36eea46f14954976fe7ab4fa4c7e3 to your computer and use it in GitHub Desktop.
Save gabrielgarza/a5c36eea46f14954976fe7ab4fa4c7e3 to your computer and use it in GitHub Desktop.
train_ship_segmentations_df = pd.read_csv(os.path.join("./datasets/train_val/train_ship_segmentations.csv"))
msk = np.random.rand(len(train_ship_segmentations_df)) < 0.8
train = train_ship_segmentations_df[msk]
test = train_ship_segmentations_df[~msk]
# Move train set
for index, row in train.iterrows():
image_id = row["ImageId"]
old_path = "./datasets/train_val/{}".format(image_id)
new_path = "./datasets/train/{}".format(image_id)
if os.path.isfile(old_path):
os.rename(old_path, new_path)
# Move dev set
for index, row in test.iterrows():
image_id = row["ImageId"]
old_path = "./datasets/train_val/{}".format(image_id)
new_path = "./datasets/val/{}".format(image_id)
if os.path.isfile(old_path):
os.rename(old_path, new_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment