From 77a6ceffe4ca7b988b2126a1fa409bd273f8a233 Mon Sep 17 00:00:00 2001 From: EIFY Date: Fri, 18 Aug 2023 13:17:31 -0700 Subject: [PATCH 1/4] Update timm to 0.9.5 Models like eva_giant_patch14_224 require timm 0.9.x --- requirements-test.txt | 2 +- requirements-training.txt | 2 +- requirements.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements-test.txt b/requirements-test.txt index 5d2e7e147..ae2a0563f 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,4 +1,4 @@ pytest-split==0.8.0 pytest==7.2.0 transformers -timm==0.6.11 +timm>=0.9.5 diff --git a/requirements-training.txt b/requirements-training.txt index c44eb61d7..0f4970476 100644 --- a/requirements-training.txt +++ b/requirements-training.txt @@ -8,5 +8,5 @@ pandas braceexpand huggingface_hub transformers -timm +timm>=0.9.5 fsspec diff --git a/requirements.txt b/requirements.txt index 6a469e6fb..7b4ba50f6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,4 @@ tqdm huggingface_hub sentencepiece protobuf<4 -timm +timm>=0.9.5 From 6be6dc8beec283c2d620bf568f8baddcea13b07a Mon Sep 17 00:00:00 2001 From: EIFY Date: Mon, 11 Sep 2023 12:57:15 -0700 Subject: [PATCH 2/4] relax back the main `requirements.txt` --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7b4ba50f6..6a469e6fb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,4 @@ tqdm huggingface_hub sentencepiece protobuf<4 -timm>=0.9.5 +timm From a4b5bc351ed2e871911fe509d2824fb8e3d63d99 Mon Sep 17 00:00:00 2001 From: Ross Wightman Date: Mon, 11 Sep 2023 12:50:14 -0700 Subject: [PATCH 3/4] Convert JIT model (on state dict load) to sd for pretrained='filename.pt' support for OpenAI .pt files. Fix #622 --- src/open_clip/factory.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/open_clip/factory.py b/src/open_clip/factory.py index 72a4e4d18..e4f0b7632 100644 --- a/src/open_clip/factory.py +++ b/src/open_clip/factory.py @@ -88,6 +88,10 @@ def load_state_dict(checkpoint_path: str, map_location='cpu'): checkpoint = torch.load(checkpoint_path, map_location=map_location) if isinstance(checkpoint, dict) and 'state_dict' in checkpoint: state_dict = checkpoint['state_dict'] + elif isinstance(checkpoint, torch.jit.ScriptModule): + state_dict = checkpoint.state_dict() + for key in ["input_resolution", "context_length", "vocab_size"]: + state_dict.pop(key, None) else: state_dict = checkpoint if next(iter(state_dict.items()))[0].startswith('module'): From f692ec95e1bf30d50aeabe2fd32008cdff53ef5e Mon Sep 17 00:00:00 2001 From: Nikolaus Korfhage Date: Thu, 14 Sep 2023 13:07:44 +0200 Subject: [PATCH 4/4] Fixed padding error in ResizeMaxSize --- src/open_clip/transform.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/open_clip/transform.py b/src/open_clip/transform.py index 748884a3c..ab13a21aa 100644 --- a/src/open_clip/transform.py +++ b/src/open_clip/transform.py @@ -40,9 +40,10 @@ def forward(self, img): else: width, height = img.size scale = self.max_size / float(max(height, width)) + new_size = tuple(round(dim * scale) for dim in (height, width)) if scale != 1.0: - new_size = tuple(round(dim * scale) for dim in (height, width)) img = F.resize(img, new_size, self.interpolation) + if not width == height: pad_h = self.max_size - new_size[0] pad_w = self.max_size - new_size[1] img = F.pad(img, padding=[pad_w//2, pad_h//2, pad_w - pad_w//2, pad_h - pad_h//2], fill=self.fill)