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

Method get_image

utils/visualizer.py:310–328  ·  view source on GitHub ↗

Returns: ndarray: the visualized image of shape (H, W, 3) (RGB) in uint8 type. The shape is scaled w.r.t the input image using the given `scale` argument.

(self)

Source from the content-addressed store, hash-verified

308 self.fig.savefig(filepath)
309
310 def get_image(self):
311 """
312 Returns:
313 ndarray:
314 the visualized image of shape (H, W, 3) (RGB) in uint8 type.
315 The shape is scaled w.r.t the input image using the given `scale` argument.
316 """
317 canvas = self.canvas
318 s, (width, height) = canvas.print_to_buffer()
319 # buf = io.BytesIO() # works for cairo backend
320 # canvas.print_rgba(buf)
321 # width, height = self.width, self.height
322 # s = buf.getvalue()
323
324 buffer = np.frombuffer(s, dtype="uint8")
325
326 img_rgba = buffer.reshape(height, width, 4)
327 rgb, alpha = np.split(img_rgba, [3], axis=2)
328 return rgb.astype("uint8")
329
330
331class Visualizer:

Callers 2

process_multi_maskMethod · 0.80
interactive_infer_imageFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected