class_docstr: Creates `Dataset` objects from input image files.
  
  This class allows for loading of images in various formats.
  For user convenience, also accepts zip-files and directories
  of images and uses some limited intelligence to attempt to
  traverse subdirectories which contain images.
  
  Currently, only .png and .tif files are supported. If the
  inputs or labels are given as a list of files, the list must contain
  only image files.
  
  Examples
  --------
  For this example, we will be using the BBBC001 Dataset. This dataset contains 6 images
  of human HT29 colon cancer cells. We will use the images as inputs and we will assign
  the labels as integers ranging from 1 to 6 for the sake of simplicity.
  
  To learn more about this dataset, please visit: https://data.broadinstitute.org/bbbc/BBBC001/
  and also see our loader for this dataset: `deepchem.molnet.loadbbbc001`.
  
  Let's begin by importing the necessary modules and downloading the dataset.
  >>> import os
  >>> import deepchem as dc
  >>> data_dir = dc.utils.data_utils.get_data_dir()
  >>> dataset_file = os.path.join(data_dir, "BBBC001_v1_images_tif.zip")
  >>> BBBC1_IMAGE_URL = 'https://data.broadinstitute.org/bbbc/BBBC001/BBBC001_v1_images_tif.zip'
  >>> if not os.path.exists(dataset_file):
  ...    dc.utils.data_utils.download_url(url=BBBC1_IMAGE_URL, dest_dir=data_dir)
  
  Now that we have the dataset, let's create a list of labels for each image.
  
  >>> labels = np.array([1,2,3,4,5,6])
  
  Let's now write this to disk somewhere. We can now use `ImageLoader` to process
  this Image dataset. We do not use a featurizer here, hence the `UserDefinedFeaturizer`
  with an empty list.
  
  >>> featurizer = dc.feat.UserDefinedFeaturizer([])
  >>> loader = dc.data.ImageLoader(tasks=['demo-task'], sorting=False)
  >>> dataset = loader.create_dataset(inputs=(dataset_file, labels),
  ...                                 in_memory=False)
  
  We can confirm that we have 6 images in our dataset and 6 labels. The images are
  of size 512x512 while the labels are just integers.
  
  >>> len(dataset)
  6
  >>> dataset.X.shape
  (6, 512, 512)
  >>> dataset.y.shape
  (6,)
  
  The label files can also be images similar to the inputs, in which case we
  can provide a list of label files instead of a list of labels.
  
  To show this, we will use the input data as the ground truths, this is often
  seen when making autoencoders. Similar to the above example, let's use `ImageLoader`
  to process this Image dataset.
  
  >>> featurizer = dc.feat.UserDefinedFeaturizer([])
  >>> loader = dc.data.ImageLoader(tasks=['demo-task'], sorting=False)
  >>> dataset = loader.create_dataset(inputs=(dataset_file, dataset_file),
  ...                                 in_memory=False)
  
  We can confirm that we have 6 images in our dataset and 6 labels. The images are
  of size 512x512 while the labels are also images of size 512x512.
  
  >>> len(dataset)
  6
  >>> dataset.X.shape
  (6, 512, 512)
  >>> dataset.y.shape
  (6, 512, 512)
class_docstr_tok: ["Creates","`","Dataset","`","objects","from","input","image","files",".","This","class","allows","for","loading","of","images","in","various","formats",".","For","user","convenience",",","also","accepts","zip-files","and","directories","of","images","and","uses","some","limited","intelligence","to","attempt","to","traverse","subdirectories","which","contain","images",".","Currently",",","only",".png","and",".tif","files","are","supported",".","If","the","inputs","or","labels","are","given","as","a","list","of","files",",","the","list","must","contain","only","image","files",".","Examples","--","--","--","--","For","this","example",",","we","will","be","using","the","BBBC001","Dataset",".","This","dataset","contains","6","images","of","human","HT29","colon","cancer","cells",".","We","will","use","the","images","as","inputs","and","we","will","assign","the","labels","as","integers","ranging","from","1","to","6","for","the","sake","of","simplicity",".","To","learn","more","about","this","dataset",",","please","visit",":","https",":","\/\/data.broadinstitute.org\/bbbc\/BBBC001\/","and","also","see","our","loader","for","this","dataset",":","`","deepchem.molnet.loadbbbc001","`",".","Let","'s","begin","by","importing","the","necessary","modules","and","downloading","the","dataset",".",">",">",">","import","os",">",">",">","import","deepchem","as","dc",">",">",">","data_dir","=","dc.utils.data_utils.get_data_dir","(",")",">",">",">","dataset_file","=","os.path.join","(","data_dir",",","``","BBBC001_v1_images_tif.zip","''",")",">",">",">","BBBC1_IMAGE_URL","=","'https",":","\/\/data.broadinstitute.org\/bbbc\/BBBC001\/BBBC001_v1_images_tif.zip'",">",">",">","if","not","os.path.exists","(","dataset_file",")",":","...","dc.utils.data_utils.download_url","(","url=BBBC1_IMAGE_URL",",","dest_dir=data_dir",")","Now","that","we","have","the","dataset",",","let","'s","create","a","list","of","labels","for","each","image",".",">",">",">","labels","=","np.array","(","[","1,2,3,4,5,6","]",")","Let","'s","now","write","this","to","disk","somewhere",".","We","can","now","use","`","ImageLoader","`","to","process","this","Image","dataset",".","We","do","not","use","a","featurizer","here",",","hence","the","`","UserDefinedFeaturizer","`","with","an","empty","list",".",">",">",">","featurizer","=","dc.feat.UserDefinedFeaturizer","(","[","]",")",">",">",">","loader","=","dc.data.ImageLoader","(","tasks=","[","'demo-task","'","]",",","sorting=False",")",">",">",">","dataset","=","loader.create_dataset","(","inputs=","(","dataset_file",",","labels",")",",","...","in_memory=False",")","We","can","confirm","that","we","have","6","images","in","our","dataset","and","6","labels",".","The","images","are","of","size","512x512","while","the","labels","are","just","integers",".",">",">",">","len","(","dataset",")","6",">",">",">","dataset.X.shape","(","6",",","512",",","512",")",">",">",">","dataset.y.shape","(","6",",",")","The","label","files","can","also","be","images","similar","to","the","inputs",",","in","which","case","we","can","provide","a","list","of","label","files","instead","of","a","list","of","labels",".","To","show","this",",","we","will","use","the","input","data","as","the","ground","truths",",","this","is","often","seen","when","making","autoencoders",".","Similar","to","the","above","example",",","let","'s","use","`","ImageLoader","`","to","process","this","Image","dataset",".",">",">",">","featurizer","=","dc.feat.UserDefinedFeaturizer","(","[","]",")",">",">",">","loader","=","dc.data.ImageLoader","(","tasks=","[","'demo-task","'","]",",","sorting=False",")",">",">",">","dataset","=","loader.create_dataset","(","inputs=","(","dataset_file",",","dataset_file",")",",","...","in_memory=False",")","We","can","confirm","that","we","have","6","images","in","our","dataset","and","6","labels",".","The","images","are","of","size","512x512","while","the","labels","are","also","images","of","size","512x512",".",">",">",">","len","(","dataset",")","6",">",">",">","dataset.X.shape","(","6",",","512",",","512",")",">",">",">","dataset.y.shape","(","6",",","512",",","512",")"]
docstr: Initialize image loader.
  
  At present, custom image featurizers aren't supported by this
  loader class.
  
  Parameters
  ----------
  tasks: List[str], optional (default None)
      List of task names for image labels.
  sorting: bool, optional (default True)
      Whether to sort image files by filename.
docstr_tok: ["Initialize","image","loader",".","At","present",",","custom","image","featurizers","are","n't","supported","by","this","loader","class",".","Parameters","--","--","--","--","--","tasks",":","List","[","str","]",",","optional","(","default","None",")","List","of","task","names","for","image","labels",".","sorting",":","bool",",","optional","(","default","True",")","Whether","to","sort","image","files","by","filename","."]
code: def __init__(
      self, tasks: Optional[List[str]] = None, sorting: bool = True
  ):
      """Initialize image loader.
  
      At present, custom image featurizers aren't supported by this
      loader class.
  
      Parameters
      ----------
      tasks: List[str], optional (default None)
          List of task names for image labels.
      sorting: bool, optional (default True)
          Whether to sort image files by filename.
      """
      if tasks is None:
          tasks = []
      self.tasks = tasks
      self.sorting = sorting
  
imports: import os
  import tempfile
  import zipfile
  import time
  import logging
  import warnings
  from typing import List, Optional, Tuple, Any, Sequence, Union, Iterator
  import pandas
  import numpy
  from deepchem.utils.typing import OneOrMany
  from deepchem.utils.data_utils import load_image_files, load_csv_files, load_json_files, load_sdf_files, unzip_file
  from deepchem.feat import UserDefinedFeaturizer, Featurizer
  from deepchem.data import Dataset, DiskDataset, NumpyDataset, ImageDataset
  from deepchem.feat.molecule_featurizers import OneHotFeaturizer
  from deepchem.utils.genomics_utils import encode_bio_sequence
label_desc: Use image node_id 1 to create a new ImageLoader object from inherited base classes: DataLoader with example: obj = ImageLoader(tasks, sorting)