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

Method get_image

detectron2/utils/visualizer.py:291–309  ·  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

289 self.fig.savefig(filepath)
290
291 def get_image(self):
292 """
293 Returns:
294 ndarray:
295 the visualized image of shape (H, W, 3) (RGB) in uint8 type.
296 The shape is scaled w.r.t the input image using the given `scale` argument.
297 """
298 canvas = self.canvas
299 s, (width, height) = canvas.print_to_buffer()
300 # buf = io.BytesIO() # works for cairo backend
301 # canvas.print_rgba(buf)
302 # width, height = self.width, self.height
303 # s = buf.getvalue()
304
305 buffer = np.frombuffer(s, dtype="uint8")
306
307 img_rgba = buffer.reshape(height, width, 4)
308 rgb, alpha = np.split(img_rgba, [3], axis=2)
309 return rgb.astype("uint8")
310
311
312class Visualizer:

Callers 13

outputFunction · 0.80
visualize_trainingMethod · 0.80
visualize_trainingMethod · 0.80
test_draw_binary_maskMethod · 0.80
process_predictionsMethod · 0.80
demo.pyFile · 0.80
process_predictionsMethod · 0.80

Calls

no outgoing calls