birdfsd_yolov5.label_studio_helpers package

Submodules

birdfsd_yolov5.label_studio_helpers.add_and_sync_new_project module

add_and_sync_data_storage(project_id: int, project_name: str, s3_endpoint_scheme: str = 'https://') dict[source]

Add the new project to label-studio, then sync its local data.

Parameters
  • project_id (str) – The id of the project to add the storage to.

  • project_name (str) – The name of the project to add the storage to.

  • s3_endpoint_scheme (str) – The scheme to use for the s3 endpoint. Defaults to ‘https://’.

Returns

The response from the sync request.

Return type

dict

add_new_project(new_project_folder_name: str) Optional[dict][source]

Creates a new project in Label Studio.

Parameters

new_project_folder_name (str) – The name of the new project.

Returns

The new project’s metadata.

Return type

dict

Raises

ValueError – If the project already exists.

birdfsd_yolov5.label_studio_helpers.create_rare_classes_view module

class CreateRareClassesView(project_id: int, model_version: str, method: str = 'median')[source]

Bases: object

Create a label-studio view tab with filters that shows rare classes.

create_view() Optional[dict][source]

Creates a new view in the project with the rare classes.

Returns

A dictionary containing the new view.

birdfsd_yolov5.label_studio_helpers.generate_patch_label_name_queries module

generate_queries(from_string: str, to_string: str) None[source]

Generate queries to update the database for replacing old label names.

Parameters
  • from_string (str) – The string to be replaced.

  • to_string (str) – The string to replace with.

Returns

None

birdfsd_yolov5.label_studio_helpers.sync_tasks module

sync_all_to_single_files(splits: int = 50) None[source]

Creates one file for all tasks and one file for all predictions.

Parameters

splits (int) – Number of chunks to split the list into before inserting to MongoDB.

Returns

None

sync_tasks(force_update: bool = False) None[source]

Synchronizes the tasks of all projects in the database.

Parameters

force_update (bool) – If True, the tasks will be updated even if they were already up-to-date.

Returns

None

birdfsd_yolov5.label_studio_helpers.utils module

get_all_projects_tasks(dump: Optional[Union[bool, str]] = None, get_predictions_instead: bool = False)[source]

Get all the tasks from all projects from the database.

The function gets all the tasks from the MongoDB database. returns a list of dictionaries, each dictionary containing the project name and the tasks associated with it.

Parameters
  • dump (Optional[Union[bool, str]]) – The JSON file containing the database dump.

  • get_predictions_instead (bool) – If True, the function returns the predictions instead of the actual tasks.

Returns

A list of dictionaries, each dictionary containing the project

name and the tasks associated with it.

Return type

list

update_model_version_in_all_projects(new_model_version: str) None[source]

Updates the selected default model version in all projects.

Parameters

new_model_version (str) – The new model version to be updated.

Returns

None

birdfsd_yolov5.label_studio_helpers.watchdog module

class WatchDog(root_data_folder: str, images_per_folder: int = 1000, debug: bool = False)[source]

Bases: object

Creates new projects when a change is detected in the source folder.

This class is used to create a new folder for the images to be stored in. The folder name is based on the current time and date. The folder is created in the root data folder. The folder name is returned.

validate_image_file(file: str) str[source]

Validates an image file.

Parameters

file (str) – The path to the image file.

Returns

The path to the image file.

Return type

str

Raises

UnidentifiedImageError – If the image file is corrupted.

watch()[source]

Monitor changes in the source and organize the data accordingly.

Returns

None

Module contents