from_darknet#
- from_darknet(dataset_path: Path | str | None = None, data_file: Path | str | None = None, ids_map: dict[int, dict[str, Any]] | str | Path | None = None, image_info: DataFrame | None = None) Dataset[source]#
Creates dataset object from a darknet dataset. Note that category ids and image ids are not given in the dataset format and thus can only be sequential As such, if we want to convert the dataset back to another format that keeps track of image and category ids, we need to give image_info and class mapping from an external source. Here we expect it to be contained in a json label map for annotations and a DataFrame with similar columns as in the final dataset’s images DataFrame for images
- Parameters:
dataset_path – folder containing the dataset, from which the relative path are given. If not set, will use
data_file’s parent directory. Defaults to Nonedata_file – data file containing info about names, lists of train and validation images. Can be either a .data file or a .yml file (for yolov5). If not set, will use the file
train_job.dataat the root ofdataset_path. Defaults to None.ids_map – Optional dictionary containing the id_remapping that was initially applied to create the darknet dataset. Will reverse it to get back to the original class mapping. The dictionary must have darknet dataset’s category ids (in sequential order then) as keys and with corresponding values that are dictionaries containing
nameandidkeys relative to this class. Note that this can also be a path to a json file containing the dictionary. Defaults to None.image_info – Optional DataFrame containing image information. Must contain at least the following columns :
relative_path,id,width,height. Defaults to None
- Raises:
ValueError – Errors when neither
dataset_pathnordata_fileis specified- Returns:
Loaded dataset object