Ejemplo n.º 1
0
def get_detect_params(params_dict):
    main_dir = get_config('Common', 'dir')
    images = get_config('Paths', 'imagesdir')
    params = '--source ' + images
    params += ' --weights ' + f"{main_dir}/runs/train/{params_dict['name']}/weights/best.pt"
    params += ' --conf ' + params_dict['confidence']
    params += ' --name ' + params_dict['name']
    params += ' --save-txt --exist-ok'
    return params
Ejemplo n.º 2
0
def get_train_params(params_dict):
    params = '--epochs ' + params_dict['epochs']
    params += ' --batch ' + params_dict['batchsize']
    params += ' --workers ' + params_dict['workers']
    params += ' --name ' + params_dict['name']
    if params_dict['devices'] != 'CPU':
        params += ' --devices ' + params_dict['devices']
    if params_dict['imgsize'] != '':
        params += ' --img ' + params_dict['imgsize']

    params += " --weights '" + params_dict['weights'] + "'"

    data = get_config('Paths', 'datayaml')
    train = get_config('Paths', 'trainyaml')
    params += f" --data '{data}' --cfg '{train}'"

    params += ' --nosave --cache'

    return params
Ejemplo n.º 3
0
def listbox_values():
    folder = get_config('Common', 'dir') + '/runs/detect/exp/'
    print(folder)
    try:
        file_list = os.listdir(folder)
    except:
        file_list = []
    fnames = [
        f for f in file_list
        if os.path.isfile(os.path.join(folder, f)) and f.lower().endswith((
            ".jpg"))
    ]
    print(fnames)
    return fnames
Ejemplo n.º 4
0
def get_command_yolo(type_yolo):
    params = get_params('Yolo')
    params_dict = {}
    for param, value in params:
        params_dict[param] = value

    path = get_config('Paths', 'yolodir')

    if type_yolo == 'train':
        params_string = get_train_params(params_dict)
    elif type_yolo == 'detect':
        params_string = get_detect_params(params_dict)

    command = f'python {path}/{type_yolo}.py {params_string}'
    return command
Ejemplo n.º 5
0
def download_train_google():
    train_data_id = get_config('Download', 'traindataid')
    train_zip_path = get_config('Common', 'dir') + '/train.zip'

    download_file_from_google_drive(train_data_id, train_zip_path)
Ejemplo n.º 6
0
def convert_val():
    val_path = get_config('Paths', 'valdir')
    convert(val_path)
Ejemplo n.º 7
0
def convert_train():
    train_path = get_config('Paths', 'traindir')
    convert(train_path)
Ejemplo n.º 8
0
def unzip_val():
    val_zip_path = get_config('Common', 'dir') + '/val.zip'
    val_path = get_config('Paths', 'valdir')

    unzip(val_zip_path)
    exctract_from_visdrone_to_dir(val_path)
Ejemplo n.º 9
0
def unzip_train():
    train_zip_path = get_config('Common', 'dir') + '/train.zip'
    train_path = get_config('Paths', 'traindir')

    unzip(train_zip_path)
    exctract_from_visdrone_to_dir(train_path)
Ejemplo n.º 10
0
def download_val_google():
    val_data_id = get_config('Download', 'valdataid')
    val_zip_path = get_config('Common', 'dir') + '/val.zip'

    download_file_from_google_drive(val_data_id, val_zip_path)
Ejemplo n.º 11
0
def download_yolo():
    path = get_config('Paths', 'yolodir')
    yolo_url = get_config('Downloads', 'yololink')
    a = os.system(f'git clone {yolo_url} {path}')
    a = os.system(f'pip install -r {path}/requirements.txt')
Ejemplo n.º 12
0
def pictures_window():
    # --------------------------------- Define Layout ---------------------------------
    folder = get_config('Common', 'dir') + '/runs/detect/exp/'
    left_col = [
        [
            sg.Text('Folder'),
            sg.Input(default_text=folder,
                     size=(30, 1),
                     enable_events=True,
                     key='-FOLDER-'),
            sg.FolderBrowse()
        ],
        [
            sg.Listbox(values=listbox_values(),
                       enable_events=True,
                       size=(40, 61),
                       key='-FILE LIST-')
        ],
    ]

    images_col = [[sg.Text(size=(100, 1), key='-TOUT-')],
                  [
                      sg.Image(
                          key='-IMAGE-',
                          pad=(30, 15),
                      ),
                  ]]

    # ----- Full layout -----
    layout = [[
        sg.Column(left_col,
                  vertical_alignment='top',
                  element_justification='up'),
        sg.VSeperator(),
        sg.Column(images_col, element_justification='c')
    ]]

    # --------------------------------- Create Window ---------------------------------
    window = sg.Window('Detected data view',
                       layout,
                       resizable=False,
                       size=(1800, 1000))
    # --------------------------------- Event Loop ---------------------------------
    while True:
        event, values = window.read()
        if event in (sg.WIN_CLOSED, 'Exit'):
            break
        if event == sg.WIN_CLOSED or event == 'Exit':
            break
        if event == '-FOLDER-':
            folder = values['-FOLDER-']
            try:
                file_list = os.listdir(folder)
            except:
                file_list = []
            fnames = [
                f for f in file_list if os.path.isfile(os.path.join(folder, f))
                and f.lower().endswith((".jpg"))
            ]
            window['-FILE LIST-'].update(fnames)
        elif event == '-FILE LIST-':
            try:
                filename = os.path.join(values['-FOLDER-'],
                                        values['-FILE LIST-'][0])
                window['-TOUT-'].update(filename)
                new_size = None
                window['-IMAGE-'].update(
                    data=convert_to_bytes(filename, resize=new_size))
            except Exception as E:
                print(f'** Error {E} **')
                pass
    # --------------------------------- Close & Exit ---------------------------------
    window.close()