Commit
ยท
e4d78d5
1
Parent(s):
9cf6c45
change_folder
Browse files- config.json +1 -2
- example_2.py +16 -0
config.json
CHANGED
|
@@ -9,8 +9,7 @@
|
|
| 9 |
"head_init_scale": 1.0,
|
| 10 |
|
| 11 |
"torch_dtype": "float32",
|
| 12 |
-
|
| 13 |
-
// Auto ํด๋์ค๋ค์ด ์ด ๋ ํฌ ์์ ์ด๋ค ์ฝ๋๋ฅผ ์จ์ผ ํ๋์ง ์๋ ค์ฃผ๋ ๋ถ๋ถ
|
| 14 |
"auto_map": {
|
| 15 |
"AutoConfig": "modeling_csatv2.CSATv2Config",
|
| 16 |
"AutoModelForImageClassification": "modeling_csatv2.CSATv2ForImageClassification"
|
|
|
|
| 9 |
"head_init_scale": 1.0,
|
| 10 |
|
| 11 |
"torch_dtype": "float32",
|
| 12 |
+
|
|
|
|
| 13 |
"auto_map": {
|
| 14 |
"AutoConfig": "modeling_csatv2.CSATv2Config",
|
| 15 |
"AutoModelForImageClassification": "modeling_csatv2.CSATv2ForImageClassification"
|
example_2.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import requests
|
| 4 |
+
|
| 5 |
+
processor = AutoImageProcessor.from_pretrained("Hyunil/CSATv2", trust_remote_code=True)
|
| 6 |
+
model = AutoModelForImageClassification.from_pretrained("Hyunil/CSATv2", trust_remote_code=True)
|
| 7 |
+
|
| 8 |
+
url = "https://images.unsplash.com/photo-1516116216624-53e697fedbea"
|
| 9 |
+
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
|
| 10 |
+
|
| 11 |
+
inputs = processor(image, return_tensors="pt")
|
| 12 |
+
outputs = model(**inputs)
|
| 13 |
+
probs = outputs.logits.softmax(dim=-1)
|
| 14 |
+
|
| 15 |
+
top_prob, top_idx = probs.topk(5)
|
| 16 |
+
print(top_idx, top_prob)
|