Skip to content

Data API

reid.ReIDSplit dataclass

Holds one split: its image paths and each image's person and camera IDs.

A split is a query split, a gallery split, or a full dataset that an evaluation protocol divides into query and gallery. Its number of images is fixed once built, so its IDs always line up with its images; to add, remove, or relabel images, build a new split, which is checked again.

Attributes:

Name Type Description
image_paths Sequence[str]

Path of each image, N in total, stored as a tuple.

pids ndarray

Person ID of each image. Shape (N,).

camids ndarray

Camera ID of each image. Shape (N,).

gallery_junk_pids frozenset[int]

Person IDs whose gallery images are ignored when ranking, such as Market-1501's bad detections (-1).

reid.load_identity_folders(root)

Load identity folders into one ReIDSplit, scanning the disk once.

Expects <root>/<identity>/<image>.(jpg|jpeg|png|bmp): tracking crops or any identity-labelled pictures. Identity folders are sorted by name and assigned contiguous person IDs (0..N-1). Camera IDs are set to -1 because the folders carry no camera information; protocols assign synthetic camera IDs where retrieval needs them. Pass the split to reid.ReIDModel.evaluate, whose protocol picks the query and gallery images from it.

Parameters:

Name Type Description Default
root str | Path

Dataset root with one subdirectory per identity.

required

Returns:

Type Description
ReIDSplit

A ReIDSplit over every crop found, with contiguous pids and

ReIDSplit

camids all equal to -1.

Raises:

Type Description
FileNotFoundError

If root is not a directory, or if no crops are found.

reid.load_market1501(root)

Load Market-1501 query and gallery splits from root.

Expects query/ and bounding_box_test/. Person and camera IDs are parsed from filenames.

Parameters:

Name Type Description Default
root str | Path

Path to the Market-1501 directory.

required

Returns:

Type Description
tuple[ReIDSplit, ReIDSplit]

Query and gallery as (ReIDSplit, ReIDSplit).

Raises:

Type Description
FileNotFoundError

If root, query/, or bounding_box_test/ does not exist.

ValueError

If an image file name does not start with <person>_c<camera>, such as a hidden ._* file macOS writes.

reid.load_msmt17(root)

Load MSMT17 query and gallery splits from root.

Expects test/, list_query.txt, and list_gallery.txt, whose lines read path pid. The camera ID comes from the image file name.

Parameters:

Name Type Description Default
root str | Path

Path to the MSMT17 directory.

required

Returns:

Type Description
tuple[ReIDSplit, ReIDSplit]

Query and gallery as (ReIDSplit, ReIDSplit).

Raises:

Type Description
FileNotFoundError

If root, test/, list_query.txt, or list_gallery.txt does not exist.

ValueError

If a list line is not path pid.