Untitled

ClassificationTransformsEval
 avatar
unknown
python
2 years ago
691 B
4
Indexable
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(), 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)
Editor is loading...