birdfsd_yolov5.preprocessing package
Submodules
birdfsd_yolov5.preprocessing.json2yolov5 module
- class birdfsd_yolov5.preprocessing.json2yolov5.JSON2YOLO(projects: str, output_dir: str = 'dataset-YOLO', only_tar_file: bool = False, enable_s3: bool = True, copy_data_from: Optional[str] = None, filter_underrepresented_cls: bool = False, filter_cls_with_instances_under: Optional[int] = None, get_tasks_with_api: bool = False, force_update: bool = False)[source]
Bases:
objectConverts the output of a Label-studio project to a YOLO dataset.
The output is a folder with the following structure:
dataset-YOLO ├── classes.txt ├── dataset_config.yml ├── images │ ├── train │ └── val └── labels ….├── train ….└── val
The output will also be stored in a tarball with the same name as the output folder.
The tasks that failed to export for any reason, will be logged at the end of the run.
- static bbox_ls_to_yolo(x: float, y: float, width: float, height: float) tuple[source]
From label-studio’s xywh to yolov5’s xywh.
Converts a bounding box from the format used by the labelme tool to the format used by the yolo tool.
- Parameters
x – The x coordinate of the top left corner of the bounding box.
y – The y coordinate of the top left corner of the bounding box.
width – The width of the bounding box.
height – The height of the bounding box.
- Returns
A tuple containing the x, y, width and height of the bounding box in the format used by the yolov5.
- Return type
tuple
- convert_to_yolo(task: dict) Optional[list][source]
Convert the task to YOLO format.
- Parameters
task (dict) – The task to be converted.
- Returns
The labels in the task.
- Return type
list
- Raises
FailedToParseImageURL – If the image URL is not valid.
TypeError – If the image URL is not valid.
- get_data(excluded_labels) list[source]
This function is used to get data from the database.
- Returns
A list of data.
- Return type
list
- plot_results(results: list) None[source]
Plots the results of the classification.
- Parameters
results (list) – The results of the classification.
- Returns
None
- run() None[source]
Runs the preprocessing pipeline.
This method is used to run main preprocessing pipeline and convert the data to the yolov5 format.
- Returns
None
- Raises
BucketDoesNotExist – If the dataset S3 bucket does not exist.