Skip to content

DataLoader

DataLoader is the parent class from which all data loaders inherit. It is used to load data from a dataset into a format that can be used by the model.

Code Documentation

Source code in evaluations/dataloaders/dataloader.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class DataLoader:
    def __init__(self):
        self.eval_data = {}
        self.data = {}
        self.image_files = None

    def process_files(self) -> None:
        """
        Process all input files in the dataset.

        Returns:
            None
        """

        for root, dirs, files in os.walk(self.image_files.rstrip("/") + "/test/"):
            for file in files:
                if file.endswith(".jpg"):
                    file_name = os.path.join(root, file)
                    if file_name not in self.data:
                        self.data[file_name] = {}

                    self.data[file_name][
                        "predictions"
                    ] = self.get_predictions_for_image(file_name)

        return self.data

process_files()

Process all input files in the dataset.

Returns:

Type Description
None

None

Source code in evaluations/dataloaders/dataloader.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def process_files(self) -> None:
    """
    Process all input files in the dataset.

    Returns:
        None
    """

    for root, dirs, files in os.walk(self.image_files.rstrip("/") + "/test/"):
        for file in files:
            if file.endswith(".jpg"):
                file_name = os.path.join(root, file)
                if file_name not in self.data:
                    self.data[file_name] = {}

                self.data[file_name][
                    "predictions"
                ] = self.get_predictions_for_image(file_name)

    return self.data