Exemplo n.º 1
0
# 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)

Exemplo n.º 2
0
# 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)

Exemplo n.º 3
0
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")

Exemplo n.º 4
0
        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)
Exemplo n.º 5
0
# 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)

Exemplo n.º 6
0
# 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)

Exemplo n.º 7
0
# 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)

Exemplo n.º 8
0
# 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)

Exemplo n.º 9
0
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)

Exemplo n.º 10
0
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)

Exemplo n.º 11
0
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)

Exemplo n.º 12
0
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)

Exemplo n.º 13
0
# 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")

Exemplo n.º 14
0
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)
Exemplo n.º 15
0
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")

Exemplo n.º 16
0
    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)

Exemplo n.º 17
0
# 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)


Exemplo n.º 18
0
# 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")

Exemplo n.º 19
0
# 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)

Exemplo n.º 20
0
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)

Exemplo n.º 21
0
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)