https://github.com/dusty-nv/clip_trt
CLIP and SigLIP models optimized with TensorRT with a Transformers-like API
https://github.com/dusty-nv/clip_trt
Last synced: 3 days ago
JSON representation
CLIP and SigLIP models optimized with TensorRT with a Transformers-like API
- Host: GitHub
- URL: https://github.com/dusty-nv/clip_trt
- Owner: dusty-nv
- License: mit
- Created: 2024-06-09T02:59:38.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-29T17:40:24.000Z (9 months ago)
- Last Synced: 2025-04-11T21:46:15.777Z (2 months ago)
- Language: Python
- Size: 71.3 KB
- Stars: 22
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# clip_trt
CLIP and SigLIP models optimized with TensorRT with a Transformers-like API### Command-Line Example
```bash
python3 -m clip_trt \
--inputs image_a.jpg image_b.jpg image_c.jpg \
--inputs 'a dog' 'a cat' 'a bear' 'a lion'
```### Code Example
```python
from clip_trt import CLIPModelmodel = CLIPModel.from_pretrained(
"openai/clip-vit-large-patch14-336",
use_tensorrt=True,
crop=False,
)similarity = model(
[
'my_image.jpg',
PIL.Image.open('image_2.jpg').convert('RGB'),
np.ndarray((3,480,640), dtype=np.uint8),
torch.ones((3,336,336), dtype=torch.uint8, device='cuda')
],
[
'a dog', 'a cat', 'a bear', 'a lion'
],
)
```### Embeddings
```
image_embed = model.embed('xyz.jpg')
text_embed = model.embed('an elephant in the jungle')
```