From 9f14a4f208ba40c7f1bce346f996ca66666f3b93 Mon Sep 17 00:00:00 2001 From: David Bau Date: Tue, 30 Aug 2022 03:01:20 -0400 Subject: [PATCH] Add clip normalization. --- baukit/renormalize.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/baukit/renormalize.py b/baukit/renormalize.py index fa4e8c6..a8f3c6d 100644 --- a/baukit/renormalize.py +++ b/baukit/renormalize.py @@ -92,6 +92,10 @@ OFFSET_SCALE = dict( zc=([0.5, 0.5, 0.5], [0.5, 0.5, 0.5]), # zero-mean, unit-variance over empirical ImageNet sample imagenet=([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]), + # clip normalization; see + # https://github.com/openai/CLIP/blob/c5478aac7b9e007a2659d36b57ebe148849e542a/clip/clip.py#L85 + clip=([0.48145466, 0.4578275, 0.40821073], + [0.26862954, 0.26130258, 0.27577711]), # zero-mean, 255 range over ImageNet sample imagenet_meanonly=([0.485, 0.456, 0.406], [1.0 / 255, 1.0 / 255, 1.0 / 255]),