def image_boxes(tag, tensor_image, tensor_boxes, rescale=0.8, mean_pixs=(122.7717, 115.9465, 102.9801)): '''Outputs a `Summary` protocol buffer with images.''' tensor_image = make_np(tensor_image, 'IMG') tensor_boxes = make_np(tensor_boxes) if isinstance(tensor_image, list): res = [] for i, t in enumerate(tensor_image): t = t + mean_pixs rois = tensor_boxes[tensor_boxes[:, 0] == i, 1:5] image = make_image(t.astype(np.uint8, copy=False), rescale=rescale, rois=rois) res.append( Summary( value=[Summary.Value(tag=tag + ('_%d' % i), image=image)])) return res else: tensor_image = tensor_image + mean_pixs # Assuming the values are within [0,255] now rois = tensor_boxes[:, 1:5] image = make_image(tensor_image.astype(np.uint8, copy=False), rescale=rescale, rois=rois) return Summary(value=[Summary.Value(tag=tag, image=image)])
def image(tag, tensor, rescale=0.6, mean_pixs=(122.7717, 115.9465, 102.9801)): '''Outputs a `Summary` protocol buffer with images.''' tensor = make_np(tensor, 'IMG') if isinstance(tensor, list): res = [] for i, t in enumerate(tensor): t = t + mean_pixs image = make_image(t.astype(np.uint8, copy=False), rescale=rescale) res.append(Summary(value=[Summary.Value(tag=tag + ('_%d' % i), image=image)])) else: tensor = tensor + mean_pixs # Assuming the values are within [0,255] now image = make_image(tensor.astype(np.uint8, copy=False), rescale=rescale) return Summary(value=[Summary.Value(tag=tag, image=image)])
def memory(tag, tensor, rescale=4.0, value_scale=1.0): tensor = make_np(tensor, 'MEM') if isinstance(tensor, list): res = [] for i, t in enumerate(tensor): t = np.minimum(t * (255. / value_scale), 255.) t = np.concatenate((t, t, t), axis=2) image = make_image(t.astype(np.uint8, copy=False), rescale=rescale) res.append( Summary( value=[Summary.Value(tag=tag + ('_%d' % i), image=image)])) return res else: t = np.minimum(tensor * (255. / value_scale), 255.) tensor = np.concatenate((t, t, t), axis=2) image = make_image(tensor.astype(np.uint8, copy=False), rescale=rescale) return Summary(value=[Summary.Value(tag=tag, image=image)])
def histogram(name, values, bins): '''Outputs a `Summary` protocol buffer with a histogram.''' values = make_np(values) return self.histogram_with_values(name, values, bins)
def image(tag, tensor, rescale=0.6, mean_pixs=(122.7717, 115.9465, 102.9801)): '''Outputs a `Summary` protocol buffer with images.''' tensor = make_np(tensor, 'IMG') + mean_pixs # Assuming the values are within [0,255] now image = make_image(tensor.astype(np.uint8, copy=False), rescale=rescale) return Summary(value=[Summary.Value(tag=tag, image=image)])
def histogram(name, values, bins): '''Outputs a `Summary` protocol buffer with a histogram.''' values = make_np(values) hist = make_histogram(values.astype(np.float32, copy=False), bins) return Summary(value=[Summary.Value(tag=name, histo=hist)])