If we try to load a CLIP model that has not been traced (and is saved as a state_dict), then this first tries to load it with `torch.jit.load(opened_file)` while will eventually raise a RuntimeError, which is then caught and handled and you re-try loading the model with `torch.load(opened_file)`. However, the file pointer, `opened_file` has been advanced by `torch.jit.load`, so this attempt fails with a `EOFError: Ran out of input` exception. To fix this, we simply need to reset the file pointer to the beginning of the file with `.fseek(0)`
* import packaging to be compatible with setuptools==70.0.0
* importing the version module
---------
Co-authored-by: Jamie <Jamie@Alexandras-MacBook-Pro.local>
Co-authored-by: Jong Wook Kim <jongwook@nyu.edu>
* use pkg_resources for PyTorch version checks in notebooks
* remove version checking in notebook code cell
Co-authored-by: Jong Wook Kim <jongwook@nyu.edu>
* Patch clip model for ONNX compatibility
Changes to use INT32 for tokenization, since ONNX doesn't yet support ArgMax(INT64)
Use explicit dimension for norm
* Add compatibility fix for torch 1.7
This prevents the following error on Windows (when using
a multi-process DataLoader, for example):
AttributeError: Can't pickle local object '_transform.<locals>.<lambda>'
* Can specify root directory when loading model
* specifying download_root instead
* Update Prompt_Engineering_for_ImageNet.ipynb
Fix bug caused by changing default to jit=False with handling the case jit=True as well
* Reduce size of diff
* Reduce size of diff #2
* Reduce size of diff #3
* updated Interacting_with_CLIP.ipynb
* update Prompt_Engineering_for_ImageNet.ipynb
Co-authored-by: kcosta42 <kcosta@student.42.fr>
Co-authored-by: Jong Wook Kim <jongwook@openai.com>
* Add truncate_text option to tokenize
This makes it possible to run tokenize on texts that are longer than the number of tokens
that fit the context length without having to try to guess how to cut in number of
characters beforehand
* add doc, rename to just "truncate", use eot_token
Co-authored-by: Jong Wook Kim <jongwook@openai.com>