class_docstr: ImageNet dataset.
class_docstr_tok: ["ImageNet","dataset","."]
docstr: Prepares the image for network input (HWC/BGR/int -> CHW/BGR/float).
docstr_tok: ["Prepares","the","image","for","network","input","(","HWC\/BGR\/int","-",">","CHW\/BGR\/float",")","."]
code: def _prepare_im(self, im):
      """Prepares the image for network input (HWC/BGR/int -> CHW/BGR/float)."""
      # Convert HWC/BGR/int to HWC/RGB/float format for applying transforms
      im = im[:, :, ::-1].astype(np.float32) / 255
      # Train and test setups differ
      train_size, test_size = cfg.TRAIN.IM_SIZE, cfg.TEST.IM_SIZE
      if self._split == "train":
          # For training use random_sized_crop, horizontal_flip, augment, lighting
          im = transforms.random_sized_crop(im, train_size)
          im = transforms.horizontal_flip(im, prob=0.5)
          im = transforms.augment(im, cfg.TRAIN.AUGMENT)
          im = transforms.lighting(
              im, cfg.TRAIN.PCA_STD, _EIG_VALS, _EIG_VECS
          )
      else:
          # For testing use scale and center crop
          im = transforms.scale_and_center_crop(
              im, test_size, train_size
          )
      # For training and testing use color normalization
      im = transforms.color_norm(im, _MEAN, _STD)
      # Convert HWC/RGB/float to CHW/BGR/float format
      im = np.ascontiguousarray(im[:, :, ::-1].transpose([2, 0, 1]))
      return im
  
file_path: pycls/pycls/datasets/imagenet.py
imports: import os
  import re
  import cv2
  import numpy
  import pycls.core.logging
  import pycls.datasets.transforms
  import torch.utils.data
  from pycls.core.config import cfg
label_desc: Use image node_id 3 for calling the ImageNet obj's underlying member method code with example usage: obj._prepare_im(im) and returns: im