class_docstr: The ``StyleTransferData`` class is a :class:`~flash.core.data.data_module.DataModule` with a set of classmethods
  for loading data for image style transfer.
class_docstr_tok: ["The","``","StyleTransferData","``","class","is","a",":","class",":","`","~flash.core.data.data_module.DataModule","`","with","a","set","of","classmethods","for","loading","data","for","image","style","transfer","."]
docstr: Load the :class:`~flash.image.style_transfer.data.StyleTransferData` from folders containing images.
  
  The supported file extensions are: ``.jpg``, ``.jpeg``, ``.png``, ``.ppm``, ``.bmp``, ``.pgm``, ``.tif``,
  ``.tiff``, ``.webp``, and ``.npy``.
  Here's the required folder structure:
  
  .. code-block::
  
      train_folder
      ├── image_1.png
      ├── image_2.png
      ├── image_3.png
      ...
  
  To learn how to customize the transforms applied for each stage, read our
  :ref:`customizing transforms guide <customizing_transforms>`.
  
  Args:
      train_folder: The folder containing images to use when training.
      predict_folder: The folder containing images to use when predicting.
      transform: The :class:`~flash.core.data.io.input_transform.InputTransform` type to use.
      input_cls: The :class:`~flash.core.data.io.input.Input` type to use for loading the data.
      transform: The :class:`~flash.core.data.io.input_transform.InputTransform` type to use.
      transform_kwargs: Dict of keyword arguments to be provided when instantiating the transforms.
      data_module_kwargs: Additional keyword arguments to provide to the
        :class:`~flash.core.data.data_module.DataModule` constructor.
  
  Returns:
      The constructed :class:`~flash.image.style_transfer.data.StyleTransferData`.
  
  Examples
  ________
  
  .. testsetup::
  
      >>> import os
      >>> from PIL import Image
      >>> rand_image = Image.fromarray(np.random.randint(0, 255, (64, 64, 3), dtype="uint8"))
      >>> os.makedirs("train_folder", exist_ok=True)
      >>> os.makedirs("predict_folder", exist_ok=True)
      >>> _ = [rand_image.save(os.path.join("train_folder", f"image_{i}.png")) for i in range(1, 4)]
      >>> _ = [rand_image.save(os.path.join("predict_folder", f"predict_image_{i}.png")) for i in range(1, 4)]
  
  .. doctest::
  
      >>> from flash import Trainer
      >>> from flash.image import StyleTransfer, StyleTransferData
      >>> datamodule = StyleTransferData.from_folders(
      ...     train_folder="train_folder",
      ...     predict_folder="predict_folder",
      ...     transform_kwargs=dict(image_size=(128, 128)),
      ...     batch_size=2,
      ... )
      >>> model = StyleTransfer()
      >>> trainer = Trainer(fast_dev_run=True)
      >>> trainer.fit(model, datamodule=datamodule)  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
      Training...
      >>> trainer.predict(model, datamodule=datamodule)  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
      Predicting...
  
  .. testcleanup::
  
      >>> import shutil
      >>> shutil.rmtree("train_folder")
      >>> shutil.rmtree("predict_folder")
docstr_tok: ["Load","the",":","class",":","`","~flash.image.style_transfer.data.StyleTransferData","`","from","folders","containing","images",".","The","supported","file","extensions","are",":","``",".jpg","``",",","``",".jpeg","``",",","``",".png","``",",","``",".ppm","``",",","``",".bmp","``",",","``",".pgm","``",",","``",".tif","``",",","``",".tiff","``",",","``",".webp","``",",","and","``",".npy","``",".","Here","'s","the","required","folder","structure",":","..","code-block",":",":","train_folder","\u251c\u2500\u2500","image_1.png","\u251c\u2500\u2500","image_2.png","\u251c\u2500\u2500","image_3.png","...","To","learn","how","to","customize","the","transforms","applied","for","each","stage",",","read","our",":","ref",":","`","customizing","transforms","guide","<","customizing_transforms",">","`",".","Args",":","train_folder",":","The","folder","containing","images","to","use","when","training",".","predict_folder",":","The","folder","containing","images","to","use","when","predicting",".","transform",":","The",":","class",":","`","~flash.core.data.io.input_transform.InputTransform","`","type","to","use",".","input_cls",":","The",":","class",":","`","~flash.core.data.io.input.Input","`","type","to","use","for","loading","the","data",".","transform",":","The",":","class",":","`","~flash.core.data.io.input_transform.InputTransform","`","type","to","use",".","transform_kwargs",":","Dict","of","keyword","arguments","to","be","provided","when","instantiating","the","transforms",".","data_module_kwargs",":","Additional","keyword","arguments","to","provide","to","the",":","class",":","`","~flash.core.data.data_module.DataModule","`","constructor",".","Returns",":","The","constructed",":","class",":","`","~flash.image.style_transfer.data.StyleTransferData","`",".","Examples","________","..","testsetup",":",":",">",">",">","import","os",">",">",">","from","PIL","import","Image",">",">",">","rand_image","=","Image.fromarray","(","np.random.randint","(","0",",","255",",","(","64",",","64",",","3",")",",","dtype=","''","uint8","''",")",")",">",">",">","os.makedirs","(","``","train_folder","''",",","exist_ok=True",")",">",">",">","os.makedirs","(","``","predict_folder","''",",","exist_ok=True",")",">",">",">","_","=","[","rand_image.save","(","os.path.join","(","``","train_folder","''",",","f","''","image_","{","i","}",".png","''",")",")","for","i","in","range","(","1",",","4",")","]",">",">",">","_","=","[","rand_image.save","(","os.path.join","(","``","predict_folder","''",",","f","''","predict_image_","{","i","}",".png","''",")",")","for","i","in","range","(","1",",","4",")","]","..","doctest",":",":",">",">",">","from","flash","import","Trainer",">",">",">","from","flash.image","import","StyleTransfer",",","StyleTransferData",">",">",">","datamodule","=","StyleTransferData.from_folders","(","...","train_folder=","''","train_folder","''",",","...","predict_folder=","''","predict_folder","''",",","...","transform_kwargs=dict","(","image_size=","(","128",",","128",")",")",",","...","batch_size=2",",","...",")",">",">",">","model","=","StyleTransfer","(",")",">",">",">","trainer","=","Trainer","(","fast_dev_run=True",")",">",">",">","trainer.fit","(","model",",","datamodule=datamodule",")","#","doctest",":","+ELLIPSIS","+NORMALIZE_WHITESPACE","Training","...",">",">",">","trainer.predict","(","model",",","datamodule=datamodule",")","#","doctest",":","+ELLIPSIS","+NORMALIZE_WHITESPACE","Predicting","...","..","testcleanup",":",":",">",">",">","import","shutil",">",">",">","shutil.rmtree","(","``","train_folder","''",")",">",">",">","shutil.rmtree","(","``","predict_folder","''",")"]
code: def from_folders(
      cls,
      train_folder: Optional[str] = None,
      predict_folder: Optional[str] = None,
      input_cls: Type[Input] = ImageClassificationFolderInput,
      transform: INPUT_TRANSFORM_TYPE = StyleTransferInputTransform,
      transform_kwargs: Optional[Dict] = None,
      **data_module_kwargs: Any,
  ) -> "StyleTransferData":
      """Load the :class:`~flash.image.style_transfer.data.StyleTransferData` from folders containing images.
  
      The supported file extensions are: ``.jpg``, ``.jpeg``, ``.png``, ``.ppm``, ``.bmp``, ``.pgm``, ``.tif``,
      ``.tiff``, ``.webp``, and ``.npy``.
      Here's the required folder structure:
  
      .. code-block::
  
          train_folder
          ├── image_1.png
          ├── image_2.png
          ├── image_3.png
          ...
  
      To learn how to customize the transforms applied for each stage, read our
      :ref:`customizing transforms guide <customizing_transforms>`.
  
      Args:
          train_folder: The folder containing images to use when training.
          predict_folder: The folder containing images to use when predicting.
          transform: The :class:`~flash.core.data.io.input_transform.InputTransform` type to use.
          input_cls: The :class:`~flash.core.data.io.input.Input` type to use for loading the data.
          transform: The :class:`~flash.core.data.io.input_transform.InputTransform` type to use.
          transform_kwargs: Dict of keyword arguments to be provided when instantiating the transforms.
          data_module_kwargs: Additional keyword arguments to provide to the
            :class:`~flash.core.data.data_module.DataModule` constructor.
  
      Returns:
          The constructed :class:`~flash.image.style_transfer.data.StyleTransferData`.
  
      Examples
      ________
  
      .. testsetup::
  
          >>> import os
          >>> from PIL import Image
          >>> rand_image = Image.fromarray(np.random.randint(0, 255, (64, 64, 3), dtype="uint8"))
          >>> os.makedirs("train_folder", exist_ok=True)
          >>> os.makedirs("predict_folder", exist_ok=True)
          >>> _ = [rand_image.save(os.path.join("train_folder", f"image_{i}.png")) for i in range(1, 4)]
          >>> _ = [rand_image.save(os.path.join("predict_folder", f"predict_image_{i}.png")) for i in range(1, 4)]
  
      .. doctest::
  
          >>> from flash import Trainer
          >>> from flash.image import StyleTransfer, StyleTransferData
          >>> datamodule = StyleTransferData.from_folders(
          ...     train_folder="train_folder",
          ...     predict_folder="predict_folder",
          ...     transform_kwargs=dict(image_size=(128, 128)),
          ...     batch_size=2,
          ... )
          >>> model = StyleTransfer()
          >>> trainer = Trainer(fast_dev_run=True)
          >>> trainer.fit(model, datamodule=datamodule)  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
          Training...
          >>> trainer.predict(model, datamodule=datamodule)  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
          Predicting...
  
      .. testcleanup::
  
          >>> import shutil
          >>> shutil.rmtree("train_folder")
          >>> shutil.rmtree("predict_folder")
  
      """
  
      return cls(
          input_cls(RunningStage.TRAINING, train_folder),
          predict_input=input_cls(
              RunningStage.PREDICTING, predict_folder
          ),
          transform=transform,
          transform_kwargs=transform_kwargs,
          **data_module_kwargs,
      )
  
file_path: lightning-flash/src/flash/image/style_transfer/data.py
imports: from typing import Any, Collection, Dict, Optional, Sequence, Type
  import numpy
  from torch import Tensor
  from flash.core.data.data_module import DataModule
  from flash.core.data.io.input import Input
  from flash.core.utilities.stability import beta
  from flash.core.utilities.stages import RunningStage
  from flash.core.utilities.types import INPUT_TRANSFORM_TYPE
  from flash.image.classification.input import ImageClassificationFilesInput, ImageClassificationFolderInput
  from flash.image.data import ImageNumpyInput, ImageTensorInput
  from flash.image.style_transfer.input_transform import StyleTransferInputTransform
label_desc: Use image node_id 2 for calling the StyleTransferData obj's underlying member method code with example usage: obj.from_folders(cls, train_folder, predict_folder, input_cls, transform, transform_kwargs) and returns: cls