GithubHelp home page GithubHelp logo

iawang / k2arm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ines-hpmm/k2arm

0.0 0.0 0.0 66.19 MB

Contains the k2arm framework, results and slides from the presentation at Forum Künstliche Intelligenz

License: GNU General Public License v3.0

Shell 0.01% JavaScript 0.01% C++ 0.82% Python 0.09% C 94.13% Objective-C 0.55% Assembly 3.97% CSS 0.05% Makefile 0.02% HTML 0.27% CMake 0.04% Batchfile 0.05%

k2arm's Introduction

k2arm - Forum Künstliche Intelligenz

This repository contains the k2arm software framework, related code and the presentation from the "Forum Künstliche Intelligenz" talk in Stuttgart , 14.05.2019.

The k2arm software framework can be used to translate a custom keras model into C-code. The generated C-code can, in combination with the ARM-CMSIS-NN functions, be used to run neural-net calculations in an efficient way on an embedded microcontroller such as the Cortex-M4. Those generated networks are compared to networks which are generated with the x-Cube-AI tool from ST.

Three different sized MNIST classifiers are compared, the results are included in the presentation.

Requirements and Preparation

  1. Following additional software and versions is required:

    • ubnntu 18.04
    • python 3.6
    • tensorflow 1.10.0
    • keras version 2.2.4
    • STM32CubeMX
    • X-Cube-AI
    • arm-none-eabi-gcc 6.3.1
  2. Follwoing hardware is required:

  3. Checkout the repository

git clone https://github.com/InES-HPMM/k2arm.git
  1. Build stlink
cd k2arm/ST/stlink
make

Reproduce k2arm Measurements

  1. Switch into the ARM host directory and generate the C-code with the k2arm framework
cd ../../ARM/host/
python3 generateCMSISCode.py
  1. Switch into the target directory and build the firmware
cd ../target/
make
  1. Connect the STM32F4-Discovery board to your computer, and flash the firmware
sudo ../../ST/stlink/build/Release/st-flash --format ihex write ./build/k2arm.hex
  1. Switch into the top level dir
cd ../..
  1. Open the file eval.py and adjust the settings serDev and modelPath
serDev = '/dev/ttyUSB1'
modelPath = 'models/modelMid/model.keras'
  1. Connect the serial device
PA0-WKUP Board ------> TX Serial device host
PA1      Board ------> RX Serial device host
GND      Board ------> GND host
  1. Tun the evaluation script:
python3 eval.py
  1. To measure the run-time of the neural net connect the GPIO PIN0 of GPIOB to an oscilloscope

Reproduce X-Cube-AI Measurements

  1. Start STM32CubeMX
  2. In the section File chose the option to Load Project and select the file: ST/St.ioc
  3. In the section Additional Software chose the desired network in the network section, then press GENERATE CODE
  4. Go into the ST dir and checkout the wrong changed files (Makefile and application code)
cd ST/
git checkout  Src/main.c Src/app_x-cube-ai.c Inc/app_x-cube-ai.h Makefile
  1. Build the firmware
make
  1. Connect the STM32F4-Discovery board to your computer, and flash the firmware
sudo ./stlink/build/Release/st-flash --format ihex write ./build/ST.hex
  1. Switch into the top level dir
cd ..
  1. Open the file eval.py and adjust the settings
serDev = '/dev/ttyUSB1'
modelPath = 'models/modelL/model.keras'
  1. Connect the serial device
PA0-WKUP Board ------> TX Serial device host
PA1      Board ------> RX Serial device host
GND      Board ------> GND host
  1. Run the evaluation script
python3 eval.py
  1. To measure the run-time of the neural net connect the GPIO PIN0 of GPIOB to an oscilloscope

k2arm's People

Contributors

rarazac avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.