Created
November 21, 2019 12:04
-
-
Save thecaffeinedev/70cd8778c103d55a3539e820d663697e to your computer and use it in GitHub Desktop.
YoloV3 Custom model
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 glob, os | |
# change the path of your images folder | |
dataset_path = '/home/thecaffeinedev/yolov3/training/images' | |
# Percentage of images to be used for the test set | |
percentage_test = 30; | |
# Create and/or truncate train.txt and test.txt | |
file_train = open('train.txt', 'w') | |
file_test = open('test.txt', 'w') | |
# Populate train.txt and test.txt | |
counter = 1 | |
index_test = round(100 / percentage_test) | |
for pathAndFilename in glob.iglob(os.path.join(dataset_path, "*.JPG")): | |
title, ext = os.path.splitext(os.path.basename(pathAndFilename)) | |
if counter == index_test+1: | |
counter = 1 | |
file_test.write(dataset_path + "/" + title + '.JPG' + "\n") | |
else: | |
file_train.write(dataset_path + "/" + title + '.JPG' + "\n") | |
counter = counter + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment