[DS] Normalization과 Standardization

김유상·2023년 2월 7일
0

참고 링크: https://heeya-stupidbutstudying.tistory.com/entry/%ED%86%B5%EA%B3%84-%EC%A0%95%EA%B7%9C%ED%99%94%EC%99%80-%ED%91%9C%EC%A4%80%ED%99%94

나중에 필자가 살펴보기 위해 먼저 링크를 남긴다.

PyTorch의 Torchvision.transforms를 이용한 방법

transform = transforms.Compose([
	transforms.Resize((300, 300)),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.406, 0.456, 0.485], std=[0.225, 0.224, 0.229])
    ])

단순히 numpy연산을 이용한 방법

resized_image = resized_image.astype(np.float32)
mean = (0.406, 0.456, 0.485)
std = (0.225, 0.224, 0.229)
resized_image /= 255.0
resized_image -= mean
resized_image /= std

opencv에서 제공하는 blobFromImage api를 이용하는 방법

blob_image = cv2.dnn.blobFromImage(resized_image, scalefactor=0.007843, size=(300,300), mean=(127.5, 127.5, 127.5), swapRB=False)
profile
continuous programming

0개의 댓글