ClassificationTransformsEval

mail@pastecode.io avatar
unknown
python
a year ago
675 B
2
Indexable
Never
class ClassificationTransformsEval:
    def __init__(
        self,
        *,
        mean=(0.485, 0.456, 0.406),
        std=(0.229, 0.224, 0.225),
        resize,
        crop_size,
        aspect_ratio_th=4
    ):
        trans = [T.ToPILImage()]
        trans.append(ResizeCenterCropCollageEval(resize_size=resize, crop_size=crop_size, aspect_ratio_th=aspect_ratio_th))
        trans.extend(
            [
                T.PILToTensor(),
                T.ConvertImageDtype(torch.float),
                T.Normalize(mean=mean, std=std),
            ]
        )
        self.transforms = T.Compose(trans)

    def __call__(self, img):
        return self.transforms(img)