class_docstr: ```
  Image preprocessing
  ```
docstr: ```
  Receives raw data and returns
  tuple containing the generator and steps
  argument for model.predict.
  ```
docstr_tok: ["``","`","Receives","raw","data","and","returns","tuple","containing","the","generator","and","steps","argument","for","model.predict",".","``","`"]
code: def preprocess(self, data, batch_size=U.DEFAULT_BS):
      """
      ```
      Receives raw data and returns
      tuple containing the generator and steps
      argument for model.predict.
      ```
      """
      # input is an array of pixel values
      if isinstance(data, np.ndarray):
          generator = self.datagen.flow(data, shuffle=False)
          generator.batch_size = batch_size
          nsamples = len(data)
          steps = math.ceil(nsamples / batch_size)
          return (generator, steps)
  
      # input is a folder of images
      elif os.path.isdir(data):
          folder = data
          if folder[-1] != os.sep:
              folder += os.sep
          parent = os.path.dirname(os.path.dirname(folder))
          folder_name = os.path.basename(os.path.dirname(folder))
          if self.target_size is None or self.color_mode is None:
              raise Exception(
                  "To use predict_folder, you must load the data using either "
                  + "the images_from_folder function or the images_from_csv function."
              )
          generator = self.datagen.flow_from_directory(
              parent,
              classes=[folder_name],
              target_size=self.target_size,
              class_mode="categorical",
              shuffle=False,
              interpolation="bicubic",
              color_mode=self.color_mode,
          )
          generator.batch_size = batch_size
          nsamples = generator.samples
          steps = math.ceil(nsamples / batch_size)
          return (generator, steps)
      # input is the path to an image file
      elif os.path.isfile(data):
          if self.target_size is None or self.color_mode is None:
              raise Exception(
                  "To use predict_filename, you must load the data using either "
                  + "the ktrain.vision.images_from_folder function or the "
                  + "ktrain.vision.images_from_csv function."
              )
          img = keras.preprocessing.image.load_img(
              data,
              target_size=self.target_size,
              color_mode=self.color_mode,
          )
          x = keras.preprocessing.image.img_to_array(img)
          x = np.expand_dims(x, axis=0)
          generator = self.datagen.flow(np.array(x), shuffle=False)
          generator.batch_size = batch_size
          nsamples = 1
          steps = math.ceil(nsamples / batch_size)
          return (generator, steps)
      else:
          raise ValueError(
              "data argument is not valid file, folder, or numpy.ndarray"
          )
  
file_path: ktrain/ktrain/vision/preprocessor.py
imports: from ..None import utils
  from ..imports import *
  from ..preprocessor import Preprocessor
label_desc: Use image node_id 5 for calling the ImagePreprocessor obj's underlying member method code with example usage: obj.preprocess(data, batch_size) and returns: generator,  steps, generator,  steps, generator,  steps