Created
January 15, 2018 08:13
-
-
Save SeaOfOcean/0b4cc8bcc2a8b1961bb29c9d3f803901 to your computer and use it in GitHub Desktop.
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 | |
from os.path import isfile | |
import random | |
annots = os.listdir("annotations") | |
random.shuffle(annots) | |
test_len = int(len(annots) * 0.1) | |
train_data = annots[test_len:] | |
test_data = annots[:test_len] | |
f = open('ImageSets/train_messi.txt', 'w') | |
for annot in train_data: | |
name = annot[: annot.index('.xml')] | |
png_image = 'images/' + name + '.png' | |
if isfile(png_image): | |
f.write(png_image + "\t" + "annotations/" + annot + "\n") | |
f.close() | |
f = open('ImageSets/test_messi.txt', 'w') | |
for annot in test_data: | |
name = annot[: annot.index('.xml')] | |
png_image = 'images/' + name + '.png' | |
if isfile(png_image): | |
f.write(png_image + "\t" + "annotations/" + annot + "\n") | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment