code: def load_images_DR(split="random", seed=None):
      """Loader for DR images"""
      data_dir = deepchem.utils.get_data_dir()
      images_path = os.path.join(data_dir, "DR", "train")
      label_path = os.path.join(data_dir, "DR", "trainLabels.csv")
      if not os.path.exists(images_path) or not os.path.exists(
          label_path
      ):
          logger.warn(
              "Cannot locate data, \n\
          all images(.png) should be stored in the folder: $DEEPCHEM_DATA_DIR/DR/train/,\n\
          corresponding label file should be stored as $DEEPCHEM_DATA_DIR/DR/trainLabels.csv.\n\
          Please refer to https://www.kaggle.com/c/diabetic-retinopathy-detection for data access"
          )
  
      image_names = os.listdir(images_path)
      raw_images = []
      for im in image_names:
          if (
              im.endswith(".jpeg")
              and not im.startswith("cut_")
              and not "cut_" + im in image_names
          ):
              raw_images.append(im)
      if len(raw_images) > 0:
          cut_raw_images(raw_images, images_path)
  
      image_names = [
          p
          for p in os.listdir(images_path)
          if p.startswith("cut_") and p.endswith(".png")
      ]
      all_labels = dict(
          zip(*np.transpose(np.array(pd.read_csv(label_path))))
      )
  
      print("Number of images: %d" % len(image_names))
      labels = np.array(
          [all_labels[os.path.splitext(n)[0][4:]] for n in image_names]
      ).reshape((-1, 1))
      image_full_paths = [
          os.path.join(images_path, n) for n in image_names
      ]
  
      classes, cts = np.unique(
          list(all_labels.values()), return_counts=True
      )
      weight_ratio = dict(zip(classes, np.max(cts) / cts.astype(float)))
      weights = np.array([weight_ratio[l[0]] for l in labels]).reshape(
          (-1, 1)
      )
  
      loader = deepchem.data.ImageLoader()
      dat = loader.featurize(
          image_full_paths, labels=labels, weights=weights
      )
      if split == None:
          return dat
  
      splitters = {
          "index": deepchem.splits.IndexSplitter(),
          "random": deepchem.splits.RandomSplitter(),
      }
      if not seed is None:
          np.random.seed(seed)
      splitter = splitters[split]
      train, valid, test = splitter.train_valid_test_split(dat)
      all_dataset = (train, valid, test)
      return all_dataset
  
file_path: deepchem/contrib/DiabeticRetinopathy/data.py
imports: from __future__ import division
  from __future__ import unicode_literals
  import os
  import logging
  import deepchem
  import numpy
  import pandas
label_desc: Use image node_id 1 for calling a global function with example usage: load_images_DR(split, seed) and returns: all_dataset, dat