Open josh-wende opened 1 year ago
The network expects BGR inputs during inference, you can use the following code to verify in Jupyter Notebook:
import cv2
import numpy as np
import torch
from PIL import Image
from clrnet.datasets import build_dataloader
from clrnet.utils.config import Config
cfg = Config.fromfile("configs/clrnet/clr_resnet18_tusimple.py")
cfg.gpus = 1
cfg.seed = 0
test_loader = build_dataloader(cfg.dataset.test, cfg, is_train=False)
test_set = test_loader.dataset
idx = 2
# (C, H, W) -> (H, W, C)
Image.fromarray((test_set[idx]["img"].permute(1, 2, 0).numpy() * 255).astype(np.uint8))
In the second cell:
img = cv2.imread(test_set[idx]["meta"].data["full_img_path"])[cfg.cut_height :, :, :]
Image.fromarray(cv2.resize(img, (cfg.img_w, cfg.img_h)))
The two images are the same. Because cv2.imread
reads the images in BGR order, the input to the network is also BGR.
Looking at the code, it is non-obvious to me. Appreciate the help.