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

Method process_predictions

demo_d2/predictor.py:89–106  ·  view source on GitHub ↗
(frame, predictions)

Source from the content-addressed store, hash-verified

87 video_visualizer = VideoVisualizer(self.metadata, self.instance_mode)
88
89 def process_predictions(frame, predictions):
90 frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
91 if "panoptic_seg" in predictions:
92 panoptic_seg, segments_info = predictions["panoptic_seg"]
93 vis_frame = video_visualizer.draw_panoptic_seg_predictions(
94 frame, panoptic_seg.to(self.cpu_device), segments_info
95 )
96 elif "instances" in predictions:
97 predictions = predictions["instances"].to(self.cpu_device)
98 vis_frame = video_visualizer.draw_instance_predictions(frame, predictions)
99 elif "sem_seg" in predictions:
100 vis_frame = video_visualizer.draw_sem_seg(
101 frame, predictions["sem_seg"].argmax(dim=0).to(self.cpu_device)
102 )
103
104 # Converts Matplotlib RGB format to OpenCV BGR format
105 vis_frame = cv2.cvtColor(vis_frame.get_image(), cv2.COLOR_RGB2BGR)
106 return vis_frame
107
108 frame_gen = self._frame_from_video(video)
109 if self.parallel:

Callers

nothing calls this directly

Calls 5

get_imageMethod · 0.80
toMethod · 0.45
draw_sem_segMethod · 0.45

Tested by

no test coverage detected