if args.square: if max_size == default_size: max_size = default_square_size else: if max_size > 100: print("Square mode, and size is {0}".format(max_size)) print("Error : Square size is too big.") sys.exit(1) head, tail = os.path.split(input_path) dir_path = os.path.join(head, tail + "_dataset") ds = DSUtils() ds.files_copy(input_path, dir_path) ds.files_change_ext(dir_path, ".jpeg", ".jpg") ds.img_convert_ext(dir_path, ".jpg") ds.files_lower_ext(dir_path) ds.files_remove_notjpg(dir_path) if not args.keepsize and args.square: ds.img_square(dir_path, max_size) elif not args.keepsize: ds.img_resize(dir_path, max_size) if not args.nodup: rdd.images_remove_duplicated(dir_path, "") ds.files_numbering(dir_path, name_header)
import sys import time # add module path script_path = os.path.dirname(os.path.realpath(__file__)) module_path = os.path.join(script_path, "myutils") sys.path.append(module_path) # my modules from create_dataset_utils import DSUtils # main function if __name__ == '__main__': argv = sys.argv argc = len(argv) if argc != 2: print("Error : The number of arguments must be one.") print("arg 1: The images directory path.") sys.exit(1) input_path = os.path.normpath(argv[1]) if not os.path.exists(os.path.join(os.getcwd(), input_path)): print("Error : Inputted path doesn't exist.") sys.exit(1) ds = DSUtils() ds.files_lower_ext(input_path)