(b, max_images=64, rows=None, cols=None)
return img
Turn a batch of images into a single image mosaic.
Turn a batch of images into a single image mosaic.
Turn a batch of images into a single image mosaic .
def batch_image(b, max_images=64, rows=None, cols=None):
  """Turn a batch of images into a single image mosaic."""
  mb = min(b.shape[0], max_images)
  if rows is None:
    rows = int(np.ceil(np.sqrt(mb)))
    cols = rows
  diff = rows * cols - mb
  b = np.vstack([b[:mb], np.zeros([diff, b.shape[1], b.shape[2], b.shape[3]])])
  tmp = b.reshape(-1, cols * b.shape[1], b.shape[2], b.shape[3])
  img = np.hstack(tmp[i] for i in range(rows))
  return img
def batch_image ( b , max_images = 64 , rows = None , cols = None ) : mb = min ( b . shape [ 0 ] , max_images ) if rows is None : rows = int ( np . ceil ( np . sqrt ( mb ) ) ) cols = rows diff = rows * cols - mb b = np . vstack ( [ b [ : mb ] , np . zeros ( [ diff , b . shape [ 1 ] , b . shape [ 2 ] , b . shape [ 3 ] ] ) ] ) tmp = b . reshape ( - 1 , cols * b . shape [ 1 ] , b . shape [ 2 ] , b . shape [ 3 ] ) img = np . hstack ( tmp [ i ] for i in range ( rows ) ) return img