chamidullinr commited on
Commit
27e0aca
1 Parent(s): 9d369ef

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +56 -0
README.md ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - ResNet-50
6
+ ---
7
+
8
+ # ResNet-50
9
+
10
+ ## Model Description
11
+
12
+ ResNet-50 model from [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385) paper.
13
+
14
+ ## Original implementation
15
+
16
+ Follow [this link](https://huggingface.co/microsoft/resnet-50) to see the original implementation.
17
+
18
+ # How to use
19
+
20
+ You can use the `base` model that returns `last_hidden_state`.
21
+ ```python
22
+ from transformers import AutoFeatureExtractor
23
+ from onnxruntime import InferenceSession
24
+ from datasets import load_dataset
25
+
26
+ # load image
27
+ dataset = load_dataset("huggingface/cats-image")
28
+ image = dataset["test"]["image"][0]
29
+
30
+ # load model
31
+ feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/resnet-50")
32
+ session = InferenceSession("onnx/model.onnx")
33
+
34
+ # ONNX Runtime expects NumPy arrays as input
35
+ inputs = feature_extractor(image, return_tensors="np")
36
+ outputs = session.run(output_names=["last_hidden_state"], input_feed=dict(inputs))
37
+ ```
38
+
39
+ Or you can use the model with classification head that returns `logits`.
40
+ ```python
41
+ from transformers import AutoFeatureExtractor
42
+ from onnxruntime import InferenceSession
43
+ from datasets import load_dataset
44
+
45
+ # load image
46
+ dataset = load_dataset("huggingface/cats-image")
47
+ image = dataset["test"]["image"][0]
48
+
49
+ # load model
50
+ feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/resnet-50")
51
+ session = InferenceSession("onnx/model_cls.onnx")
52
+
53
+ # ONNX Runtime expects NumPy arrays as input
54
+ inputs = feature_extractor(image, return_tensors="np")
55
+ outputs = session.run(output_names=["logits"], input_feed=dict(inputs))
56
+ ```