Update README.md
Browse files
README.md
CHANGED
@@ -21,9 +21,31 @@ widget:
|
|
21 |
|
22 |
You can use the raw model for tasks like zero-shot image classification and image-text retrieval.
|
23 |
|
|
|
24 |
### How to use
|
25 |
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
```python
|
29 |
from PIL import Image
|
|
|
21 |
|
22 |
You can use the raw model for tasks like zero-shot image classification and image-text retrieval.
|
23 |
|
24 |
+
|
25 |
### How to use
|
26 |
|
27 |
+
#### Use Git-RSCLIP to get image features
|
28 |
+
|
29 |
+
```python
|
30 |
+
from PIL import Image
|
31 |
+
import requests
|
32 |
+
from transformers import AutoProcessor, AutoModel
|
33 |
+
import torch
|
34 |
+
|
35 |
+
model = AutoModel.from_pretrained("lcybuaa/Git-RSCLIP")
|
36 |
+
processor = AutoProcessor.from_pretrained("lcybuaa/Git-RSCLIP")
|
37 |
+
|
38 |
+
url = "https://github.com/Chen-Yang-Liu/PromptCC/blob/main/Example/B/train_000051.png?raw=true"
|
39 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
40 |
+
|
41 |
+
inputs = processor(images=image, return_tensors="pt")
|
42 |
+
|
43 |
+
with torch.no_grad():
|
44 |
+
image_features = model.get_image_features(**inputs)
|
45 |
+
```
|
46 |
+
|
47 |
+
|
48 |
+
#### zero-shot image classification:
|
49 |
|
50 |
```python
|
51 |
from PIL import Image
|