https://github.com/bes-dev/pytorch_clip_interrogator
Image-to-prompt reconstruction.
https://github.com/bes-dev/pytorch_clip_interrogator
Last synced: 12 months ago
JSON representation
Image-to-prompt reconstruction.
- Host: GitHub
- URL: https://github.com/bes-dev/pytorch_clip_interrogator
- Owner: bes-dev
- License: bsd-2-clause
- Created: 2023-02-19T15:50:09.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-01T08:25:02.000Z (about 3 years ago)
- Last Synced: 2025-07-01T09:05:33.120Z (12 months ago)
- Language: Python
- Size: 778 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pytorch_clip_interrogator: Image-To-Promt.
[](https://pepy.tech/project/pytorch_clip_interrogator)
[](https://pepy.tech/project/pytorch_clip_interrogator)
[](https://pepy.tech/project/pytorch_clip_interrogator)
## Install package
```bash
pip install pytorch_clip_interrogator
```
## Install the latest version
```bash
pip install --upgrade git+https://github.com/bes-dev/pytorch_clip_interrogator.git
```
## Features
- Fully compatible with models from Huggingface.
- Supports BLIP 1/2 model.
- Support batch processing.
## Usage
### Simple code
```python
import torch
import requests
from PIL import Image
from pytorch_clip_interrogator import PromptEngineer
# build pipeline
pipe = PromptEngineer(
blip_model="Salesforce/blip2-opt-2.7b",
clip_model="openai/clip-vit-base-patch32",
device="cuda",
torch_dtype=torch.float16
)
# load image
img_url = 'https://storage.googleapis.com/sfr-vision-language-research/BLIP/demo.jpg'
image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB')
# generate caption
print(pipe(image))
```