> ## Documentation Index
> Fetch the complete documentation index at: https://docs.t3gemstone.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Edge-AI TensorLab

> Image Processing Model Compilation Kit

In this section, the [edgeai-tensorlab](https://github.com/t3gemstone/edgeai-tensorlab.git) project will be downloaded to the developer's computer, and the tools that can be used on the development board will be installed.

<Tip>
  By the end of this section, you will have experience in the following topics.

  * Experiencing the basic usage of edgeai-tensorlab components
  * Performing data labeling and model compilations with edgeai-tensorlab
</Tip>

<Steps>
  <Step title="Download edgeai-tensorlab">
    Download the edgeai-tensorlab project by performing `git clone` on Ubuntu
  </Step>

  <Step title="Install Requirements">
    Install the requirements to perform the compilation process by running the script named `setup.sh`
  </Step>

  <Step title="Complete Library Installations">
    Complete the installation of the tools inside edgeai-tensorlab to prepare the system
  </Step>
</Steps>

# 1. Preparation

Compilation operations were performed with a computer containing the Ubuntu 22.04 GNU/Linux distribution. While it is possible to use distributions such as Debian, Fedora, Pardus, Ubuntu 22 or Ubuntu 24 will be more suitable for those using such compilation tools for the first time.

### 1.1. Computer Requirements

1. Ubuntu 22 or Ubuntu 24 computer
2. At least 8GB RAM
3. At least 10GB of available free disk space

The Gemstone SDK requires tools like `Docker` and `Devbox`. After cloning the SDK project with the following commands, the `setup.sh` script inside it performs these installations automatically.

<Frame>
  ```mermaid theme={"system"}
  flowchart
      n1@{ label: "**Download Project**" } --- n2["**Install Requirements**"]
      n2 --- n3["**Activate Devbox Shell**"]
      n3 --- n4["Prepare Data Labeling and Model Compilation Environment with Distrobox."]
      n5["Complete EdgeAI Label Studio Package Installations with Distrobox"] --- n6["Label Data with Label Studio"]
      n6 --- n7["Compile Model with Edge AI Model Maker"]
      n4 --> n5
      n1@{ shape: rounded}
      n3@{ shape: hex}
      n4@{ shape: hex}
      n5@{ shape: hex}
      style n1 fill:#FFDE59
      style n7 stroke-width:1px,stroke-dasharray:5 5
  	  style n6 stroke-width:1px,stroke-dasharray:5 5
  ```
</Frame>

### 1.2. Download the Project

Open a Terminal in any folder on Ubuntu and clone the project with the `git clone` command as below.

<CodeGroup>
  ```bash Terminal lines theme={"system"}
  git clone https://github.com/t3gemstone/edgeai-tensorlab.git
  ```

  ```bash Output lines theme={"system"}
  ubuntu@host:~$ git clone https://github.com/t3gemstone/edgeai-tensorlab.git
  Cloning into 'edgeai-tensorlab'...
  remote: Enumerating objects: 386468, done.
  remote: Counting objects: 100% (442/442), done.
  remote: Compressing objects: 100% (101/101), done.
  remote: Total 386468 (delta 389), reused 344 (delta 341), pack-reused 386026 (from 2)
  Receiving objects: 100% (386468/386468), 675.93 MiB | 29.93 MiB/s, done.
  Resolving deltas: 100% (280871/280871), done.
  Updating files: 100% (15274/15274), done.
  ubuntu@host:~$
  ```
</CodeGroup>

### 1.3. Install Requirements

After the cloning process, enter the folder with the `cd edgeai-tensorlab` command from the same terminal screen and run the `setup.sh` script.

<CodeGroup>
  ```bash Terminal lines theme={"system"}
  cd edgeai-tensorlab
  ./setup.sh
  ```

  ```bash Output lines theme={"system"}
  ubuntu@host:~$ cd edgeai-tensorlab/
  ubuntu@host:edgeai-tensorlab$ ./setup.sh 

  🚀 T3 Gemstone Vision Process Model Development Kit

    This script downloads and installs the necessary packages 📦 
    to develop the vision process model for T3 Gemstone boards.
    Powered by Jetify Devbox, Distrobox, Love and Passion.

  → requirements...
  ✓ requirements... [DONE]
  → docker...
  ✓ docker... [DONE]
  ✓ docker-permissions... [DONE]
  → devbox...
  ✓ devbox... [DONE]

  What's the next?
    1. Learn how to build 🌍 a new world
      Read the docs at https://docs.t3gemstone.org

    2. Get help and give feedback
      Join our community at https://community.t3gemstone.org
  ```
</CodeGroup>

<Warning>
  If the application named Docker was not previously installed on your system; if you are installing it for the first time, remember to log out and log back in to your computer user session.
</Warning>

# 2. Compilation

After completing the requirement installation script, you can start the compilation steps by activating the Devbox Shell from within the sdk folder in the Terminal.

### 2.1. Activate Devbox Console

Activate **Devbox**, a software package management system that may contain different versions from Ubuntu packages, to complete the necessary downloads and installations for edgeai-tensorlab.

<CodeGroup>
  ```bash Terminal lines theme={"system"}
  devbox shell
  ```

  ```bash Output lines theme={"system"}
  ubuntu@host:~$ cd edgeai-tensorlab
  ubuntu@host:edgeai-tensorlab$ devbox shell
  Starting a devbox shell...
  📦 devbox:edgeai-tensorlab>
  ```
</CodeGroup>

### 2.2. Prepare Compilation Environment

Perform the Distrobox installation process via the following command.

<CodeGroup>
  ```bash Terminal lines theme={"system"}
  task box
  ```

  ```bash Output lines theme={"system"}
  📦 devbox:edgeai-tensorlab> task box
  task: [box] distrobox-list | grep -q 'gemstone-edgeai' || docker build -f Dockerfile -t gemstone-edgeai:latest .
  [+] Building 0.1s (9/9) FINISHED                                 docker:default
  => [internal] load build definition from Dockerfile                       0.0s
  => => transferring dockerfile: 1.21kB                                     0.0s
  => [internal] load metadata for docker.io/library/ubuntu:22.04            0.0s
  => [internal] load .dockerignore                                          0.0s
  => => transferring context: 2B                                            0.0s
  => [1/5] FROM docker.io/library/ubuntu:22.04                              0.0s
  => CACHED [2/5] RUN apt-get update &&     apt-get upgrade -y &&     apt-  0.0s
  => CACHED [3/5] RUN sed -i 's/pam_unix\.so obscure/pam_unix.so minlen=1   0.0s
  => CACHED [4/5] RUN echo gemstone > /etc/hostname                         0.0s
  => CACHED [5/5] RUN curl --location https://taskfile.dev/install.sh | su  0.0s
  => exporting to image                                                     0.0s
  => => exporting layers                                                    0.0s
  => => writing image sha256:9671fd0552dfcab17e321871b140c89b0aa242eabed98  0.0s
  => => naming to docker.io/library/gemstone-edgeai:latest                  0.0s
  task: [box] distrobox-assemble create --file distrobox.ini
  - Creating gemstone-edgeai...
  Creating 'gemstone-edgeai' using image gemstone-edgeai	 [ OK ]
  Distrobox 'gemstone-edgeai' successfully created.
  To enter, run:

  distrobox enter gemstone-edgeai

  Successfully copied 2.05kB to /tmp/gemstone-edgeai.os-release
  Starting container...                   	 [ OK ]
  Installing basic packages...            	 [ OK ]
  Setting up devpts mounts...             	 [ OK ]
  Setting up read-only mounts...          	 [ OK ]
  Setting up read-write mounts...         	 [ OK ]
  Setting up host's sockets integration...	 [ OK ]
  Integrating host's themes, icons, fonts...	 [ OK ]
  Setting up distrobox profile...         	 [ OK ]
  Setting up sudo...                      	 [ OK ]
  Setting up user groups...               	 [ OK ]
  Setting up user's group list...         	 [ OK ]
  Adding user...                          	 [ OK ]
  Ensuring user's access...               	 [ OK ]
  Setting up skel...                      	 [ OK ]
  Executing init hooks...                 	 [ OK ]
  Setting up init system...               	 [ OK ]
  Firing up init system...                	 [ OK ]

  Container Setup Complete!
  task: [box] distrobox-enter --additional-flags "--tty" --name gemstone-edgeai --no-workdir
  To run a command as administrator (user "root"), use "sudo <command>".
  See "man sudo_root" for details.

  ⚠️  First time user password setup ⚠️ 
  New password: 
  Retype new password: 
  passwd: password updated successfully
  🚀 distrobox:workdir> 
  ```
</CodeGroup>

Towards the end of the installation process, you will be asked for `⚠️  First time user password setup ⚠️` to give a password for your distrobox environment. To distinguish which console you are in from the Terminal during compilation operations, you can choose a 1-character password different from your computer's password. Finally, when you see the `🚀 distrobox:workdir>` line, you are ready to prepare Gemstone Image Processing models!

### 2.3. Complete Package Installations

Complete the necessary installations for Label Studio and Edge AI Model Maker.

<CodeGroup>
  ```bash Terminal lines theme={"system"}
  task install
  ```

  ```bash Output lines theme={"system"}
  📦 devbox:edgeai-tensorlab> task box
  task: [box] distrobox-list | grep -q 'gemstone-edgeai' || docker build -f Dockerfile -t gemstone-edgeai:latest .
  [+] Building 0.1s (9/9) FINISHED                                 docker:default
  => [internal] load build definition from Dockerfile                       0.0s
  => => transferring dockerfile: 1.21kB                                     0.0s
  => [internal] load metadata for docker.io/library/ubuntu:22.04            0.0s
  => [internal] load .dockerignore                                          0.0s
  => => transferring context: 2B                                            0.0s
  => [1/5] FROM docker.io/library/ubuntu:22.04                              0.0s
  => CACHED [2/5] RUN apt-get update &&     apt-get upgrade -y &&     apt-  0.0s
  => CACHED [3/5] RUN sed -i 's/pam_unix\.so obscure/pam_unix.so minlen=1   0.0s
  => CACHED [4/5] RUN echo gemstone > /etc/hostname                         0.0s
  => CACHED [5/5] RUN curl --location https://taskfile.dev/install.sh | su  0.0s
  => exporting to image                                                     0.0s
  => => exporting layers                                                    0.0s
  => => writing image sha256:9671fd0552dfcab17e321871b140c89b0aa242eabed98  0.0s
  => => naming to docker.io/library/gemstone-edgeai:latest                  0.0s
  task: [box] distrobox-assemble create --file distrobox.ini
  - Creating gemstone-edgeai...
  Creating 'gemstone-edgeai' using image gemstone-edgeai	 [ OK ]
  Distrobox 'gemstone-edgeai' successfully created.
  To enter, run:

  distrobox enter gemstone-edgeai

  Successfully copied 2.05kB to /tmp/gemstone-edgeai.os-release
  Starting container...                   	 [ OK ]
  Installing basic packages...            	 [ OK ]
  Setting up devpts mounts...             	 [ OK ]
  Setting up read-only mounts...          	 [ OK ]
  Setting up read-write mounts...         	 [ OK ]
  Setting up host's sockets integration...	 [ OK ]
  Integrating host's themes, icons, fonts...	 [ OK ]
  Setting up distrobox profile...         	 [ OK ]
  Setting up sudo...                      	 [ OK ]
  Setting up user groups...               	 [ OK ]
  Setting up user's group list...         	 [ OK ]
  Adding user...                          	 [ OK ]
  Ensuring user's access...               	 [ OK ]
  Setting up skel...                      	 [ OK ]
  Executing init hooks...                 	 [ OK ]
  Setting up init system...               	 [ OK ]
  Firing up init system...                	 [ OK ]

  Container Setup Complete!
  task: [box] distrobox-enter --additional-flags "--tty" --name gemstone-edgeai --no-workdir
  To run a command as administrator (user "root"), use "sudo <command>".
  See "man sudo_root" for details.

  ⚠️  First time user password setup ⚠️ 
  New password: 
  Retype new password: 
  passwd: password updated successfully
  🚀 distrobox:workdir> 
  ```
</CodeGroup>

# 3. End

By completing this section, you have set up the Gemstone image processing model preparation environment.

<Check>
  You can proceed to the next section and start data labeling and model compilation for Gemstone boards.
</Check>
