parameters: (self)
return_statement: return self.transformer.preprocess(img, seg, self.scale)
docstring: Load the next image in a batch.
docstring_summary: Load the next image in a batch.
docstring_tokens: Load the next image in a batch .
function: def load_next_sample(self):
          """
          Load the next image in a batch.
          """
          
          # Did we finish an epoch?
          if self._cur == len(self.list_samples):
              self._cur = 0
              shuffle(self.list_samples)
  
          # Load rgb and its different types of gt from one sample
          image_file_name = self.list_samples[self._cur][0];
          seg_file_name = self.list_samples[self._cur][1];
          
          # determine if the file exists ...
          if not osp.isfile(osp.join(self.root_dir, image_file_name)):
              print('The file {} doesnot exist!!!'.format(osp.join(self.root_dir, image_file_name)));
              sys.exit(0);
          
          # start to read samples ...
          img = cv2.imread(osp.join(self.root_dir, image_file_name), 1);
          seg = cv2.imread(osp.join(self.root_dir, seg_file_name), 0);
          #rotate label, start label from 0 and change the void label from 0 to 255 (to ingore)
          seg -= 1;
          seg = seg.astype(np.uint8);      
  
          # do a simple horizontal flip as data augmentation       
          if self.mirror == True:
              flip = np.random.choice(2)*2-1
              img = img[:, ::flip]
              seg = seg[:, ::flip]
          
          # randomly pick a scale from scale factors
          scale_num = len(self.scale_factors)
          self.scale = self.scale_factors[np.random.choice(scale_num)]
  
          self._cur += 1
          return self.transformer.preprocess(img, seg, self.scale)
function_tokens: def load_next_sample ( self ) : # Did we finish an epoch? if self . _cur == len ( self . list_samples ) : self . _cur = 0 shuffle ( self . list_samples ) # Load rgb and its different types of gt from one sample image_file_name = self . list_samples [ self . _cur ] [ 0 ] seg_file_name = self . list_samples [ self . _cur ] [ 1 ] # determine if the file exists ... if not osp . isfile ( osp . join ( self . root_dir , image_file_name ) ) : print ( 'The file {} doesnot exist!!!' . format ( osp . join ( self . root_dir , image_file_name ) ) ) sys . exit ( 0 ) # start to read samples ... img = cv2 . imread ( osp . join ( self . root_dir , image_file_name ) , 1 ) seg = cv2 . imread ( osp . join ( self . root_dir , seg_file_name ) , 0 ) #rotate label, start label from 0 and change the void label from 0 to 255 (to ingore) seg -= 1 seg = seg . astype ( np . uint8 ) # do a simple horizontal flip as data augmentation        if self . mirror == True : flip = np . random . choice ( 2 ) * 2 - 1 img = img [ : , : : flip ] seg = seg [ : , : : flip ] # randomly pick a scale from scale factors scale_num = len ( self . scale_factors ) self . scale = self . scale_factors [ np . random . choice ( scale_num ) ] self . _cur += 1 return self . transformer . preprocess ( img , seg , self . scale )