get_split#

Dataset.get_split(split: str | None) Self[source]#

Get a particular split from the dataset

Parameters:

split – Split name, usually “train”, “val”, “eval”. If set to None, will retrieve all image with a null split value (None, pd.NA or np.nan)

Returns:

filtered dataset, with only samples within the wanted split

See also

iter_splits()

Example

>>> from lours.utils.doc_utils import dummy_dataset
>>> example = dummy_dataset(
...     2,
...     2,
...     split_names=["train", "eval"],
...     split_shares=[0.5, 0.5],
...     seed=14,
... )
>>> example
Dataset object containing 2 images and 2 objects
Name :
    present_wait_even
Images root :
    blood/reflect
Images :
    width  height      relative_path   type  split
id
0     424     732  listen/reason.bmp   .bmp  train
1     179     413    return/man.jpeg  .jpeg   eval
Annotations :
    image_id category_str  category_id  ...   box_y_min   box_width  box_height
id                                      ...
0          1         film           24  ...  192.940695    2.862400   74.219110
1          0   especially            4  ...  419.039943  276.766197  119.753886

[2 rows x 8 columns]
Label map :
{4: 'especially', 19: 'similar', 24: 'film'}
>>> example.get_split("eval")
Dataset object containing 1 image and 1 object
Name :
    present_wait_even
Images root :
    blood/reflect
Images :
    width  height    relative_path   type split
id
1     179     413  return/man.jpeg  .jpeg  eval
Annotations :
    image_id category_str  category_id  ...   box_y_min  box_width  box_height
id                                      ...
0          1         film           24  ...  192.940695     2.8624    74.21911

[1 rows x 8 columns]
Label map :
{4: 'especially', 19: 'similar', 24: 'film'}