Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge from CTuning #975

Merged
merged 5 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cm-mlops/script/app-image-classification-onnx-py/_cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ deps:
- tags: get,dataset,imagenet,image-classification,original
- tags: get,dataset-aux,imagenet-aux,image-classification
- tags: get,ml-model,resnet50,_onnx,image-classification
names:
- ml-model

- tags: get,generic-python-lib,_onnxruntime
skip_if_env:
Expand Down
5 changes: 5 additions & 0 deletions cm-mlops/script/get-ml-model-resnet50/_cm.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
"CM_ML_MODEL_ONNX_OPSET": "8"
}
},
"huggingface_default": {
"env": {
"CM_PACKAGE_URL": "https://huggingface.co/ctuning/mlperf-inference-resnet50-onnx-fp32-imagenet2012-v1.0/resolve/main/resnet50_v1.onnx"
}
},
"onnx,opset-11": {
"env": {
"CM_PACKAGE_URL": "https://zenodo.org/record/4735647/files/resnet50_v1.onnx"
Expand Down
24 changes: 14 additions & 10 deletions docs/tutorials/modular-image-classification.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[ [Back to index](../README.md) ]

*This tutorial is also available in [Google Colab](https://colab.research.google.com/drive/1fPFw86BKOQ79U1-lksTkAtJHn3_jhP9o?usp=sharing).*

# Trying CM: modular image classification

This example demonstrates our unified, technology-agnostic and human-readable CM automation language
Expand All @@ -19,7 +21,7 @@ to install the MLCommons CM language on your platform.
## Prepare and run modular image classification via CM

Here is an example of a modular image classification assembled from
([portable and reusable CM scripts](https://github.com/mlcommons/ck/tree/master/cm-mlops/script)).
([portable and reusable CM scripts](https://github.com/mlcommons/ck/tree/master/cm-mlops/script))
using a [human-readable YAML file](https://github.com/mlcommons/ck/blob/master/cm-mlops/script/app-image-classification-onnx-py/_cm.yaml#L19).
CM scripts simply wrap native scripts, tools, and artifacts while making them findable, accessible, portabl, interoperable, and reusable
based on [FAIR principles](https://www.go-fair.org/fair-principles).
Expand All @@ -28,6 +30,8 @@ CM will read this YAML (or JSON) description, go through all dependencies to run
and attempt to automatically detect, download, install and build all related artifacts
and tools to adapt this example to any software and hardware.

We have tested this tutorial on various Linux distributions, MacOS and Windows.

Let's go through these steps manually to better understand how CM scripts work.

First you need to install an [MLCommons CM-MLOps repository](https://github.com/mlcommons/ck/tree/master/cm-mlops)
Expand Down Expand Up @@ -81,20 +85,20 @@ You can also force to install specific versions of ML artifacts and tools
using individual CM scripts to automatically plug them into the above ML application:

```bash
cm run script "detect os" --out=json
cm run script "get python" --version_min=3.9.1
cm run script "install python-venv" --name=my-virtual-env
cm run script "get ml-model resnet50 _onnx _fp32"
cm run script "get original imagenet dataset _2012-500"
cm run script "get generic-python-lib _onnxruntime" --version=1.12.0
cmr "detect os" --out=json
cmr "get sys-utils-cm" --quiet
cmr "get python" --version_min=3.9.1
cmr "install python-venv" --name=my-virtual-env
cmr "get ml-model resnet50 image-classification _onnx _fp32" --const.CM_PACKAGE_URL=https://huggingface.co/ctuning/mlperf-inference-resnet50-onnx-fp32-imagenet2012-v1.0/resolve/main/resnet50_v1.onnx
cmr "get original imagenet dataset _2012-500"
cmr "get generic-python-lib _onnxruntime" --version=1.12.0

cm show cache
cm show cache --tags=python
cm show cache --tags=ml-model

cm run script "python app image-classification onnx"
cm run script "python app image-classification onnx" --input=my-image.jpg

cmr "python app image-classification onnx"
cmr "python app image-classification onnx" --quiet --input=`cm find script app-image-classification-onnx-py,3d5e908e472b417e`/img/computer_mouse.jpg
```

CM scripts converts CLI flags into environment variables and generates some input files
Expand Down