def save_rgb_results(gt_rgb: torch.Tensor, pred_rgb: torch.Tensor, path: str) -> None: r"""For saving RGB reconstruction results during EQA-CNN-Pretrain eval. Args: gt_rgb: RGB ground truth tensor pred_rgb: RGB reconstruction tensor path: to save images """ path = path.format(split="val", type="rgb") gt_bgr_o, pred_bgr = tensor_to_bgr_images([gt_rgb, pred_rgb]) cv2.imwrite(path + "_gt.jpg", gt_bgr_o) cv2.imwrite(path + "_pred.jpg", pred_bgr)
def save_vqa_image_results( images_tensor: torch.Tensor, question: str, prediction: str, ground_truth: str, path: str, ) -> None: r"""For saving VQA input images with input question and predicted answer. Being used to save model predictions during eval. Args: images_tensor: images' tensor containing input frames question: input question to model prediction: model's answer prediction ground_truth: ground truth answer path: to save images Returns: None """ images = tensor_to_bgr_images(images_tensor) collage_image = cv2.hconcat(images) collage_image = cv2.copyMakeBorder( collage_image, 55, 0, 0, 0, cv2.BORDER_CONSTANT, value=(255, 255, 255), ) image = put_vqa_text_on_image(collage_image, question, prediction, ground_truth) cv2.imwrite(path, image)