MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / __init__

Method __init__

utils/visualizer.py:357–382  ·  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

355 # TODO implement a fast, rasterized version using OpenCV
356
357 def __init__(self, img_rgb, metadata=None, scale=1.0, instance_mode=ColorMode.IMAGE):
358 """
359 Args:
360 img_rgb: a numpy array of shape (H, W, C), where H and W correspond to
361 the height and width of the image respectively. C is the number of
362 color channels. The image is required to be in RGB format since that
363 is a requirement of the Matplotlib library. The image is also expected
364 to be in the range [0, 255].
365 metadata (Metadata): dataset metadata (e.g. class names and colors)
366 instance_mode (ColorMode): defines one of the pre-defined style for drawing
367 instances on an image.
368 """
369 self.img = np.asarray(img_rgb).clip(0, 255).astype(np.uint8)
370 if metadata is None:
371 metadata = MetadataCatalog.get("__nonexist__")
372 self.metadata = metadata
373 self.output = VisImage(self.img, scale=scale)
374 self.cpu_device = torch.device("cpu")
375
376 # too small texts are useless, therefore clamp to 9
377 self._default_font_size = max(
378 np.sqrt(self.output.height * self.output.width) // 90, 10 // scale
379 )
380 self._default_font_size = 18
381 self._instance_mode = instance_mode
382 self.keypoint_threshold = _KEYPOINT_THRESHOLD
383
384 def draw_instance_predictions(self, predictions):
385 """

Callers

nothing calls this directly

Calls 2

VisImageClass · 0.85
deviceMethod · 0.80

Tested by

no test coverage detected