# my modules from create_dataset_utils import DSUtils # main function if __name__ == '__main__': argv = sys.argv argc = len(argv) if argc != 3: print("Error : The number of arguments must be one.") print("arg 1: The images directory path.") print("arg 2: Extraction color.") 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) color = str(argv[2]) if color != "red" and color != "green" and color != "blue": print("Error : Extraction color(arg 2) is invalid.") print("You have to input color red, green or blue.") sys.exit(1) ds = DSUtils() ds.img_color_extract(input_path, color)
# 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 != 3: print("Error : The number of arguments must be one.") print("arg 1: The File path.") print("arg 2: Resize ratio.") sys.exit(1) input_path = os.path.normpath(argv[1]) if not str.isdigit(argv[2].replace(".", "", 1)): print("Error : Resize ratio(arg 2) is not a number.") sys.exit(1) ratio = float(argv[2]) ds = DSUtils() ds.change_cvpos_ratio(input_path, ratio)
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.img_split_augmentation(input_path, "heavy")
sys.exit(1) max_size = args.size 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)
# modules import os 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) dir_path = os.path.normpath(argv[1]) ds = DSUtils() ds.files_remove_notjpg(dir_path) ds.files_remove_invalidjpg(dir_path)
# modules import os 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) dir_path = os.path.normpath(argv[1]) ds = DSUtils() ds.img_convert_ext(dir_path, ".jpg") ds.files_remove_invalidjpg(dir_path)
# main function if __name__ == '__main__': argv = sys.argv argc = len(argv) if argc != 4: print("Error : The number of arguments must be one.") print("arg 1: The images directory path.") print("arg 2: Size of images.") print("arg 3: Number of images.") 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) if not argv[2].isdigit(): print("Error : Size of images (arg 2) is not number.") sys.exit(1) size = int(argv[2]) if not argv[3].isdigit(): print("Error : Number of images (arg 3) is not number.") sys.exit(1) limit = int(argv[3]) ds = DSUtils() ds.img_random_crop(input_path, size, limit)
# 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 != 3: print("Error : The number of arguments must be one.") print("arg 1: The images directory path.") print("arg 2: Upper limit of image size.") sys.exit(1) dir_path = os.path.normpath(argv[1]) if not argv[2].isdigit(): print("Error : Upper limit of image (arg 2) is not number.") sys.exit(1) limit = int(argv[2]) ds = DSUtils() ds.img_resize_big(dir_path, limit)
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 != 3: print("Error : The number of arguments must be two.") print("arg 1: The images directory path.") print("arg 2: Maximum length (height or width).") sys.exit(1) if not argv[2].isdigit(): print("Error : Max size(arg 2) is not a number.") sys.exit(1) max_size = int(argv[2]) input_path = os.path.normpath(argv[1]) head, tail = os.path.split(input_path) dir_path = os.path.join(head, "{0}_resize{1}".format(tail, max_size)) ds = DSUtils() ds.files_copy(input_path, dir_path) ds.img_square(dir_path, max_size)
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__": # parsing arguments and option desc_str = "" parser = argparse.ArgumentParser(description=desc_str) parser.add_argument("-f", "--file", nargs=1, help="Path of input file") parser.add_argument("--csv-mode", action="store_true", default=False, help="Read information from CSV file") args = parser.parse_args() input_path = os.path.join(os.getcwd(), args.file[0]) if args.file is None: print("Error : Path of input file is needed.") sys.exit(1) elif not os.path.exists(input_path): print("Error : Input file doesn't exist.") sys.exit(1) ds = DSUtils() ds.img_trim_cvpos(input_path)
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)
from create_dataset_utils import DSUtils # main function if __name__ == '__main__': argv = sys.argv argc = len(argv) if argc != 4: print("Error : The number of arguments invalid.") print("arg 1: The dataset directory path.") print("arg 2: Rows of thumbnail.") print("arg 3: Columns of thumbnail.") sys.exit(1) dir_path = os.path.normpath(argv[1]) if not argv[2].isdigit(): print("Error : Rows of thumbnail (arg 2) is not number.") sys.exit(1) rows = int(argv[2]) if not argv[3].isdigit(): print("Error : Columns of thumbnail (arg 3) is not number.") sys.exit(1) cols = int(argv[3]) ds = DSUtils() ds.img_thumb_dir(dir_path, rows, cols)
# modules import os 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) dir_path = os.path.normpath(argv[1]) ds = DSUtils() ds.files_numbering(dir_path, "test")
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 != 3: print("Error : The number of arguments must be two.") print("arg 1: The images directory path.") print("arg 2: Maximum length (height or width).") sys.exit(1) if not argv[2].isdigit(): print("Error : Max size(arg 2) is not a number.") sys.exit(1) max_size = int(argv[2]) input_path = os.path.normpath(argv[1]) head, tail = os.path.split(input_path) dir_path = os.path.join(head, "{0}_resize{1}".format(tail, max_size)) ds = DSUtils() ds.files_copy(input_path, dir_path) ds.img_resize(dir_path, max_size)
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.img_split_augmentation(input_path, "light")
if not 4 <= argc <= 5: print("Error : The number of arguments invalid.") print("arg 1: The dataset directory path.") print("arg 2: Rows of thumbnail.") print("arg 3: Columns of thumbnail.") print("arg 4: Shift directory (option).") sys.exit(1) dir_path = os.path.normpath(argv[1]) if not argv[2].isdigit(): print("Error : Rows of thumbnail (arg 2) is not number.") sys.exit(1) rows = int(argv[2]) if not argv[3].isdigit(): print("Error : Columns of thumbnail (arg 3) is not number.") sys.exit(1) cols = int(argv[3]) if not argv[4].isdigit(): print("Error : Shift directory (arg 4) is not number.") sys.exit(1) shift = int(argv[4]) ds = DSUtils() ds.img_thumb_dataset(dir_path, rows, cols, shift)
# my modules from create_dataset_utils import DSUtils # main function if __name__ == '__main__': argv = sys.argv argc = len(argv) if argc != 3: print("Error : The number of arguments must be one.") print("arg 1: The images directory path.") print("arg 2: Size limit of images.") 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) if not argv[2].isdigit(): print("Error: Size limit of images (arg 2) is not number.") sys.exit(1) size_limit = int(argv[2]) ds = DSUtils() ds.img_split_quarter(input_path, size_limit)
# modules import os 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) dir_path = os.path.normpath(argv[1]) ds = DSUtils() ds.img_convert_ext(dir_path, ".bmp")
# 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 != 3: print("Error : The number of arguments must be one.") print("arg 1: The images directory path.") print("arg 2: Lower limit of image size.") sys.exit(1) dir_path = os.path.normpath(argv[1]) if not argv[2].isdigit(): print("Error : Limit of image (arg 2) is not number.") sys.exit(1) limit = int(argv[2]) ds = DSUtils() ds.img_remove_small(dir_path, limit)
from create_dataset_utils import DSUtils # main function if __name__ == '__main__': argv = sys.argv argc = len(argv) if argc != 4: print("Error : The number of arguments must be one.") print("arg 1: The images directory path.") print("arg 2: Lower limit of image width.") print("arg 3: Lower limit of image height.") sys.exit(1) dir_path = os.path.normpath(argv[1]) if not argv[2].isdigit(): print("Error : Lower limit of image width (arg 2) is not number.") sys.exit(1) limit_w = int(argv[2]) if not argv[3].isdigit(): print("Error : Lower limit of image height (arg 3) is not number.") sys.exit(1) limit_h = int(argv[3]) ds = DSUtils() ds.img_select_size(dir_path, limit_w, limit_h)
from create_dataset_utils import DSUtils # main function if __name__ == '__main__': argv = sys.argv argc = len(argv) if argc != 3: print("Error : The number of arguments must be one.") print("arg 1: The images directory path.") print("arg 2: The number of choice.") 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) if not argv[2].isdigit(): print("Error : The number of choice (arg 2) is not number.") sys.exit(1) num = int(argv[2]) head, tail = os.path.split(input_path) dir_path = os.path.join(head, "{0}_random{1}".format(tail, num)) ds = DSUtils() ds.files_random_choice(input_path, dir_path, num)