Update README.md
Browse files
README.md
CHANGED
@@ -12,3 +12,38 @@ Siglip2-base-patch16-224(https://huggingface.co/google/siglip2-base-patch16-224)
|
|
12 |
μ¬μ©λ νκ° λ°μ΄ν° : https://huggingface.co/datasets/hyunlord/aihub_image-caption_en-ko_karpathy-split (test)
|
13 |
|
14 |
## How to use
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
μ¬μ©λ νκ° λ°μ΄ν° : https://huggingface.co/datasets/hyunlord/aihub_image-caption_en-ko_karpathy-split (test)
|
13 |
|
14 |
## How to use
|
15 |
+
|
16 |
+
```python
|
17 |
+
import requests
|
18 |
+
import torch
|
19 |
+
from PIL import Image
|
20 |
+
from transformers import AutoModel, AutoProcessor
|
21 |
+
|
22 |
+
repo = "hyunlord/siglip2-base-patch16-224-ko"
|
23 |
+
model = AutoModel.from_pretrained(repo)
|
24 |
+
processor = AutoProcessor.from_pretrained(repo)
|
25 |
+
|
26 |
+
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
27 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
28 |
+
|
29 |
+
texts = ["κ³ μμ΄ ν λ§λ¦¬",
|
30 |
+
"κ³ μμ΄ λ λ§λ¦¬",
|
31 |
+
"λΆνμ μνμ λλ¬λμ΄ κ³ μμ΄ μΉκ΅¬λ€",
|
32 |
+
"리λͺ¨μ»¨κ³Ό κ³ μμ΄ λλ§λ¦¬",
|
33 |
+
"리λͺ¨μ»¨ λ κ°μ κ³ μμ΄ λλ§λ¦¬",
|
34 |
+
"λΆνμ μν μμ 리λͺ¨μ»¨ λ κ°μ λλ¬λμ΄ κ³ μμ΄ λλ§λ¦¬"]
|
35 |
+
inputs = processor(text=texts,
|
36 |
+
images=image,
|
37 |
+
padding="max_length",
|
38 |
+
max_length=64,
|
39 |
+
return_tensors="pt")
|
40 |
+
with torch.no_grad():
|
41 |
+
outputs = model(**inputs)
|
42 |
+
logits_per_image = outputs.logits_per_image
|
43 |
+
probs = torch.sigmoid(logits_per_image)
|
44 |
+
```
|
45 |
+
|
46 |
+
```python
|
47 |
+
>>> probs
|
48 |
+
tensor([[0.0038, 0.0429, 0.8294, 0.9787, 0.9816, 0.9990]])
|
49 |
+
```
|