@@ -0,0 +1,1386 @@
+import os%0Aimport argparse%0A%0A%0Adef arg():%0A    parser = argparse.ArgumentParser(description='Labeled Dataset Generator.')%0A    parser.add_argument('--input', '-i', type=str,%0A                        help='input dataset that contains labeled dataset.')%0A    parser.add_argument('--labeled', '-l', default=True,%0A                        help='Whether the dataset directories are named.')%0A    parser.add_argument('--names', '-n', type=str, default='',%0A                        help='labeled list of names.')%0A    parser.add_argument('--output', '-o', type=str, default='output.txt',%0A                        help='labeled output txt.')%0A    return parser.parse_args()%0A%0A%0Adef main():%0A    args = arg()%0A    dir_list = os.listdir(args.input)%0A    print(dir_list)%0A    if args.names:%0A        with open(args.names, 'w') as f:%0A            for name in dir_list:%0A                f.write(str(name) + '%5Cn')%0A%0A    result_list = %5B%5D%0A    for n_class, dir_name in enumerate(dir_list):%0A        target_dir = os.path.abspath(args.input) + '/' + dir_name%0A        img_list = os.listdir(target_dir)%0A        for img in img_list:%0A            abs_path_to_img = target_dir + '/' + img%0A            result_list.append((abs_path_to_img, str(n_class)))%0A%0A    with open(args.output, 'w') as fo:%0A        for abspath, n_class in result_list:%0A            fo.write('%7B%7D%5Ct%7B%7D%5Cn'.format(abspath, n_class))%0A%0Aif __name__ == '__main__':%0A    main()%0A

Add script dir.