@@ -17,9 +17,11 @@ Builds on [emlearn](https://emlearn.org), a C99 library for Machine Learning on
1717## Status
1818** Minimally useful**
1919
20- - Tested * working* on ` x64 ` (Unix port) and ` xtensawin ` (ESP32/ESP32-S3/etc).
21- - Currently not supported: [ armv6m/Cortex-M0/RP2040] ( https://github.com/emlearn/emlearn-micropython/issues/19 )
22- and [ RISC-V/ESP32-C3/ESP32-C6] ( https://github.com/emlearn/emlearn-micropython/issues/35 )
20+ - Initial set of Machine Learning and Digital Signal Processing modules available, including example projects.
21+ - Supports most MicroPython ports using runtime installable native modules
22+ - Primarily tested on ` x64 ` (Unix port) and ` xtensawin ` (ESP32/ESP32-S3/etc).
23+ - Some devices only supported using external, notably armv6m/Cortex-M0/RP2040
24+ - Not yet supported: [ RISC-V/ESP32-C3/ESP32-C6] ( https://github.com/emlearn/emlearn-micropython/issues/35 )
2325
2426## Features
2527
@@ -35,7 +37,7 @@ and [RISC-V/ESP32-C3/ESP32-C6](https://github.com/emlearn/emlearn-micropython/is
3537- Operates on standard ` array.array ` data structures
3638- Models can be loaded at runtime from a file in disk/flash
3739- Highly efficient. Inference times down to 100 microseconds, RAM usage <2 kB, FLASH usage <2 kB
38- - Pre-built binaries available for most architectures.
40+ - Pre-built native modules available for most common architectures ` xtensawin ` .
3941
4042## Examples
4143
@@ -46,109 +48,36 @@ and [RISC-V/ESP32-C3/ESP32-C6](https://github.com/emlearn/emlearn-micropython/is
4648
4749## Documentation
4850
49- Complete [ documentation on ReadTheDocs] ( https://emlearn-micropython.readthedocs.io/en/latest/user_guide.html ) .
51+ Complete usage [ documentation on ReadTheDocs] ( https://emlearn-micropython.readthedocs.io/en/latest/user_guide.html ) .
5052
51- ## Prerequisites
5253
53- Minimally you will need
54-
55- - Python 3.10+ on host
56- - MicroPython 1.24+ running onto your device
54+ ## Citations
5755
58- #### Download repository
56+ If you use ` emlearn-micropython ` in an academic work, please reference it using:
5957
60- Download the repository with examples etc
61- ```
62- git clone https://github.com/emlearn/emlearn-micropython
58+ ``` tex
59+ @misc{emlearn_micropython,
60+ author = {Jon Nordby},
61+ title = {{emlearn-micropython: Efficient Machine Learning engine for MicroPython}},
62+ month = aug,
63+ year = 2023,
64+ doi = {10.5281/zenodo.8212731},
65+ url = {https://doi.org/10.5281/zenodo.8212731}
66+ }
6367```
6468
65- ## Usage
66-
67- Start with the instructions in [ XOR example] ( ./examples/xor_trees/ ) .
68-
69-
70- ## Supported versions
71-
72- At any given point in time, emlearn-micropython only provides pre-built binaries for one MicroPython version.
73- In general we strongly encourage people to use the latest version.
74- There are no long-term-support or bugfix versions, at this point.
75- If you build from source, the current version of emlearn-micropython might also work on a couple of MicroPython versions around the time, but this is not guaranteed.
76-
77- | MicroPython | emlearn-micropython |
78- | ------------------| ------------------ |
79- | 1.24.x | master |
80- | 1.24.x | 0.7.0 |
81- | 1.23.x | 0.6.0 |
82-
83- #### Find architecture and .mpy version
84-
85- The correct .mpy files to use depend on the CPU architecture of your microcontroller,
86- as well as the MicroPython version.
87-
88- | MicroPython version | .mpy version |
89- | ---------------------| ------------- |
90- | 1.23.x | 6.3 |
91- | 1.24.x | 6.3 |
92-
93-
94- Identify which CPU architecture your device uses.
95- You need to specify ` ARCH ` to install the correct module version.
96-
97- | ARCH | Description | Examples |
98- | ---------------| -----------------------------------| ---------------------- |
99- | x64 | x86 64 bit | PC |
100- | x86 | x86 32 bit | |
101- | armv6m | ARM Thumb (1) | Cortex-M0 |
102- | armv7m | ARM Thumb 2 | Cortex-M3 |
103- | armv7emsp | ARM Thumb 2, single float | Cortex-M4F, Cortex-M7 |
104- | armv7emdp | ARM Thumb 2, double floats | Cortex-M7 |
105- | xtensa | non-windowed | ESP8266 |
106- | xtensawin | windowed with window size 8 | ESP32 |
107-
108- Information is also available in the official documentation:
109- [ MicroPython: .mpy files] ( https://docs.micropython.org/en/latest/reference/mpyfiles.html#versioning-and-compatibility-of-mpy-files )
11069
11170
112- ## More learning resources
71+ ## Developing
11372
114- emlearn-micropython and emlearn has been covered in the following presentations .
73+ For those that wish to hack on emlearn-micropython itself .
11574
116- - Microcontrollers + Machine Learning in 1-2-3 (PyData Global 2024).
117- [ Slides etc] ( https://github.com/jonnor/embeddedml/tree/master/presentations/PyDataGlobal2024 )
118- - Sensor data processing on microcontrollers with MicroPython and emlearn (PyConZA 2024).
119- [ Slides etc] ( https://github.com/jonnor/embeddedml/tree/master/presentations/PyConZA2024 )
120- - 6 years of open source TinyML with emlearn - a scikit-learn for microcontrollers (TinyML EMEA 2024)
121- [ YouTube video] ( https://www.youtube.com/watch?v=oG7PjPMA3Is ) |
122- [ Slides etc] ( https://github.com/jonnor/embeddedml/tree/master/presentations/TinymlEMEA2024 )
123- - emlearn - Machine Learning for Tiny Embedded Systems (Embedded Online Conference 2024).
124- [ Youtube video] ( https://www.youtube.com/watch?v=qamVWmcBdmI ) |
125- [ Slides etc] ( https://github.com/jonnor/embeddedml/tree/master/presentations/EmbeddedOnlineConference2024 )
126- - Machine Learning on microcontrollers using MicroPython and emlearn (PyCon DE & PyData Berlin 2024).
127- [ Slides etc] ( https://github.com/jonnor/embeddedml/tree/master/presentations/PyDataBerlin2024 ) |
128- [ YouTube video] ( https://www.youtube.com/watch?v=_MGm8sctqjg&t=1311s&pp=ygUSZW1sZWFybiBtaWNyb3B5dGhv ) .
75+ #### Download the code
12976
130- Here is an overview of resources for [ TinyML in general] ( https://tinyml.seas.harvard.edu/courses/ ) .
131-
132- ## Benchmarks
133-
134- #### UCI handwriting digits
135-
136- UCI ML hand-written digits datasets dataset from
137- [ sklearn.datasets.load_digits] ( https://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_digits.html ) .
138- 8x8 image, 64 features. Values are 4-bit integers (16 levels). 10 classes.
139-
140- Running with a very simple RandomForest, 7 trees.
141- Reaches approx 86% accuracy.
142- Tested on Raspberry PI Pico, with RP2040 microcontroller (ARM Cortex M0 @ 133 MHz).
143-
144- ![ Inferences per second] ( ./benchmarks/digits_bench.png )
145-
146- NOTE: over half of the time for emlearn case,
147- is spent on converting the Python lists of integers into a float array.
148- Removing that bottleneck would speed up things considerably.
149-
150-
151- ## Developing locally
77+ Clone the repository using git
78+ ```
79+ git clone https://github.com/emlearn/emlearn-micropython
80+ ```
15281
15382#### Prerequisites
15483These come in addition to the prequisites described above.
@@ -159,13 +88,13 @@ See [MicroPython: Building native modules](https://docs.micropython.org/en/lates
15988We assume that micropython is installed in the same place as this repository.
16089If using another location, adjust ` MPY_DIR ` accordingly.
16190
162- You should be using MicroPython 1.24 (or newer).
91+ You should be using MicroPython 1.25 (or newer).
16392
16493#### Build
16594
16695Build the .mpy native module
16796```
168- make dist ARCH=armv6m MPY_DIR=../micropython
97+ make dist ARCH=xtensawin MPY_DIR=../micropython
16998```
17099
171100Install it on device
@@ -180,18 +109,4 @@ To build and run tests on host
180109make check
181110```
182111
183- ## Citations
184-
185- If you use ` emlearn-micropython ` in an academic work, please reference it using:
186-
187- ``` tex
188- @misc{emlearn_micropython,
189- author = {Jon Nordby},
190- title = {{emlearn-micropython: Efficient Machine Learning engine for MicroPython}},
191- month = aug,
192- year = 2023,
193- doi = {10.5281/zenodo.8212731},
194- url = {https://doi.org/10.5281/zenodo.8212731}
195- }
196- ```
197112
0 commit comments