GithubHelp home page GithubHelp logo

noahzhy / pico_ai Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 248 KB

Project collection for Raspberry Pi Pico with TensorFlow Micro.

CMake 1.15% C 97.55% C++ 1.13% Python 0.17%
raspberry-pi-pico tflite-micro

pico_ai's Introduction

Pico AI

Introduction

This is a project collection for Raspberry Pi Pico with TensorFlow Micro.

Requirements

SDK

Download the SDK from here.

Or use bash commands to download the SDK:

git clone https://github.com/raspberrypi/pico-sdk.git
cd pico-sdk
git submodule update --init

Set PICO_SDK_PATH environment variable to the path of the SDK.

export PICO_SDK_PATH=/path/to/pico-sdk

Check environment variable:

echo $PICO_SDK_PATH

Environment

Make sure you have the following tools installed:

  • Brew

Download and install Brew from here.

Then use Shell commands to install the environment:

brew install cmake
brew install flatbuffers
brew tap ArmMbed/homebrew-formulae
brew uninstall --force arm-none-eabi-gcc
brew uninstall --force arm-none-eabi-binutils
brew install gcc-arm-embedded

Start with TF-micro on Pico

Demo

Choose a demo which you are interested in from the folder first. Then follow the instructions to Build the demo.

Now you can find the demo.uf2 file in the build folder. Flash it to your Pico board.

Run your own model

Prepare your own model first. And make sure it is a TFLite model. Then use the following command to convert it to a C array.

echo "alignas(8) const unsigned char tflite_model[] = {" > tflite_model.h
cat tflite_model.tflite | xxd -i >> tflite_model.h
echo "};" >> tflite_model.h

Copy the pico-sdk cmake file to your project folder.

cp $PICO_SDK_PATH/external/pico_sdk_import.cmake .

Download the pico-tflmicro library from here. Or use the following command to download it.

cd your_project_folder
mkdir lib
cd lib
git clone https://github.com/raspberrypi/pico-tflmicro.git

Then create a CMakeLists.txt file in your project folder. And add the following content to it.

cmake_minimum_required(VERSION 3.13)

include(pico_sdk_import.cmake)
project(demo C CXX ASM)
pico_sdk_init()

set(ARM_CPU "cortex-m0plus")
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)

add_executable(demo
  # Add your source files here.
  ${CMAKE_CURRENT_LIST_DIR}/src/main.cpp
)

target_link_libraries(demo
    pico_stdlib
    pico-tflmicro
)

# Uncomment if you want to flash your board via picotool.
# pico_enable_stdio_usb(demo 1)
pico_add_extra_outputs(demo)

add_subdirectory("lib/pico-tflmicro" EXCLUDE_FROM_ALL)

Make sure the folder structure is like this:

-- your_project_folder
    |-- build
    |-- CMakeLists.txt
    |-- pico_sdk_import.cmake
    |-- lib
        |-- pico-tflmicro
    |-- src
        |-- main.c
        ...

Now you can Build your project. Then you can find the .uf2 file in the build folder. Flash it to your Pico board. Enjoy it!

Build

cd demo
mkdir build
cd build
cmake .. -DPICO_BOARD=pico
make -j4

Flash

For Raspberry Pi Pico

  1. Plug the USB Micro cable into your PC, but do NOT plug in the Pico side.
  2. While holding down the white BOOTSEL button, plug in the micro USB cable to the Pico.

pico_ai's People

Contributors

noahzhy avatar

Stargazers

 avatar

Watchers

 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.