in kornia 19 we have this handy function for that:
import cv2
import kornia
import torch
import numpy as np

def load_opencv_img(img_path: str) -> torch.Tensor:
    img: np.ndarray = cv2.imread(img_path, cv2.IMREAD_COLOR)  # HxWx3
    img_t: torch.Tensor = kornia.image_to_tensor(img)  # 1xCxHxW
    img_t = kornia.bgr_to_grayscale(img_t)  # Bx1xHxW
    return img_t