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

Add updated environment setup instructions for Raspberry Pi OS Bookworm compatibility #483

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
67 changes: 67 additions & 0 deletions lite/examples/audio_classification/raspberry_pi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,73 @@ with Raspberry Pi OS (preferably updated to Buster).
Raspberry Pi doesn't have a microphone integrated on its board, so you need to
plug in a USB microphone to record audio.


## Setup Environment

To ensure the TensorFlow Lite examples run smoothly on Raspberry Pi OS based on Debian Bookworm (2024 release), setting up a Python virtual environment is crucial. This setup guarantees compatibility with Python 3.9 and effectively manages the dependencies for your examples.

### Install Python 3.9.0

Follow these steps to install Python from source:

1. **Install Build Dependencies**: Begin by updating your system and installing the required packages:
```bash
sudo apt update
sudo apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
```

2. **Compile and Install Python**: Download, extract, and install Python:
```bash
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
tar xf Python-3.9.0.tar.xz
cd Python-3.9.0
./configure --enable-optimizations --prefix=/usr
make -j $(nproc)
sudo make altinstall
```

3. **Verify Python Installation**: Ensure Python 3.9.0 is installed successfully:
```bash
python3.9 --version
```

4. **Change Directory**: Move out of the Python source directory:
```bash
cd ..
```

### Optional: Cleanup After Installation

To optimize disk space after the Python installation:

1. **Remove Python Source Files**: Next, use `sudo` to remove the downloaded archive and the extracted Python source directory:
```bash
sudo rm -rf Python-3.9.0.tar.xz Python-3.9.0
```

2. **Remove Build Dependencies**: Optionally, uninstall the build dependencies if they are no longer necessary:
```bash
sudo apt remove --purge -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
sudo apt autoremove -y
```

### Virtual Environment Setup

Prepare and activate a virtual environment for the TensorFlow Lite examples:

1. **Create the Environment**:
```bash
python3.9 -m venv /usr/local/venvs/tflite
```

2. **Activate the Environment**: Always reactivate the virtual environment in new sessions:
```bash
source /usr/local/venvs/tflite/bin/activate
```

**Note**: Remember to reactivate the `tflite` environment with `/usr/local/venvs/tflite/bin/activate` each time you work on the TensorFlow Lite examples.


## Install the TensorFlow Lite runtime

In this project, all you need from the TensorFlow Lite API is the `Interpreter`
Expand Down
66 changes: 66 additions & 0 deletions lite/examples/image_classification/raspberry_pi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,72 @@ to the Raspberry Pi. It's okay if you're using SSH to access the Pi shell
attached to the Pi to see the camera stream.


## Setup Environment

To ensure the TensorFlow Lite examples run smoothly on Raspberry Pi OS based on Debian Bookworm (2024 release), setting up a Python virtual environment is crucial. This setup guarantees compatibility with Python 3.9 and effectively manages the dependencies for your examples.

### Install Python 3.9.0

Follow these steps to install Python from source:

1. **Install Build Dependencies**: Begin by updating your system and installing the required packages:
```bash
sudo apt update
sudo apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
```

2. **Compile and Install Python**: Download, extract, and install Python:
```bash
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
tar xf Python-3.9.0.tar.xz
cd Python-3.9.0
./configure --enable-optimizations --prefix=/usr
make -j $(nproc)
sudo make altinstall
```

3. **Verify Python Installation**: Ensure Python 3.9.0 is installed successfully:
```bash
python3.9 --version
```

4. **Change Directory**: Move out of the Python source directory:
```bash
cd ..
```

### Optional: Cleanup After Installation

To optimize disk space after the Python installation:

1. **Remove Python Source Files**: Next, use `sudo` to remove the downloaded archive and the extracted Python source directory:
```bash
sudo rm -rf Python-3.9.0.tar.xz Python-3.9.0
```

2. **Remove Build Dependencies**: Optionally, uninstall the build dependencies if they are no longer necessary:
```bash
sudo apt remove --purge -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
sudo apt autoremove -y
```

### Virtual Environment Setup

Prepare and activate a virtual environment for the TensorFlow Lite examples:

1. **Create the Environment**:
```bash
python3.9 -m venv /usr/local/venvs/tflite
```

2. **Activate the Environment**: Always reactivate the virtual environment in new sessions:
```bash
source /usr/local/venvs/tflite/bin/activate
```

**Note**: Remember to reactivate the `tflite` environment with `/usr/local/venvs/tflite/bin/activate` each time you work on the TensorFlow Lite examples.


## Install the TensorFlow Lite runtime

In this project, all you need from the TensorFlow Lite API is the `Interpreter`
Expand Down
67 changes: 67 additions & 0 deletions lite/examples/image_segmentation/raspberry_pi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,73 @@ Raspberry Pi. It's okay if you're using SSH to access the Pi shell (you don't
need to use a keyboard connected to the Pi)—you only need a monitor attached to
the Pi to see the camera stream.


## Setup Environment

To ensure the TensorFlow Lite examples run smoothly on Raspberry Pi OS based on Debian Bookworm (2024 release), setting up a Python virtual environment is crucial. This setup guarantees compatibility with Python 3.9 and effectively manages the dependencies for your examples.

### Install Python 3.9.0

Follow these steps to install Python from source:

1. **Install Build Dependencies**: Begin by updating your system and installing the required packages:
```bash
sudo apt update
sudo apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
```

2. **Compile and Install Python**: Download, extract, and install Python:
```bash
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
tar xf Python-3.9.0.tar.xz
cd Python-3.9.0
./configure --enable-optimizations --prefix=/usr
make -j $(nproc)
sudo make altinstall
```

3. **Verify Python Installation**: Ensure Python 3.9.0 is installed successfully:
```bash
python3.9 --version
```

4. **Change Directory**: Move out of the Python source directory:
```bash
cd ..
```

### Optional: Cleanup After Installation

To optimize disk space after the Python installation:

1. **Remove Python Source Files**: Next, use `sudo` to remove the downloaded archive and the extracted Python source directory:
```bash
sudo rm -rf Python-3.9.0.tar.xz Python-3.9.0
```

2. **Remove Build Dependencies**: Optionally, uninstall the build dependencies if they are no longer necessary:
```bash
sudo apt remove --purge -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
sudo apt autoremove -y
```

### Virtual Environment Setup

Prepare and activate a virtual environment for the TensorFlow Lite examples:

1. **Create the Environment**:
```bash
python3.9 -m venv /usr/local/venvs/tflite
```

2. **Activate the Environment**: Always reactivate the virtual environment in new sessions:
```bash
source /usr/local/venvs/tflite/bin/activate
```

**Note**: Remember to reactivate the `tflite` environment with `/usr/local/venvs/tflite/bin/activate` each time you work on the TensorFlow Lite examples.


## Install the TensorFlow Lite runtime

In this project, all you need from the TensorFlow Lite API is the `Interpreter`
Expand Down
67 changes: 67 additions & 0 deletions lite/examples/object_detection/raspberry_pi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,73 @@ Raspberry Pi. It's okay if you're using SSH to access the Pi shell (you don't
need to use a keyboard connected to the Pi)—you only need a monitor attached to
the Pi to see the camera stream.


## Setup Environment

To ensure the TensorFlow Lite examples run smoothly on Raspberry Pi OS based on Debian Bookworm (2024 release), setting up a Python virtual environment is crucial. This setup guarantees compatibility with Python 3.9 and effectively manages the dependencies for your examples.

### Install Python 3.9.0

Follow these steps to install Python from source:

1. **Install Build Dependencies**: Begin by updating your system and installing the required packages:
```bash
sudo apt update
sudo apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
```

2. **Compile and Install Python**: Download, extract, and install Python:
```bash
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
tar xf Python-3.9.0.tar.xz
cd Python-3.9.0
./configure --enable-optimizations --prefix=/usr
make -j $(nproc)
sudo make altinstall
```

3. **Verify Python Installation**: Ensure Python 3.9.0 is installed successfully:
```bash
python3.9 --version
```

4. **Change Directory**: Move out of the Python source directory:
```bash
cd ..
```

### Optional: Cleanup After Installation

To optimize disk space after the Python installation:

1. **Remove Python Source Files**: Next, use `sudo` to remove the downloaded archive and the extracted Python source directory:
```bash
sudo rm -rf Python-3.9.0.tar.xz Python-3.9.0
```

2. **Remove Build Dependencies**: Optionally, uninstall the build dependencies if they are no longer necessary:
```bash
sudo apt remove --purge -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
sudo apt autoremove -y
```

### Virtual Environment Setup

Prepare and activate a virtual environment for the TensorFlow Lite examples:

1. **Create the Environment**:
```bash
python3.9 -m venv /usr/local/venvs/tflite
```

2. **Activate the Environment**: Always reactivate the virtual environment in new sessions:
```bash
source /usr/local/venvs/tflite/bin/activate
```

**Note**: Remember to reactivate the `tflite` environment with `/usr/local/venvs/tflite/bin/activate` each time you work on the TensorFlow Lite examples.


## Download the example files

First, clone this Git repo onto your Raspberry Pi like this:
Expand Down
67 changes: 67 additions & 0 deletions lite/examples/pose_estimation/raspberry_pi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,73 @@ This sample can run on Raspberry Pi or any computer that has a camera. It uses
OpenCV to capture images from the camera and TensorFlow Lite to run inference on
the input image.


## Setup Environment

To ensure the TensorFlow Lite examples run smoothly on Raspberry Pi OS based on Debian Bookworm (2024 release), setting up a Python virtual environment is crucial. This setup guarantees compatibility with Python 3.9 and effectively manages the dependencies for your examples.

### Install Python 3.9.0

Follow these steps to install Python from source:

1. **Install Build Dependencies**: Begin by updating your system and installing the required packages:
```bash
sudo apt update
sudo apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
```

2. **Compile and Install Python**: Download, extract, and install Python:
```bash
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
tar xf Python-3.9.0.tar.xz
cd Python-3.9.0
./configure --enable-optimizations --prefix=/usr
make -j $(nproc)
sudo make altinstall
```

3. **Verify Python Installation**: Ensure Python 3.9.0 is installed successfully:
```bash
python3.9 --version
```

4. **Change Directory**: Move out of the Python source directory:
```bash
cd ..
```

### Optional: Cleanup After Installation

To optimize disk space after the Python installation:

1. **Remove Python Source Files**: Next, use `sudo` to remove the downloaded archive and the extracted Python source directory:
```bash
sudo rm -rf Python-3.9.0.tar.xz Python-3.9.0
```

2. **Remove Build Dependencies**: Optionally, uninstall the build dependencies if they are no longer necessary:
```bash
sudo apt remove --purge -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
sudo apt autoremove -y
```

### Virtual Environment Setup

Prepare and activate a virtual environment for the TensorFlow Lite examples:

1. **Create the Environment**:
```bash
python3.9 -m venv /usr/local/venvs/tflite
```

2. **Activate the Environment**: Always reactivate the virtual environment in new sessions:
```bash
source /usr/local/venvs/tflite/bin/activate
```

**Note**: Remember to reactivate the `tflite` environment with `/usr/local/venvs/tflite/bin/activate` each time you work on the TensorFlow Lite examples.


## Install the dependencies

* Run this script to install the Python dependencies, and download the TFLite
Expand Down
Loading