From b182c1b205a648ee29ad45b8eff05f022d21c761 Mon Sep 17 00:00:00 2001 From: xuyixing <361046262@qq.com> Date: Thu, 16 Dec 2021 19:58:02 +0800 Subject: [PATCH 1/5] add fda-bnn.md --- .../noah-cvlab/gpu/1.3/fdabnn_cifar10.md | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md diff --git a/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md b/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md new file mode 100755 index 0000000..cffa9a7 --- /dev/null +++ b/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md @@ -0,0 +1,91 @@ +# FDA-BNN + +--- + +model-name: FDA-BNN + +backbone-name: FDA-BNN + +module-type: CV-classification + +fine-tunable: True + +input-shape: [32, 32, 3] + +model-version: 1.0 + +train-dataset: CIFAR-10 Dataset + +accuracy: 0.866 + +author: Noah's Ark Lab + +update-time: 2021-12-16 + +repo-link: https://gitee.com/mindspore/models/tree/master/research/cv/FDA-BNN + +user-id: Noah's Ark Lab + +used-for: inference + +train-backend: gpu + +infer-backend: gpu + +mindspore-version: 1.3 + +asset: + +- file-format: ckpt + + asset-link: https://download.mindspore.cn/model_zoo/research/cv/FDA_BNN/fdabnn.ckpt + + asset-sha256: 8c6c14514ebd75e7992400b2839b1135438736941408889698120a3e0be56101 + +license: Apache2.0 +summary: 1-bit ResNet-20 model trained by FDA-BNN for visual recognition + +--- + +## Introduction + +This MindSpore Hub model uses the implementation of FDA-BNN from the MindSpore model zoo on Gitee at models/tree/master/research/cv/FDA-BNN. + +## Usage + +```python +import mindspore_hub as mshub +import mindspore +from mindspore import context, Tensor, nn +from mindspore.train.model import Model +from mindspore.common import dtype as mstype +from mindspore.dataset.transforms import py_transforms +from PIL import Image +import cv2 + +context.set_context(mode=context.GRAPH_MODE, + device_target="GPU", + device_id=0) + +model = "mindspore/gpu/1.3/fdabnn_cifar10" +image_shape = mshub.get_desired_input_shape(model) + +image = Image.open('Cifar10/a.jpg') +transforms = py_transforms.ComposeOp([py_transforms.ToTensor()]) + +network = mshub.load(model) +network.set_train(False) +out = network(transforms(image)) +``` + +## Citation + +1. Yixing Xu, Kai Han, Chang Xu, Yehui Tang, Chunjing Xu, Yunhe Wang; Learning frequency domain approximation for binary neural networks[J]. arXiv preprint arXiv:2103.00841, 2021. + +## Disclaimer + +MindSpore ("we") do not own any ownership or intellectual property rights of the datasets, and the trained models are provided on an "as is" and "as available" basis. We make no representations or warranties of any kind of the datasets and trained models (collectively, “materials”) and will not be liable for any loss, damage, expense or cost arising from the materials. Please ensure that you have permission to use the dataset under the appropriate license for the dataset and in accordance with the terms of the relevant license agreement. The trained models provided are only for research and education purposes. + +To Dataset Owners: If you do not wish to have a dataset included in MindSpore, or wish to update it in any way, we will remove or update the content at your request. Please contact us through GitHub or Gitee. Your understanding and contributions to the community are greatly appreciated. + +MindSpore is available under the Apache 2.0 license, please see the LICENSE file. \ No newline at end of file -- Gitee From 9fe1839fd7bd6043138dbec8b26bb33499d37a6c Mon Sep 17 00:00:00 2001 From: yttdebaba2 <361046262@qq.com> Date: Mon, 20 Dec 2021 01:59:15 +0000 Subject: [PATCH 2/5] update mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md. --- mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md b/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md index cffa9a7..a1edcc6 100755 --- a/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md +++ b/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md @@ -14,7 +14,7 @@ input-shape: [32, 32, 3] model-version: 1.0 -train-dataset: CIFAR-10 Dataset +train-dataset: cifar10 accuracy: 0.866 @@ -70,7 +70,7 @@ context.set_context(mode=context.GRAPH_MODE, model = "mindspore/gpu/1.3/fdabnn_cifar10" image_shape = mshub.get_desired_input_shape(model) -image = Image.open('Cifar10/a.jpg') +image = Image.open('cifar10/a.jpg') transforms = py_transforms.ComposeOp([py_transforms.ToTensor()]) network = mshub.load(model) -- Gitee From a1a18bc0f86fed5f4d8f9f381caf52e2cd17779d Mon Sep 17 00:00:00 2001 From: yttdebaba2 <361046262@qq.com> Date: Mon, 20 Dec 2021 02:55:22 +0000 Subject: [PATCH 3/5] update mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md. --- .../noah-cvlab/gpu/1.3/fdabnn_cifar10.md | 91 ------------------- 1 file changed, 91 deletions(-) diff --git a/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md b/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md index a1edcc6..e69de29 100755 --- a/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md +++ b/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md @@ -1,91 +0,0 @@ -# FDA-BNN - ---- - -model-name: FDA-BNN - -backbone-name: FDA-BNN - -module-type: CV-classification - -fine-tunable: True - -input-shape: [32, 32, 3] - -model-version: 1.0 - -train-dataset: cifar10 - -accuracy: 0.866 - -author: Noah's Ark Lab - -update-time: 2021-12-16 - -repo-link: https://gitee.com/mindspore/models/tree/master/research/cv/FDA-BNN - -user-id: Noah's Ark Lab - -used-for: inference - -train-backend: gpu - -infer-backend: gpu - -mindspore-version: 1.3 - -asset: - -- file-format: ckpt - - asset-link: https://download.mindspore.cn/model_zoo/research/cv/FDA_BNN/fdabnn.ckpt - - asset-sha256: 8c6c14514ebd75e7992400b2839b1135438736941408889698120a3e0be56101 - -license: Apache2.0 -summary: 1-bit ResNet-20 model trained by FDA-BNN for visual recognition - ---- - -## Introduction - -This MindSpore Hub model uses the implementation of FDA-BNN from the MindSpore model zoo on Gitee at models/tree/master/research/cv/FDA-BNN. - -## Usage - -```python -import mindspore_hub as mshub -import mindspore -from mindspore import context, Tensor, nn -from mindspore.train.model import Model -from mindspore.common import dtype as mstype -from mindspore.dataset.transforms import py_transforms -from PIL import Image -import cv2 - -context.set_context(mode=context.GRAPH_MODE, - device_target="GPU", - device_id=0) - -model = "mindspore/gpu/1.3/fdabnn_cifar10" -image_shape = mshub.get_desired_input_shape(model) - -image = Image.open('cifar10/a.jpg') -transforms = py_transforms.ComposeOp([py_transforms.ToTensor()]) - -network = mshub.load(model) -network.set_train(False) -out = network(transforms(image)) -``` - -## Citation - -1. Yixing Xu, Kai Han, Chang Xu, Yehui Tang, Chunjing Xu, Yunhe Wang; Learning frequency domain approximation for binary neural networks[J]. arXiv preprint arXiv:2103.00841, 2021. - -## Disclaimer - -MindSpore ("we") do not own any ownership or intellectual property rights of the datasets, and the trained models are provided on an "as is" and "as available" basis. We make no representations or warranties of any kind of the datasets and trained models (collectively, “materials”) and will not be liable for any loss, damage, expense or cost arising from the materials. Please ensure that you have permission to use the dataset under the appropriate license for the dataset and in accordance with the terms of the relevant license agreement. The trained models provided are only for research and education purposes. - -To Dataset Owners: If you do not wish to have a dataset included in MindSpore, or wish to update it in any way, we will remove or update the content at your request. Please contact us through GitHub or Gitee. Your understanding and contributions to the community are greatly appreciated. - -MindSpore is available under the Apache 2.0 license, please see the LICENSE file. \ No newline at end of file -- Gitee From 9f7b3d0ed6fe6c59b07b408bb641fb9a93c484f1 Mon Sep 17 00:00:00 2001 From: yttdebaba2 <361046262@qq.com> Date: Mon, 20 Dec 2021 02:59:05 +0000 Subject: [PATCH 4/5] update mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md. --- .../noah-cvlab/gpu/1.3/fdabnn_cifar10.md | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md b/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md index e69de29..a1edcc6 100755 --- a/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md +++ b/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md @@ -0,0 +1,91 @@ +# FDA-BNN + +--- + +model-name: FDA-BNN + +backbone-name: FDA-BNN + +module-type: CV-classification + +fine-tunable: True + +input-shape: [32, 32, 3] + +model-version: 1.0 + +train-dataset: cifar10 + +accuracy: 0.866 + +author: Noah's Ark Lab + +update-time: 2021-12-16 + +repo-link: https://gitee.com/mindspore/models/tree/master/research/cv/FDA-BNN + +user-id: Noah's Ark Lab + +used-for: inference + +train-backend: gpu + +infer-backend: gpu + +mindspore-version: 1.3 + +asset: + +- file-format: ckpt + + asset-link: https://download.mindspore.cn/model_zoo/research/cv/FDA_BNN/fdabnn.ckpt + + asset-sha256: 8c6c14514ebd75e7992400b2839b1135438736941408889698120a3e0be56101 + +license: Apache2.0 +summary: 1-bit ResNet-20 model trained by FDA-BNN for visual recognition + +--- + +## Introduction + +This MindSpore Hub model uses the implementation of FDA-BNN from the MindSpore model zoo on Gitee at models/tree/master/research/cv/FDA-BNN. + +## Usage + +```python +import mindspore_hub as mshub +import mindspore +from mindspore import context, Tensor, nn +from mindspore.train.model import Model +from mindspore.common import dtype as mstype +from mindspore.dataset.transforms import py_transforms +from PIL import Image +import cv2 + +context.set_context(mode=context.GRAPH_MODE, + device_target="GPU", + device_id=0) + +model = "mindspore/gpu/1.3/fdabnn_cifar10" +image_shape = mshub.get_desired_input_shape(model) + +image = Image.open('cifar10/a.jpg') +transforms = py_transforms.ComposeOp([py_transforms.ToTensor()]) + +network = mshub.load(model) +network.set_train(False) +out = network(transforms(image)) +``` + +## Citation + +1. Yixing Xu, Kai Han, Chang Xu, Yehui Tang, Chunjing Xu, Yunhe Wang; Learning frequency domain approximation for binary neural networks[J]. arXiv preprint arXiv:2103.00841, 2021. + +## Disclaimer + +MindSpore ("we") do not own any ownership or intellectual property rights of the datasets, and the trained models are provided on an "as is" and "as available" basis. We make no representations or warranties of any kind of the datasets and trained models (collectively, “materials”) and will not be liable for any loss, damage, expense or cost arising from the materials. Please ensure that you have permission to use the dataset under the appropriate license for the dataset and in accordance with the terms of the relevant license agreement. The trained models provided are only for research and education purposes. + +To Dataset Owners: If you do not wish to have a dataset included in MindSpore, or wish to update it in any way, we will remove or update the content at your request. Please contact us through GitHub or Gitee. Your understanding and contributions to the community are greatly appreciated. + +MindSpore is available under the Apache 2.0 license, please see the LICENSE file. \ No newline at end of file -- Gitee From d57346ff7f8166e2b70f4ab35ecbbc0ab446a9bc Mon Sep 17 00:00:00 2001 From: yttdebaba2 <361046262@qq.com> Date: Mon, 20 Dec 2021 03:06:30 +0000 Subject: [PATCH 5/5] update mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md. --- .../noah-cvlab/gpu/1.3/fdabnn_cifar10.md | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md b/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md index a1edcc6..cb08668 100755 --- a/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md +++ b/mshub_res/assets/noah-cvlab/gpu/1.3/fdabnn_cifar10.md @@ -6,7 +6,7 @@ model-name: FDA-BNN backbone-name: FDA-BNN -module-type: CV-classification +module-type: cv-classification fine-tunable: True @@ -16,7 +16,7 @@ model-version: 1.0 train-dataset: cifar10 -accuracy: 0.866 +accuracy: 86.6 author: Noah's Ark Lab @@ -55,27 +55,16 @@ This MindSpore Hub model uses the implementation of FDA-BNN from the MindSpore m ```python import mindspore_hub as mshub -import mindspore -from mindspore import context, Tensor, nn -from mindspore.train.model import Model -from mindspore.common import dtype as mstype -from mindspore.dataset.transforms import py_transforms -from PIL import Image -import cv2 - -context.set_context(mode=context.GRAPH_MODE, +from mindspore import context +from src.args import args + +context.set_context(mode=context.PYNATIVE_MODE, device_target="GPU", device_id=0) model = "mindspore/gpu/1.3/fdabnn_cifar10" -image_shape = mshub.get_desired_input_shape(model) - -image = Image.open('cifar10/a.jpg') -transforms = py_transforms.ComposeOp([py_transforms.ToTensor()]) - -network = mshub.load(model) +network = mshub.load(model, args) network.set_train(False) -out = network(transforms(image)) ``` ## Citation -- Gitee