reset_images_root#

Dataset.reset_images_root(new_path: Path | str) Self[source]#

Replace the images_root with a new path. Relative path to images are updated accordingly so that new_path/new_relative_path still point to the right path.

Parameters:

new_path – New path to replace current images_root with

Returns:

New dataset object with updated images (relative_path column) and images_root.

Example

>>> from lours.utils.doc_utils import dummy_dataset
>>> example = dummy_dataset(2, 2, seed=1, generate_real_images=True)
>>> example
Dataset object containing 2 images and 2 objects
Name :
    shake_effort_many
Images root :
    /tmp/care/suggest
Images :
    width  height        relative_path  type  split
id
0     955     229  determine/story.jpg  .jpg  train
1     131     840       air/method.bmp  .bmp  train
Annotations :
    image_id category_str  category_id  ...   box_y_min   box_width  box_height
id                                      ...
0          1       listen           14  ...  276.974642    9.718823  184.684056
1          0        reach           22  ...    6.311037  123.141689  174.239136

[2 rows x 8 columns]
Label map :
{14: 'listen', 15: 'marriage', 22: 'reach'}
>>> example.check()
Checking Image and annotations Ids ...
Checking Bounding boxes ..
Checking label map ...
Checking images are valid ...
>>> example = example.reset_images_root("/tmp/")
>>> example
Dataset object containing 2 images and 2 objects
Name :
    shake_effort_many
Images root :
    /tmp
Images :
    width  height                     relative_path  type  split
id
0     955     229  care/suggest/determine/story.jpg  .jpg  train
1     131     840       care/suggest/air/method.bmp  .bmp  train
Annotations :
    image_id category_str  category_id  ...   box_y_min   box_width  box_height
id                                      ...
0          1       listen           14  ...  276.974642    9.718823  184.684056
1          0        reach           22  ...    6.311037  123.141689  174.239136

[2 rows x 8 columns]
Label map :
{14: 'listen', 15: 'marriage', 22: 'reach'}
>>> example.check()
Checking Image and annotations Ids ...
Checking Bounding boxes ..
Checking label map ...
Checking images are valid ...