Repository: roboflow/supervision
File: supervision/dataset/core.py (Python)

Code before:
            >>> import supervision as sv

            >>> cd = sv.ClassificationDataset(...)

            >>> cd.as_multiclass_folder_structure(
            ...     root_directory_path="./images/valid/",
            ...     output_directory_path="./out",
            ... )
        """
        os.makedirs(output_directory_path, exist_ok=True)

        for class_name in self.classes:
            os.makedirs(os.path.join(output_directory_path, class_name), exist_ok=True)

            for image in self.annotations:
                for class_id in self.annotations[image].class_id:
                    if class_id == self.classes.index(class_name):
                        cv2.imwrite(
                            os.path.join(output_directory_path, class_name, image),
                            self.images[image],
                        )

    @classmethod
    def from_multiclass_folder_structure(
        cls, root_directory_path: str
    ) -> "ClassificationDataset":
        """
        Load data from a multiclass folder structure into a ClassificationDataset.

        Args:
            root_directory_path (str): The path to the dataset directory.

        Returns:
            ClassificationDataset: The dataset.

        Example:
            ```python
            >>> import supervision as sv

            >>> cd = sv.ClassificationDataset.from_multiclass_folder_structure(
            ...     root_directory_path="./dataset",
            ... )
        """
        classes = os.listdir(root_directory_path)

        classes = sorted(set(classes))

        images = {}
        annotations = {}

        for class_name in classes:

Review comment (suggestion):
Because we use `from __future__ import annotations` at the top of the file, we do not need `"` around `"ClassificationDataset"`.

Code after:
        for class_name in self.classes:
            os.makedirs(os.path.join(root_directory_path, class_name), exist_ok=True)

        for image_name in self.images:
            classification = self.annotations[image_name]
            image = self.images[image_name]
            class_id = (
                classification.class_id[0]
                if classification.confidence is None
                else classification.get_top_k(1)[0]
            )
            class_name = self.classes[class_id]
            image_path = os.path.join(root_directory_path, class_name, image_name)
            cv2.imwrite(image_path, image)

    @classmethod
    def from_multiclass_folder_structure(
        cls, root_directory_path: str
    ) -> ClassificationDataset:
        """
        Load data from a multiclass folder structure into a ClassificationDataset.

        Args:
            root_directory_path (str): The path to the dataset directory.

        Returns:
            ClassificationDataset: The dataset.

        Example:
            ```python
            >>> import roboflow
            >>> from roboflow import Roboflow
            >>> import supervision as sv

            >>> roboflow.login()

            >>> rf = Roboflow()

            >>> project = rf.workspace(WORKSPACE_ID).project(PROJECT_ID)
            >>> dataset = project.version(PROJECT_VERSION).download("folder")

            >>> cd = sv.ClassificationDataset.from_multiclass_folder_structure(
            ...     root_directory_path=f"{dataset.location}/train"
            ... )
            ```
        """
        classes = os.listdir(root_directory_path)
        classes = sorted(set(classes))

        images = {}
        annotations = {}