Base writer class#
This is the base class that other writers inherit from.
It enforces the use of the write()
method in all writers.
Bases: ABC
Source code in detection_datasets/writers/base.py
__init__(dataset, name, path, move_or_copy_images='copy')
#
Base class for writing datasets to disk.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset |
DetectionDataset
|
DetectionDataset instance. |
required |
name |
str
|
Name of the dataset to be created in the "path" directory. |
required |
path |
str
|
Path to the directory where the dataset will be created. |
required |
move_or_copy_images |
str
|
Wether to move or copy images from the source directory to the directory of the new dataset written to disk. Defaults to 'copy'. |
'copy'
|
Source code in detection_datasets/writers/base.py
do_move_or_copy_image(in_file, out_file)
#
Move or copy an image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_file |
str
|
Path to the existing image file. |
required |
out_file |
str
|
Directory where the image will be added. |
required |
Source code in detection_datasets/writers/base.py
write()
abstractmethod
#
Write the dataset to disk.
This method is specifc to each format, and need to be implemented in the writer class.
Mmdet writer#
This writer saves a dataset to disk in the MMdetection format, that is called "middle format" on the MMdetection documentation.
For more details check Tutorial 2: Customize Datasets on the MMdetection documentation.
Bases: BaseWriter
Source code in detection_datasets/writers/mmdet.py
__init__(**kwargs)
#
write()
#
Write the dataset to disk.
For the MMDET format, the associated steps are: 1. Create the directories for the images and annotations. 2. Prepare the data for any given split. 3. Write the annotation file to disk for each split. 4. Write the images to disk for each split.
Source code in detection_datasets/writers/mmdet.py
YOLO writer#
This writer saves a dataset to disk in the YOLO format.
Bases: BaseWriter
Write a dataset to a directory in the YOLO format.
Source code in detection_datasets/writers/yolo.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
__init__(**kwargs)
#
write()
#
Write the dataset to disk.
For the YOLO format, the associated steps are: 1. Write the YAML file. 2. Create the directories for the images and labels. 3. Write the images and labels.
Source code in detection_datasets/writers/yolo.py
COCO writer#
This writer saves a dataset to disk in the COCO format.
Bases: BaseWriter
Source code in detection_datasets/writers/coco.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|