[PR #137] [MERGED] Fix bug #138 by handling jit cases #461

Closed
opened 2026-10-31 21:15:13 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/openai/CLIP/pull/137
Author: @or-toledano
Created: 8/8/2021
Status: ✅ Merged
Merged: 8/9/2021
Merged by: @jongwook

Base: main ← Head: patch-1


📝 Commits (8)

  • 53e1d0b Can specify root directory when loading model
  • 6599907 specifying download_root instead
  • 991ca4a Update Prompt_Engineering_for_ImageNet.ipynb
  • ea7f744 Reduce size of diff
  • 311a078 Reduce size of diff #2
  • a2c8ae2 Reduce size of diff #3
  • 9323115 updated Interacting_with_CLIP.ipynb
  • d17f612 update Prompt_Engineering_for_ImageNet.ipynb

📊 Changes

3 files changed (+577 additions, -582 deletions)

View changed files

📝 clip/clip.py (+7 -4)
📝 notebooks/Interacting_with_CLIP.ipynb (+454 -382)
📝 notebooks/Prompt_Engineering_for_ImageNet.ipynb (+116 -196)

📄 Description

Fixed bug #138 caused by changing default to jit=False with handling the case jit=True as well.
(Causes: ModuleAttributeError: 'CLIP' object has no attribute 'input_resolution')
This cell won't run otherwise as the attributes and types are jit dependent. Changed to:

    jit = True  
    model, preprocess = clip.load("ViT-B/32", jit=jit)
    if jit  
        input_resolution = model.input_resolution.item()  
        context_length = model.context_length.item()  
        vocab_size = model.vocab_size.item()  
    else:  
        input_resolution = model.visual.input_resolution  
        context_length = model.context_length  
        vocab_size = model.vocab_size  

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/openai/CLIP/pull/137 **Author:** [@or-toledano](https://github.com/or-toledano) **Created:** 8/8/2021 **Status:** ✅ Merged **Merged:** 8/9/2021 **Merged by:** [@jongwook](https://github.com/jongwook) **Base:** `main` ← **Head:** `patch-1` --- ### 📝 Commits (8) - [`53e1d0b`](https://github.com/openai/CLIP/commit/53e1d0b6aaf91423d1bf91248205b73198caa760) Can specify root directory when loading model - [`6599907`](https://github.com/openai/CLIP/commit/6599907d3e3c809b8c1a85fa317774241c0b4740) specifying download_root instead - [`991ca4a`](https://github.com/openai/CLIP/commit/991ca4a48ff926233384adbbbb9767a070e58232) Update Prompt_Engineering_for_ImageNet.ipynb - [`ea7f744`](https://github.com/openai/CLIP/commit/ea7f744b2f8b685b218ee33cf3fc6753a097bba7) Reduce size of diff - [`311a078`](https://github.com/openai/CLIP/commit/311a0784a290443e26a0d68a2594dba9630c386a) Reduce size of diff #2 - [`a2c8ae2`](https://github.com/openai/CLIP/commit/a2c8ae2af8dc1fbf0962b61f5b611c2271ac32e3) Reduce size of diff #3 - [`9323115`](https://github.com/openai/CLIP/commit/9323115d59bd140f586914a34314cd48ef706356) updated Interacting_with_CLIP.ipynb - [`d17f612`](https://github.com/openai/CLIP/commit/d17f612a64353a2b82a42e0a39d8026360d90da2) update Prompt_Engineering_for_ImageNet.ipynb ### 📊 Changes **3 files changed** (+577 additions, -582 deletions) <details> <summary>View changed files</summary> 📝 `clip/clip.py` (+7 -4) 📝 `notebooks/Interacting_with_CLIP.ipynb` (+454 -382) 📝 `notebooks/Prompt_Engineering_for_ImageNet.ipynb` (+116 -196) </details> ### 📄 Description Fixed bug #138 caused by changing default to jit=False with handling the case jit=True as well. (Causes: `ModuleAttributeError: 'CLIP' object has no attribute 'input_resolution'`) This cell won't run otherwise as the attributes and types are jit dependent. Changed to: ``` jit = True model, preprocess = clip.load("ViT-B/32", jit=jit) ``` ```` if jit input_resolution = model.input_resolution.item() context_length = model.context_length.item() vocab_size = model.vocab_size.item() else: input_resolution = model.visual.input_resolution context_length = model.context_length vocab_size = model.vocab_size ```` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 21:15:13 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openai/CLIP#461
No description provided.