class_docstr: VisA Datamodule.
  
  Args:
      root (Path | str): Path to the root of the dataset
      category (str): Category of the MVTec dataset (e.g. "bottle" or "cable").
      image_size (int | tuple[int, int] | None, optional): Size of the input image.
          Defaults to None.
      center_crop (int | tuple[int, int] | None, optional): When provided, the images will be center-cropped
          to the provided dimensions.
      normalize (bool): When True, the images will be normalized to the ImageNet statistics.
      train_batch_size (int, optional): Training batch size. Defaults to 32.
      eval_batch_size (int, optional): Test batch size. Defaults to 32.
      num_workers (int, optional): Number of workers. Defaults to 8.
      task (TaskType): Task type, 'classification', 'detection' or 'segmentation'
      transform_config_train (str | A.Compose | None, optional): Config for pre-processing
          during training.
          Defaults to None.
      transform_config_val (str | A.Compose | None, optional): Config for pre-processing
          during validation.
          Defaults to None.
      test_split_mode (TestSplitMode): Setting that determines how the testing subset is obtained.
      test_split_ratio (float): Fraction of images from the train set that will be reserved for testing.
      val_split_mode (ValSplitMode): Setting that determines how the validation subset is obtained.
      val_split_ratio (float): Fraction of train or test images that will be reserved for validation.
      seed (int | None, optional): Seed which may be set to a fixed value for reproducibility.
class_docstr_tok: ["VisA","Datamodule",".","Args",":","root","(","Path","|","str",")",":","Path","to","the","root","of","the","dataset","category","(","str",")",":","Category","of","the","MVTec","dataset","(","e.g",".","``","bottle","''","or","``","cable","''",")",".","image_size","(","int","|","tuple","[","int",",","int","]","|","None",",","optional",")",":","Size","of","the","input","image",".","Defaults","to","None",".","center_crop","(","int","|","tuple","[","int",",","int","]","|","None",",","optional",")",":","When","provided",",","the","images","will","be","center-cropped","to","the","provided","dimensions",".","normalize","(","bool",")",":","When","True",",","the","images","will","be","normalized","to","the","ImageNet","statistics",".","train_batch_size","(","int",",","optional",")",":","Training","batch","size",".","Defaults","to","32.","eval_batch_size","(","int",",","optional",")",":","Test","batch","size",".","Defaults","to","32.","num_workers","(","int",",","optional",")",":","Number","of","workers",".","Defaults","to","8.","task","(","TaskType",")",":","Task","type",",","'classification","'",",","'detection","'","or","'segmentation'","transform_config_train","(","str","|","A.Compose","|","None",",","optional",")",":","Config","for","pre-processing","during","training",".","Defaults","to","None",".","transform_config_val","(","str","|","A.Compose","|","None",",","optional",")",":","Config","for","pre-processing","during","validation",".","Defaults","to","None",".","test_split_mode","(","TestSplitMode",")",":","Setting","that","determines","how","the","testing","subset","is","obtained",".","test_split_ratio","(","float",")",":","Fraction","of","images","from","the","train","set","that","will","be","reserved","for","testing",".","val_split_mode","(","ValSplitMode",")",":","Setting","that","determines","how","the","validation","subset","is","obtained",".","val_split_ratio","(","float",")",":","Fraction","of","train","or","test","images","that","will","be","reserved","for","validation",".","seed","(","int","|","None",",","optional",")",":","Seed","which","may","be","set","to","a","fixed","value","for","reproducibility","."]
docstr: Apply the 1-class subset splitting using the fixed split in the csv file.
  
  adapted from https://github.com/amazon-science/spot-diff
docstr_tok: ["Apply","the","1-class","subset","splitting","using","the","fixed","split","in","the","csv","file",".","adapted","from","https",":","\/\/github.com\/amazon-science\/spot-diff"]
code: def apply_cls1_split(self) -> None:
      """Apply the 1-class subset splitting using the fixed split in the csv file.
  
      adapted from https://github.com/amazon-science/spot-diff
      """
      logger.info("preparing data")
      categories = [
          "candle",
          "capsules",
          "cashew",
          "chewinggum",
          "fryum",
          "macaroni1",
          "macaroni2",
          "pcb1",
          "pcb2",
          "pcb3",
          "pcb4",
          "pipe_fryum",
      ]
  
      split_file = self.root / "split_csv" / "1cls.csv"
  
      for category in categories:
          train_folder = self.split_root / category / "train"
          test_folder = self.split_root / category / "test"
          mask_folder = self.split_root / category / "ground_truth"
  
          train_img_good_folder = train_folder / "good"
          test_img_good_folder = test_folder / "good"
          test_img_bad_folder = test_folder / "bad"
          test_mask_bad_folder = mask_folder / "bad"
  
          train_img_good_folder.mkdir(parents=True, exist_ok=True)
          test_img_good_folder.mkdir(parents=True, exist_ok=True)
          test_img_bad_folder.mkdir(parents=True, exist_ok=True)
          test_mask_bad_folder.mkdir(parents=True, exist_ok=True)
  
      with split_file.open(encoding="utf-8") as file:
          csvreader = csv.reader(file)
          next(csvreader)
          for row in csvreader:
              category, split, label, image_path, mask_path = row
              if label == "normal":
                  label = "good"
              else:
                  label = "bad"
              image_name = image_path.split("/")[-1]
              mask_name = mask_path.split("/")[-1]
  
              img_src_path = self.root / image_path
              msk_src_path = self.root / mask_path
              img_dst_path = (
                  self.split_root
                  / category
                  / split
                  / label
                  / image_name
              )
              msk_dst_path = (
                  self.split_root
                  / category
                  / "ground_truth"
                  / label
                  / mask_name
              )
  
              shutil.copyfile(img_src_path, img_dst_path)
              if split == "test" and label == "bad":
                  mask = cv2.imread(str(msk_src_path))
  
                  # binarize mask
                  mask[mask != 0] = 255
  
                  cv2.imwrite(str(msk_dst_path), mask)
  
imports: from __future__ import annotations
  import csv
  import logging
  import shutil
  from pathlib import Path
  import albumentations
  import cv2
  from anomalib.data.base import AnomalibDataModule, AnomalibDataset
  from anomalib.data.task_type import TaskType
  from anomalib.data.utils import DownloadInfo, InputNormalizationMethod, Split, TestSplitMode, ValSplitMode, download_and_extract, get_transforms
  from .mvtec import make_mvtec_dataset
label_desc: Use image node_id 3 for calling the Visa obj's underlying member method code with example usage: obj.apply_cls1_split() without return types