(frame, predictions)
| 90 | video_visualizer = VideoVisualizer(self.metadata, self.instance_mode) |
| 91 | |
| 92 | def process_predictions(frame, predictions): |
| 93 | frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR) |
| 94 | if "panoptic_seg" in predictions: |
| 95 | panoptic_seg, segments_info = predictions["panoptic_seg"] |
| 96 | vis_frame = video_visualizer.draw_panoptic_seg_predictions( |
| 97 | frame, panoptic_seg.to(self.cpu_device), segments_info |
| 98 | ) |
| 99 | elif "instances" in predictions: |
| 100 | predictions = predictions["instances"].to(self.cpu_device) |
| 101 | predictions = predictions[predictions.scores > confidence_threshold] |
| 102 | vis_frame = video_visualizer.draw_instance_predictions(frame, predictions) |
| 103 | elif "sem_seg" in predictions: |
| 104 | vis_frame = video_visualizer.draw_sem_seg( |
| 105 | frame, predictions["sem_seg"].argmax(dim=0).to(self.cpu_device) |
| 106 | ) |
| 107 | |
| 108 | # Converts Matplotlib RGB format to OpenCV BGR format |
| 109 | vis_frame = cv2.cvtColor(vis_frame.get_image(), cv2.COLOR_RGB2BGR) |
| 110 | return vis_frame |
| 111 | |
| 112 | frame_gen = self._frame_from_video(video) |
| 113 | if self.parallel: |
nothing calls this directly
no test coverage detected