def run_on_image(self, image, visualizer=None):
        """
        Args:
            image (np.ndarray): an image of shape (H, W, C) (in BGR order).
                This is the format used by OpenCV.

        Returns:
            predictions (dict): the output of the model.
            vis_output (VisImage): the visualized image output.
        """
        vis_output = None
        predictions = self.predictor(image)
        # Convert image from OpenCV BGR format to Matplotlib RGB format.
        image = image[:, :, ::-1]
        use_video_vis = True
        if visualizer is None:
            use_video_vis = False
            visualizer = Visualizer(image, self.metadata, instance_mode=self.instance_mode)
        if "panoptic_seg" in predictions:
            panoptic_seg, segments_info = predictions["panoptic_seg"]
            vis_output = visualizer.draw_panoptic_seg_predictions(
                panoptic_seg.to(self.cpu_device), segments_info
            )
        else:
            if "sem_seg" in predictions:
                vis_output = visualizer.draw_sem_seg(
                    predictions["sem_seg"].argmax(dim=0).to(self.cpu_device)
                )
            if "instances" in predictions:
                instances = predictions["instances"].to(self.cpu_device)
                if use_video_vis:
                    vis_output = visualizer.draw_instance_predictions(
                        image, predictions=instances)
                else:
                    vis_output = visualizer.draw_instance_predictions(predictions=instances)
            elif "proposals" in predictions:
                instances = predictions["proposals"].to(self.cpu_device)
                instances.pred_boxes = instances.proposal_boxes
                instances.scores = instances.objectness_logits
                instances.pred_classes[:] = -1
                if use_video_vis:
                    vis_output = visualizer.draw_instance_predictions(
                        image, predictions=instances)
                else:
                    vis_output = visualizer.draw_instance_predictions(predictions=instances)

        return predictions, vis_output

        Args:
            image (np.ndarray): an image of shape (H, W, C) (in BGR order).
                This is the format used by OpenCV.

        Returns:
            predictions (dict): the output of the model.
            vis_output (VisImage): the visualized image output.
        
video_chat_text/video_chat_with_StableLM/models/grit_src/third_party/CenterNet2/projects/CenterNet2/predictor.py