Skip to content

Commit

Permalink
Add class label scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-arm committed Apr 19, 2021
1 parent 0372021 commit f1952ac
Show file tree
Hide file tree
Showing 39 changed files with 630 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ MobileNet v2 is an efficient image classification neural network, targeted for m
## License
[Apache-2.0](https://spdx.org/licenses/Apache-2.0.html)

## Related Materials
### Class Labels
The class labels associated with this model can be downloaded by running the script `get_class_labels.sh`.

## Network Information
| Network Information | Value |
|---------------------|------------------|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (C) 2021 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env bash

wget https://gist.githubusercontent.com/yrevar/942d3a0ac09ec9e5eb3a/raw/238f720ff059c1f82f368259d1ca4ffa5dd8f9f5/imagenet1000_clsidx_to_labels.txt
python scripts/process_labels.py --path imagenet1000_clsidx_to_labels.txt

rm imagenet1000_clsidx_to_labels.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (C) 2021 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import ast

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Process ImageNet labels.")
parser.add_argument("--path", type=str, required=True)

args = parser.parse_args()

with open(args.path, "r") as f:
data = f.read()

labels = ast.literal_eval(data)

# Include the background class as there are 1001 classes
class_labels = ["background"]

for _, l in labels.items():
class_labels.append(l)

with open("labelmappings.txt", "w") as f:
for l in class_labels:
f.write("{}\n".format(l))
7 changes: 7 additions & 0 deletions models/keyword_spotting/cnn_large/tflite_int8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ This is a fully quantized version (asymmetrical int8) of the CNN Large model dev
## License
[Apache-2.0](https://spdx.org/licenses/Apache-2.0.html)

## Related Materials
### Class Labels
The class labels associated with this model can be downloaded by running the script `get_class_labels.sh`.

### Model Recreation Code
Code to recreate this model can be found here: https://github.com/ARM-software/ML-examples/tree/master/tflu-kws-cortex-m.

## Network Information
| Network Information | Value |
|---------------------|------------------|
Expand Down
20 changes: 20 additions & 0 deletions models/keyword_spotting/cnn_large/tflite_int8/get_class_labels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2021 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env bash

wget https://raw.githubusercontent.com/ARM-software/ML-KWS-for-MCU/e9cf319e9aa2ff71d433e111477dd95329fb94cb/Pretrained_models/labels.txt
mv labels.txt labelmappings.txt
7 changes: 7 additions & 0 deletions models/keyword_spotting/cnn_medium/tflite_int8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ This is a fully quantized version (asymmetrical int8) of the CNN Medium model de
## License
[Apache-2.0](https://spdx.org/licenses/Apache-2.0.html)

## Related Materials
### Class Labels
The class labels associated with this model can be downloaded by running the script `get_class_labels.sh`.

### Model Recreation Code
Code to recreate this model can be found here: https://github.com/ARM-software/ML-examples/tree/master/tflu-kws-cortex-m.

## Network Information
| Network Information | Value |
|---------------------|------------------|
Expand Down
20 changes: 20 additions & 0 deletions models/keyword_spotting/cnn_medium/tflite_int8/get_class_labels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2021 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env bash

wget https://raw.githubusercontent.com/ARM-software/ML-KWS-for-MCU/e9cf319e9aa2ff71d433e111477dd95329fb94cb/Pretrained_models/labels.txt
mv labels.txt labelmappings.txt
7 changes: 7 additions & 0 deletions models/keyword_spotting/cnn_small/tflite_int8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ This is a fully quantized version (asymmetrical int8) of the CNN Small model dev
## License
[Apache-2.0](https://spdx.org/licenses/Apache-2.0.html)

## Related Materials
### Class Labels
The class labels associated with this model can be downloaded by running the script `get_class_labels.sh`.

### Model Recreation Code
Code to recreate this model can be found here: https://github.com/ARM-software/ML-examples/tree/master/tflu-kws-cortex-m.

## Network Information
| Network Information | Value |
|---------------------|------------------|
Expand Down
20 changes: 20 additions & 0 deletions models/keyword_spotting/cnn_small/tflite_int8/get_class_labels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2021 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env bash

wget https://raw.githubusercontent.com/ARM-software/ML-KWS-for-MCU/e9cf319e9aa2ff71d433e111477dd95329fb94cb/Pretrained_models/labels.txt
mv labels.txt labelmappings.txt
7 changes: 7 additions & 0 deletions models/keyword_spotting/dnn_large/tflite_int8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ This is a fully quantized version (asymmetrical int8) of the DNN Large model dev
## License
[Apache-2.0](https://spdx.org/licenses/Apache-2.0.html)

## Related Materials
### Class Labels
The class labels associated with this model can be downloaded by running the script `get_class_labels.sh`.

### Model Recreation Code
Code to recreate this model can be found here: https://github.com/ARM-software/ML-examples/tree/master/tflu-kws-cortex-m.

## Network Information
| Network Information | Value |
|---------------------|------------------|
Expand Down
20 changes: 20 additions & 0 deletions models/keyword_spotting/dnn_large/tflite_int8/get_class_labels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2021 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env bash

wget https://raw.githubusercontent.com/ARM-software/ML-KWS-for-MCU/e9cf319e9aa2ff71d433e111477dd95329fb94cb/Pretrained_models/labels.txt
mv labels.txt labelmappings.txt
7 changes: 7 additions & 0 deletions models/keyword_spotting/dnn_medium/tflite_int8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ This is a fully quantized version (asymmetrical int8) of the DNN Medium model de
## License
[Apache-2.0](https://spdx.org/licenses/Apache-2.0.html)

## Related Materials
### Class Labels
The class labels associated with this model can be downloaded by running the script `get_class_labels.sh`.

### Model Recreation Code
Code to recreate this model can be found here: https://github.com/ARM-software/ML-examples/tree/master/tflu-kws-cortex-m.

## Network Information
| Network Information | Value |
|---------------------|------------------|
Expand Down
20 changes: 20 additions & 0 deletions models/keyword_spotting/dnn_medium/tflite_int8/get_class_labels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2021 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env bash

wget https://raw.githubusercontent.com/ARM-software/ML-KWS-for-MCU/e9cf319e9aa2ff71d433e111477dd95329fb94cb/Pretrained_models/labels.txt
mv labels.txt labelmappings.txt
7 changes: 7 additions & 0 deletions models/keyword_spotting/dnn_small/tflite_int8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ This is a fully quantized version (asymmetrical int8) of the DNN Small model dev
## License
[Apache-2.0](https://spdx.org/licenses/Apache-2.0.html)

## Related Materials
### Class Labels
The class labels associated with this model can be downloaded by running the script `get_class_labels.sh`.

### Model Recreation Code
Code to recreate this model can be found here: https://github.com/ARM-software/ML-examples/tree/master/tflu-kws-cortex-m.

## Network Information
| Network Information | Value |
|---------------------|------------------|
Expand Down
20 changes: 20 additions & 0 deletions models/keyword_spotting/dnn_small/tflite_int8/get_class_labels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2021 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env bash

wget https://raw.githubusercontent.com/ARM-software/ML-KWS-for-MCU/e9cf319e9aa2ff71d433e111477dd95329fb94cb/Pretrained_models/labels.txt
mv labels.txt labelmappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This is a clustered (32 clusters, kmeans++ centroid initialization) and retraine
## License
[Apache-2.0](https://spdx.org/licenses/Apache-2.0.html)

## Related Materials
### Class Labels
The class labels associated with this model can be downloaded by running the script `get_class_labels.sh`.

## Network Information
| Network Information | Value |
|---------------------|------------------|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2021 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env bash

wget https://raw.githubusercontent.com/ARM-software/ML-KWS-for-MCU/e9cf319e9aa2ff71d433e111477dd95329fb94cb/Pretrained_models/labels.txt
mv labels.txt labelmappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ The original model was converted to Keras, optimized using the Clustering API in
## License
[Apache-2.0](https://spdx.org/licenses/Apache-2.0.html)

## Related Materials
### Class Labels
The class labels associated with this model can be downloaded by running the script `get_class_labels.sh`.

## Network Information
| Network Information | Value |
|---------------------|------------------|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2021 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env bash

wget https://raw.githubusercontent.com/ARM-software/ML-KWS-for-MCU/e9cf319e9aa2ff71d433e111477dd95329fb94cb/Pretrained_models/labels.txt
mv labels.txt labelmappings.txt
7 changes: 7 additions & 0 deletions models/keyword_spotting/ds_cnn_large/tflite_int8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ This is a fully quantized version (asymmetrical int8) of the DS-CNN Large model
## License
[Apache-2.0](https://spdx.org/licenses/Apache-2.0.html)

## Related Materials
### Class Labels
The class labels associated with this model can be downloaded by running the script `get_class_labels.sh`.

### Model Recreation Code
Code to recreate this model can be found here: https://github.com/ARM-software/ML-examples/tree/master/tflu-kws-cortex-m.

## Network Information
| Network Information | Value |
|---------------------|------------------|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2021 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the License); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env bash

wget https://raw.githubusercontent.com/ARM-software/ML-KWS-for-MCU/e9cf319e9aa2ff71d433e111477dd95329fb94cb/Pretrained_models/labels.txt
mv labels.txt labelmappings.txt
Loading

0 comments on commit f1952ac

Please sign in to comment.