def __init__(self, dataset_dir=None):
        if dataset_dir:

            self.paths = ConfigPaths(dataset_dir)
        else:
            self.paths = ConfigPaths(dtst_dir)
 def __init__(self):
     self.paths = ConfigPaths(dataset_dir)
Exemple #3
0
import pandas as pd
from os.path import join
from argparse import ArgumentParser
"""
YOLO has 3 types of file:
1. image.jpg
2. image.txt --> 5 columns ==> class, xmin, ymin, w, h | normalized
3. classes.txt
"""

if __name__ == '__main__':
    parser = ArgumentParser()
    parser.add_argument('--dataset_dir', help='Root folder of dataset.')

    dataset_dir = ''
    paths = ConfigPaths(dataset_dir)
    df = pd.read_csv(join(paths.standard_format_dir, 'dataset.csv'),
                     index_col=0)

    for index, row in df.iterrows():
        frame_name = row['frame_name']
        classes = eval(row['class'])
        xmins = eval(row['xmin'])
        ymins = eval(row['ymin'])
        xmaxs = eval(row['xmax'])
        ymaxs = eval(row['ymax'])
        width = row['width']
        height = row['height']

        with open(
                join(paths.yolo_v5_pytorch_labels_dir,
from object_detection_dataset.constants._path_creator import ConfigPaths
if __name__ == '__main__':
    root_folder = 'E:\\Data Sets\\Detection\\Maritime\\COCO x SEAGULL\\'
    paths = ConfigPaths(root_folder, make_dirs=True)
Exemple #5
0
        categories, supercategories = [], []
        for category_id in category_ids:
            for val in self.data['categories']:
                if val['id'] == category_id:
                    categories.append(val['name'])
                    supercategories.append(val['supercategory'])
        return categories, supercategories

    def __find_bbox_of_id(self, image_id: int):
        total_bboxes = []
        category_ids = []
        id_list = []
        for val in self.data['annotations']:
            if val['image_id'] == image_id:
                total_bboxes.append(val['bbox'])
                category_ids.append(val['category_id'])
                id_list.append(val['id'])
        return total_bboxes, category_ids, id_list


if __name__ == '__main__':
    dataset_dir = 'E:\Data Sets\Detection\COCO\outputs\original_format'
    # dataset_dir = 'D:\Documents\Computer Vision\Object Detection\Datasets\COCO'
    paths = ConfigPaths(dataset_dir, False)
    json_path = os_path_join(dataset_dir, 'instances_train2017.json')

    handler = COCO_JSON_Handler(dataset_dir, json_path, extract_data=True)
    handler.set_json_dir(dataset_dir)
    handler.show_all_categories()
    handler.extract_categories(dataset_dir)
Exemple #6
0
import os
import pandas as pd
from object_detection_dataset.constants._path_creator import ConfigPaths
import shutil

if __name__ == '__main__':
    coco__folder = 'E:\\Data Sets\\Detection\\COCO\\'
    coco_paths = ConfigPaths(coco__folder, make_dirs=True)

    coco_x_seagull_folder = 'E:\\Data Sets\\Detection\\Maritime\\COCO x SEAGULL\\'
    coco_x_seagull_paths = ConfigPaths(coco_x_seagull_folder, make_dirs=True)

    coco_x_seagull_df = pd.read_csv(os.path.join(coco_x_seagull_paths.standard_format_dir, 'coco_x_seagull.csv'))

    for index, row in coco_x_seagull_df.iterrows():

        image_name = row['filename']
        src = os.path.join(coco_paths.images_dir, 'train2017', image_name)
        dst = os.path.join(coco_x_seagull_paths.images_dir, image_name)
        print('copying', image_name)
        print('From:', src)
        print('To:', dst)

        shutil.copy(src, dst)
Exemple #7
0
 def __init__(self, dataset_dir: str):
     self.paths = ConfigPaths(dataset_dir, make_dirs=False)
     self.standard_csv_path = os_path_join(self.paths.standard_format_dir, 'all.csv')