hyunlord commited on
Commit
a65bb64
Β·
verified Β·
1 Parent(s): 4072019

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +35 -0
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
+ ```