Skip to content

Instantly share code, notes, and snippets.

@kingardor
Last active June 1, 2021 13:26
Show Gist options
  • Save kingardor/9c519585266cd4715fa1deac73743760 to your computer and use it in GitHub Desktop.
Save kingardor/9c519585266cd4715fa1deac73743760 to your computer and use it in GitHub Desktop.
To generate train.txt/test.txt for YOLO object detection
'''
Usage: python3 classgen.py --input path >> train.txt
'''
import os
import argparse
def argsparser():
'''
To use arguments from command line.
'''
parser = argparse.ArgumentParser(description='Renamer script')
parser.add_argument('--input', dest='input', help='Input Directory', default='path', type=str)
return parser.parse_args()
if __name__ == '__main__':
args = argsparser()
files = os.listdir(args.input)
for f in files:
if 'jpg' in f:
print('data/obj/' + f)
@roboticlemon
Copy link

Tidy little script, just change the usage comment to traingen.py
Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment