MCPcopy Create free account
hub / github.com/PeizeSun/SparseR-CNN / __init__

Method __init__

detectron2/utils/visualizer.py:334–357  ·  view source on GitHub ↗

Args: img_rgb: a numpy array of shape (H, W, C), where H and W correspond to the height and width of the image respectively. C is the number of color channels. The image is required to be in RGB format since that is a requirement o

(self, img_rgb, metadata=None, scale=1.0, instance_mode=ColorMode.IMAGE)

Source from the content-addressed store, hash-verified

332 # TODO implement a fast, rasterized version using OpenCV
333
334 def __init__(self, img_rgb, metadata=None, scale=1.0, instance_mode=ColorMode.IMAGE):
335 """
336 Args:
337 img_rgb: a numpy array of shape (H, W, C), where H and W correspond to
338 the height and width of the image respectively. C is the number of
339 color channels. The image is required to be in RGB format since that
340 is a requirement of the Matplotlib library. The image is also expected
341 to be in the range [0, 255].
342 metadata (Metadata): image metadata.
343 instance_mode (ColorMode): defines one of the pre-defined style for drawing
344 instances on an image.
345 """
346 self.img = np.asarray(img_rgb).clip(0, 255).astype(np.uint8)
347 if metadata is None:
348 metadata = MetadataCatalog.get("__nonexist__")
349 self.metadata = metadata
350 self.output = VisImage(self.img, scale=scale)
351 self.cpu_device = torch.device("cpu")
352
353 # too small texts are useless, therefore clamp to 9
354 self._default_font_size = max(
355 np.sqrt(self.output.height * self.output.width) // 90, 10 // scale
356 )
357 self._instance_mode = instance_mode
358
359 def draw_instance_predictions(self, predictions):
360 """

Callers

nothing calls this directly

Calls 4

VisImageClass · 0.85
clipMethod · 0.45
getMethod · 0.45
deviceMethod · 0.45

Tested by

no test coverage detected