added readme
Browse files- README.md +35 -1
- onnx/model.onnx +3 -0
README.md
CHANGED
@@ -1,3 +1,37 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language: en
|
3 |
+
tags:
|
4 |
+
- deit
|
5 |
+
license: apache-2.0
|
6 |
---
|
7 |
+
|
8 |
+
# DeiT
|
9 |
+
|
10 |
+
## Model description
|
11 |
+
|
12 |
+
DeiT proposed in [this paper](https://arxiv.org/abs/2012.12877) are more efficiently trained transformers for image classification, requiring far less data and far less computing resources compared to the original ViT models.
|
13 |
+
|
14 |
+
## Original implementation
|
15 |
+
|
16 |
+
Follow [this link](https://huggingface.co/docs/transformers/main/en/model_doc/deit#deit) to see the original implementation.
|
17 |
+
|
18 |
+
## How to use
|
19 |
+
|
20 |
+
```{python}
|
21 |
+
from onnxruntime import InferenceSession
|
22 |
+
from transformers import DeiTFeatureExtractor, DeiTForImageClassification
|
23 |
+
import torch
|
24 |
+
from PIL import Image
|
25 |
+
import requests
|
26 |
+
|
27 |
+
torch.manual_seed(3)
|
28 |
+
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
29 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
30 |
+
|
31 |
+
feature_extractor = DeiTFeatureExtractor.from_pretrained("facebook/deit-base-distilled-patch16-224")
|
32 |
+
inputs = feature_extractor(images=image, return_tensors="np")
|
33 |
+
session = InferenceSession("onnx/model.onnx")
|
34 |
+
|
35 |
+
# ONNX Runtime expects NumPy arrays as input
|
36 |
+
outputs = session.run(output_names=["last_hidden_state"], input_feed=dict(inputs))
|
37 |
+
```
|
onnx/model.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5ff45d3308d00918461270c16bda63a37cb099c264c01e2fc55412110fe18ee1
|
3 |
+
size 345664810
|