示例#1
0
    def add_image_with_boxes(self,
                             tag,
                             img_tensor,
                             box_tensor,
                             global_step=None,
                             walltime=None,
                             dataformats='CHW',
                             **kwargs):
        """Add image and draw bounding boxes on the image.

        Args:
            tag (string): Data identifier
            img_tensor (torch.Tensor, numpy.array, or string/blobname): Image data
            box_tensor (torch.Tensor, numpy.array, or string/blobname): Box data (for detected objects)
            global_step (int): Global step value to record
            walltime (float): Optional override default walltime (time.time()) of event
        Shape:
            img_tensor: Default is :math:`(3, H, W)`. It can be specified with ``dataformat`` agrument.
            e.g. CHW or HWC

            box_tensor: (torch.Tensor, numpy.array, or string/blobname): NX4,  where N is the number of
            boxes and each 4 elememts in a row represents (xmin, ymin, xmax, ymax).
        """
        if self._check_caffe2(img_tensor):
            img_tensor = workspace.FetchBlob(img_tensor)
        if self._check_caffe2(box_tensor):
            box_tensor = workspace.FetchBlob(box_tensor)
        self.file_writer.add_summary(
            image_boxes(tag,
                        img_tensor,
                        box_tensor,
                        dataformats=dataformats,
                        **kwargs), global_step, walltime)
示例#2
0
    def add_image_with_boxes(self, tag, img_tensor, box_tensor, global_step=None,
                             walltime=None, **kwargs):
        """Add image boxes data to summary (useful for models such as Detectron).

        Args:
            tag (string): Data identifier
            img_tensor (torch.Tensor, numpy.array, or string/blobname): Image data
            box_tensor (torch.Tensor, numpy.array, or string/blobname): Box data (for detected objects)
            global_step (int): Global step value to record
            walltime (float): Optional override default walltime (time.time()) of event
        """
        if self._check_caffe2(img_tensor):
            img_tensor = workspace.FetchBlob(img_tensor)
        if self._check_caffe2(box_tensor):
            box_tensor = workspace.FetchBlob(box_tensor)
        self.file_writer.add_summary(image_boxes(tag, img_tensor, box_tensor, **kwargs), global_step, walltime)
 def test_image_with_boxes(self):
     summary.image_boxes('dummy',
                         np.random.rand(3, 32, 32).astype(np.float32),
                         np.array([[10, 10, 40, 40]]))
示例#4
0
 def test_image_with_boxes(self):
     compare_proto(summary.image_boxes('dummy',
                         tensor_N(shape=(3, 32, 32)),
                         np.array([[10, 10, 40, 40]])), self)