pytorch-zero-lit
Converted official JAX models for LiT: Zero-Shot Transfer with Locked-image text Tuning to pytorch.
JAX -> Tensorflow -> ONNX -> Pytorch.
- Image encoder is loaded into pytorch and supports gradients
- Text encoder is not loaded into pytorch and runs via ONNX on cpu
Install
poetry add pytorch-zero-lit
or
pip install pytorch-zero-lit
Usage
from lit import LiT
model = LiT()
images = TF.to_tensor(
Image.open("cat.png").convert("RGB").resize((224, 224))
)[None]
texts = [
"a photo of a cat",
"a photo of a dog",
"a photo of a bird",
"a photo of a fish",
]
image_encodings = model.encode_images(images)
text_encodings = model.encode_texts(texts)
cosine_similarity = model.cosine_similarity(image_encodings, text_encodings)
Release files for pytorch-zero-lit 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytorch-zero-lit-0.2.3.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytorch_zero_lit-0.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.1 kB
Release files / pytorch-zero-lit-0.2.3.tar.gz
| Download URL | pytorch-zero-lit-0.2.3.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fae3fe704a1ae31d911ba89977523085f2d66bd309b037d1d0b2e7406337cf7a
|
|
BLAKE2b-256 checksum How to use checksums |
7a5f64443acd04ef801115ca0b5e3a4a37883239ee0ae19ce5afd0ebdb8047ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.8.8 Linux/5.15.0-48-generic
|
Release files / pytorch_zero_lit-0.2.3-py3-none-any.whl
| Download URL | pytorch_zero_lit-0.2.3-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eefa460f4e6ff0053c9ab308cfbe4ff442f9ecc718cdd02eefecfe7dfb1b416e
|
|
BLAKE2b-256 checksum How to use checksums |
5a630c8319ca80537e862dd335663af05213977b8465bc16e2f8111e4901abbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.8.8 Linux/5.15.0-48-generic
|