From 2dc850998a6cc551ad45c7b3d10d60145c2d8d8d Mon Sep 17 00:00:00 2001 From: Matias Mattamala Date: Sat, 3 Feb 2024 12:10:38 +0000 Subject: [PATCH] Add missing testing file --- wild_visual_navigation/utils/testing.py | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 wild_visual_navigation/utils/testing.py diff --git a/wild_visual_navigation/utils/testing.py b/wild_visual_navigation/utils/testing.py new file mode 100644 index 00000000..9c1a2224 --- /dev/null +++ b/wild_visual_navigation/utils/testing.py @@ -0,0 +1,29 @@ +import os +import cv2 +import torch +from torchvision import transforms as T +from wild_visual_navigation import WVN_ROOT_DIR + + +def load_test_image(): + np_img = cv2.imread(os.path.join(WVN_ROOT_DIR, "assets/images/forest_clean.png")) + img = torch.from_numpy(cv2.cvtColor(np_img, cv2.COLOR_BGR2RGB)) + img = img.permute(2, 0, 1) + img = (img.type(torch.float32) / 255)[None] + return img + + +def get_dino_transform(): + transform = T.Compose( + [ + T.Resize(448, T.InterpolationMode.NEAREST), + T.CenterCrop(448), + ] + ) + return transform + + +def make_results_folder(name): + path = os.path.join(WVN_ROOT_DIR, "results", name) + os.makedirs(path, exist_ok=True) + return path