trevorhobenshield
commited on
Commit
•
2a603e1
1
Parent(s):
cf14453
Update README.md
Browse files
README.md
CHANGED
@@ -14,7 +14,7 @@ from urllib.request import urlopen
|
|
14 |
|
15 |
import einops
|
16 |
import numpy as np
|
17 |
-
import onnxruntime
|
18 |
from PIL import Image
|
19 |
|
20 |
def softmax(x):
|
@@ -24,8 +24,8 @@ def softmax(x):
|
|
24 |
IMG_URL = 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
|
25 |
IN1K_CLASSES_URL = 'https://storage.googleapis.com/bit_models/ilsvrc2012_wordnet_lemmas.txt'
|
26 |
|
27 |
-
session =
|
28 |
-
# session =
|
29 |
|
30 |
labels = urlopen(IN1K_CLASSES_URL).read().decode().splitlines()
|
31 |
img = np.array(
|
@@ -43,7 +43,7 @@ img = einops.rearrange(img, 'h w c -> 1 c h w').astype(np.float32)
|
|
43 |
out = session.run(None, {session.get_inputs()[0].name: img})
|
44 |
|
45 |
out = softmax(out[0][0])
|
46 |
-
topk = np.argsort(out)[::-1][:5]
|
47 |
for i in topk:
|
48 |
print(f'{out[i]:.2f}', labels[i])
|
49 |
```
|
|
|
14 |
|
15 |
import einops
|
16 |
import numpy as np
|
17 |
+
import onnxruntime as ort
|
18 |
from PIL import Image
|
19 |
|
20 |
def softmax(x):
|
|
|
24 |
IMG_URL = 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
|
25 |
IN1K_CLASSES_URL = 'https://storage.googleapis.com/bit_models/ilsvrc2012_wordnet_lemmas.txt'
|
26 |
|
27 |
+
session = ort.InferenceSession('eva02_tiny_patch14_336.mim_in22k_ft_in1k.ort')
|
28 |
+
# session = ort.InferenceSession('eva02_tiny_patch14_336.mim_in22k_ft_in1k.onnx')
|
29 |
|
30 |
labels = urlopen(IN1K_CLASSES_URL).read().decode().splitlines()
|
31 |
img = np.array(
|
|
|
43 |
out = session.run(None, {session.get_inputs()[0].name: img})
|
44 |
|
45 |
out = softmax(out[0][0])
|
46 |
+
topk = np.argsort(out)[::-1][:5]
|
47 |
for i in topk:
|
48 |
print(f'{out[i]:.2f}', labels[i])
|
49 |
```
|