File size: 759 Bytes
e857f97 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import PIL
import cv2
import numpy as np
import torch
from PIL import Image
from torch import nn
from torchvision import transforms
from open_clip.constants import OPENAI_DATASET_MEAN, OPENAI_DATASET_STD
def get_thermal_transform(args):
transform = transforms.Compose(
[
transforms.ToTensor(),
transforms.Resize(224, interpolation=transforms.InterpolationMode.BICUBIC),
transforms.CenterCrop(224),
transforms.Normalize(OPENAI_DATASET_MEAN, OPENAI_DATASET_STD) # assume image
]
)
return transform
def load_and_transform_thermal(thermal_path, transform):
thermal = Image.open(thermal_path)
thermal_outputs = transform(thermal)
return {'pixel_values': thermal_outputs}
|