Skip to content

Commit 932293f

Browse files
author
Anna Grebneva
authored
Added ConvNeXt Tiny model (#3419)
1 parent 3fb7f24 commit 932293f

File tree

11 files changed

+255
-0
lines changed

11 files changed

+255
-0
lines changed

demos/classification_benchmark_demo/cpp/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ omz_converter --list models.lst
3737

3838
* alexnet
3939
* caffenet
40+
* convnext-tiny
4041
* densenet-121
4142
* densenet-121-tf
4243
* dla-34

demos/classification_benchmark_demo/cpp/models.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This file can be used with the --list option of the model downloader.
22
alexnet
33
caffenet
4+
convnext-tiny
45
densenet-121
56
densenet-121-tf
67
dla-34

demos/classification_demo/python/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ omz_converter --list models.lst
3939

4040
* alexnet
4141
* caffenet
42+
* convnext-tiny
4243
* densenet-121
4344
* densenet-121-tf
4445
* dla-34

demos/classification_demo/python/models.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This file can be used with the --list option of the model downloader.
22
alexnet
33
caffenet
4+
convnext-tiny
45
densenet-121
56
densenet-121-tf
67
dla-34

models/public/convnext-tiny/README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# convnext-tiny
2+
3+
## Use Case and High-Level Description
4+
5+
The `convnext-tiny` model is tiny version of ConvNeXt model, constructed entirely from standard ConvNet modules. ConvNeXt is accurate, efficient, scalable and very simple in design. The model is pre-trained for image classification task on the ImageNet dataset.
6+
7+
The model input is a blob that consists of a single image of `1, 3, 224, 224` in `RGB` order.
8+
9+
The model output is typical object classifier for the 1000 different classifications matching with those in the ImageNet database.
10+
11+
For details see [repository](https://github.com/rwightman/pytorch-image-models) and [paper](https://arxiv.org/abs/2201.03545).
12+
13+
## Specification
14+
15+
| Metric | Value |
16+
| ---------------- | -------------- |
17+
| Type | Classification |
18+
| GFLOPs | 8.9419 |
19+
| MParams | 28.5892 |
20+
| Source framework | PyTorch\* |
21+
22+
## Accuracy
23+
24+
| Metric | Value |
25+
| ------ | ----- |
26+
| Top 1 | 82.05% |
27+
| Top 5 | 95.86% |
28+
29+
## Input
30+
31+
### Original model
32+
33+
Image, name - `image`, shape - `1, 3, 224, 224`, format is `B, C, H, W`, where:
34+
35+
- `B` - batch size
36+
- `C` - channel
37+
- `H` - height
38+
- `W` - width
39+
40+
Channel order is `RGB`.
41+
Mean values - [123.675,116.28,103.53], scale values - [58.395, 57.12, 57.375].
42+
43+
### Converted model
44+
45+
Image, name - `image`, shape - `1, 3, 224, 224`, format is `B, C, H, W`, where:
46+
47+
- `B` - batch size
48+
- `C` - channel
49+
- `H` - height
50+
- `W` - width
51+
52+
Channel order is `BGR`.
53+
54+
## Output
55+
56+
### Original model
57+
58+
Object classifier according to ImageNet classes, name - `probs`, shape - `1, 1000`, output data format is `B, C`, where:
59+
60+
- `B` - batch size
61+
- `C` - predicted probabilities for each class in logits format
62+
63+
### Converted model
64+
65+
Object classifier according to ImageNet classes, name - `probs`, shape - `1, 1000`, output data format is `B, C`, where:
66+
67+
- `B` - batch size
68+
- `C` - predicted probabilities for each class in logits format
69+
70+
## Download a Model and Convert it into OpenVINO™ IR Format
71+
72+
You can download models and if necessary convert them into OpenVINO™ IR format using the [Model Downloader and other automation tools](../../../tools/model_tools/README.md) as shown in the examples below.
73+
74+
An example of using the Model Downloader:
75+
```
76+
omz_downloader --name <model_name>
77+
```
78+
79+
An example of using the Model Converter:
80+
```
81+
omz_converter --name <model_name>
82+
```
83+
84+
## Demo usage
85+
86+
The model can be used in the following demos provided by the Open Model Zoo to show its capabilities:
87+
88+
* [Classification Benchmark C++ Demo](../../../demos/classification_benchmark_demo/cpp/README.md)
89+
* [Classification Python\* Demo](../../../demos/classification_demo/python/README.md)
90+
91+
## Legal Information
92+
93+
The original model is distributed under the
94+
[Apache License, Version 2.0](https://raw.githubusercontent.com/rwightman/pytorch-image-models/master/LICENSE).
95+
A copy of the license is provided in `<omz_dir>/models/public/licenses/APACHE-2.0-PyTorch-Image-Models.txt`.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
models:
2+
- name: convnext-tiny-onnx
3+
4+
launchers:
5+
- framework: onnx_runtime
6+
model: convnext-tiny.onnx
7+
adapter: classification
8+
9+
datasets:
10+
- name: imagenet_1000_classes
11+
reader: pillow_imread
12+
preprocessing:
13+
- type: resize
14+
size: 256
15+
interpolation: BICUBIC
16+
aspect_ratio_scale: greater
17+
use_pillow: True
18+
- type: crop
19+
size: 224
20+
use_pillow: True
21+
- type: normalization
22+
mean: [123.675, 116.28, 103.53]
23+
std: [58.395, 57.12, 57.375]
24+
metrics:
25+
- name: accuracy@top1
26+
type: accuracy
27+
top_k: 1
28+
reference: 0.8205
29+
- name: accuracy@top5
30+
type: accuracy
31+
top_k: 5
32+
reference: 0.9586
33+
34+
- name: convnext-tiny
35+
36+
launchers:
37+
- framework: openvino
38+
adapter: classification
39+
40+
datasets:
41+
- name: imagenet_1000_classes
42+
reader: pillow_imread
43+
preprocessing:
44+
- type: resize
45+
size: 256
46+
interpolation: BICUBIC
47+
aspect_ratio_scale: greater
48+
use_pillow: True
49+
- type: crop
50+
size: 224
51+
use_pillow: True
52+
- type: rgb_to_bgr
53+
metrics:
54+
- name: accuracy@top1
55+
type: accuracy
56+
top_k: 1
57+
reference: 0.8205
58+
- name: accuracy@top5
59+
type: accuracy
60+
top_k: 5
61+
reference: 0.9586

models/public/convnext-tiny/model.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (c) 2022 Intel Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from torch import load
16+
from timm.models.convnext import convnext_tiny, checkpoint_filter_fn
17+
18+
19+
def create_convnext(weights):
20+
model = convnext_tiny()
21+
22+
checkpoint = load(weights, map_location='cpu')
23+
ckpt = checkpoint_filter_fn(checkpoint, model)
24+
model.load_state_dict(ckpt)
25+
26+
return model

models/public/convnext-tiny/model.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Copyright (c) 2022 Intel Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
description: >-
16+
The "convnext-tiny" model is tiny version of ConvNeXt model, constructed entirely
17+
from standard ConvNet modules. ConvNeXt is accurate, efficient, scalable and very
18+
simple in design. The model is pre-trained for image classification task on the
19+
ImageNet dataset.
20+
21+
The model input is a blob that consists of a single image of "1, 3, 224, 224" in
22+
"RGB" order.
23+
24+
The model output is typical object classifier for the 1000 different classifications
25+
matching with those in the ImageNet database.
26+
27+
For details see repository <https://github.com/rwightman/pytorch-image-models> and
28+
paper <https://arxiv.org/abs/2201.03545>.
29+
task_type: classification
30+
files:
31+
- name: timm-0.5.4-py3-none-any.whl
32+
size: 431537
33+
checksum: e8f1967a8e2029fe21a43875132b4b123227b718abc35725d7f2b9fd0ef2062884ac3dd558570b51a780aad89bc375d6
34+
source: https://files.pythonhosted.org/packages/49/65/a83208746dc9c0d70feff7874b49780ff110810feb528df4b0ecadcbee60/timm-0.5.4-py3-none-any.whl
35+
- name: convnext_tiny_1k_224_ema.pth
36+
size: 114414741
37+
checksum: f277194ca9561079ea0519fffc204820922ae46dc865b9def7208cf5993382d6cced681d3d26f6b70c31bf7cec4aba62
38+
original_source: https://dl.fbaipublicfiles.com/convnext/convnext_tiny_1k_224_ema.pth
39+
source: https://storage.openvinotoolkit.org/repositories/open_model_zoo/public/2022.2/convnext-tiny/convnext_tiny_1k_224_ema.pth
40+
postprocessing:
41+
- $type: unpack_archive
42+
format: zip
43+
file: timm-0.5.4-py3-none-any.whl
44+
conversion_to_onnx_args:
45+
- --model-path=$dl_dir
46+
- --model-path=$config_dir
47+
- --model-name=create_convnext
48+
- --import-module=model
49+
- --model-param=weights=r"$dl_dir/convnext_tiny_1k_224_ema.pth"
50+
- --input-shape=1,3,224,224
51+
- --input-names=image
52+
- --output-names=probs
53+
- --output-file=$conv_dir/convnext-tiny.onnx
54+
input_info:
55+
- name: image
56+
shape: [1, 3, 224, 224]
57+
layout: NCHW
58+
model_optimizer_args:
59+
- --input_model=$conv_dir/convnext-tiny.onnx
60+
- --mean_values=image[123.675,116.28,103.53]
61+
- --scale_values=image[58.395, 57.12, 57.375]
62+
- --reverse_input_channels
63+
- --output=probs
64+
framework: pytorch
65+
license: https://raw.githubusercontent.com/rwightman/pytorch-image-models/master/LICENSE

models/public/device_support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
| colorization-siggraph | YES | YES | YES |
1616
| colorization-v2 | YES | YES | YES |
1717
| common-sign-language-0001 | YES | YES | |
18+
| convnext-tiny | YES | | |
1819
| ctdet_coco_dlav0_512 | YES | YES | YES |
1920
| ctpn | YES | YES | YES |
2021
| deblurgan-v2 | YES | YES | YES |

models/public/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
omz_models_model_alexnet
4646
omz_models_model_anti_spoof_mn3
4747
omz_models_model_caffenet
48+
omz_models_model_convnext_tiny
4849
omz_models_model_densenet_121
4950
omz_models_model_densenet_121_tf
5051
omz_models_model_dla_34
@@ -337,6 +338,7 @@ You can download models and convert them into OpenVINO™ IR format (\*.xml + \*
337338
| AlexNet | Caffe\* | [alexnet](./alexnet/README.md) | 56.598%/79.812% | 1.5 | 60.965 |
338339
| AntiSpoofNet | PyTorch\* | [anti-spoof-mn3](./anti-spoof-mn3/README.md) | 3.81% | 0.15 | 3.02 |
339340
| CaffeNet | Caffe\* | [caffenet](./caffenet/README.md) | 56.714%/79.916% | 1.5 | 60.965 |
341+
| ConvNeXt Tiny | PyTorch\* | [convnext-tiny](./convnext-tiny/README.md) | 82.05%/95.86% | 8.9419 | 28.5892 |
340342
| DenseNet 121 | Caffe\*<br>TensorFlow\*| [densenet-121](./densenet-121/README.md)<br>[densenet-121-tf](./densenet-121-tf/README.md)| 74.42%/92.136%<br>74.46%/92.13%| 5.723~5.7287 | 7.971 |
341343
| DLA 34 | PyTorch\* | [dla-34](./dla-34/README.md) | 74.64%/92.06% | 6.1368 | 15.7344 |
342344
| EfficientNet B0 | TensorFlow\*<br>PyTorch\* | [efficientnet-b0](./efficientnet-b0/README.md)<br>[efficientnet-b0-pytorch](./efficientnet-b0-pytorch/README.md) | 75.70%/92.76%<br>77.70%/93.52% | 0.819 | 5.268 |

0 commit comments

Comments
 (0)