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

Remove Artpec-7 #195

Merged
merged 1 commit into from
Oct 8, 2024
Merged
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
7 changes: 1 addition & 6 deletions .github/workflows/hello-world-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ jobs:
env:
EXREPO: acap-computer-vision-examples
EXNAME: hello-world-python
strategy:
matrix:
include:
- arch: armv7hf
- arch: aarch64
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v2
Expand All @@ -30,4 +25,4 @@ jobs:
imagetag: ${{ env.EXREPO }}_${{ env.EXNAME }}:1.0
run: |
cd $EXNAME
docker build --no-cache --build-arg ARCH=${{ matrix.arch }} --tag $imagetag .
docker build --no-cache --tag $imagetag .
12 changes: 4 additions & 8 deletions .github/workflows/minimal-ml-inference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ jobs:
strategy:
matrix:
include:
- arch: armv7hf
chip: cpu
- arch: armv7hf
chip: edgetpu
- arch: aarch64
chip: artpec8
- chip: cpu
- chip: artpec8
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v2
Expand All @@ -36,5 +32,5 @@ jobs:
run: |
cd $EXNAME
docker run --rm --privileged multiarch/qemu-user-static --credential yes --persistent yes
docker build --no-cache --build-arg CHIP=${{ matrix.chip }} --build-arg ARCH=${{ matrix.arch }} --tag $imagetag .
docker build --file Dockerfile.model --tag $modeltag --build-arg ARCH=${{ matrix.arch }} .
docker build --no-cache --build-arg CHIP=${{ matrix.chip }} --tag $imagetag .
docker build --file Dockerfile.model --tag $modeltag .
12 changes: 4 additions & 8 deletions .github/workflows/object-detector-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ jobs:
strategy:
matrix:
include:
- arch: armv7hf
chip: cpu
- arch: armv7hf
chip: edgetpu
- arch: aarch64
chip: artpec8
- chip: cpu
- chip: artpec8
env:
EXREPO: acap-computer-vision-examples
EXNAME: object-detector-python
Expand All @@ -35,5 +31,5 @@ jobs:
modeltag: ${{ env.EXREPO }}_${{ env.EXNAME }}-${{ matrix.chip }}-model:1.0
run: |
cd $EXNAME
docker build --no-cache --build-arg CHIP=${{ matrix.chip }} --build-arg ARCH=${{ matrix.arch }} --tag $imagetag .
docker build --file Dockerfile.model --tag $modeltag --build-arg ARCH=${{ matrix.arch }} .
docker build --no-cache --build-arg CHIP=${{ matrix.chip }} --tag $imagetag .
docker build --file Dockerfile.model --tag $modeltag .
7 changes: 1 addition & 6 deletions .github/workflows/opencv-qr-decoder-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ jobs:
env:
EXREPO: acap-computer-vision-examples
EXNAME: opencv-qr-decoder-python
strategy:
matrix:
include:
- arch: armv7hf
- arch: aarch64
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v2
Expand All @@ -30,4 +25,4 @@ jobs:
imagetag: ${{ env.EXREPO }}_${{ env.EXNAME }}:1.0
run: |
cd $EXNAME
docker build --no-cache --build-arg ARCH=${{ matrix.arch }} --tag $imagetag .
docker build --no-cache --tag $imagetag .
7 changes: 1 addition & 6 deletions .github/workflows/parameter-api-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ jobs:
env:
EXREPO: acap-computer-vision-examples
EXNAME: parameter-api-python
strategy:
matrix:
include:
- arch: armv7hf
- arch: aarch64
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v2
Expand All @@ -30,4 +25,4 @@ jobs:
imagetag: ${{ env.EXREPO }}_${{ env.EXNAME }}:1.0
run: |
cd $EXNAME
docker build --no-cache --build-arg ARCH=${{ matrix.arch }} --tag $imagetag .
docker build --no-cache --tag $imagetag .
12 changes: 4 additions & 8 deletions .github/workflows/pose-estimator-with-flask.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ jobs:
strategy:
matrix:
include:
- arch: armv7hf
chip: cpu
- arch: armv7hf
chip: edgetpu
- arch: aarch64
chip: artpec8
- chip: cpu
- chip: artpec8

steps:
- uses: actions/checkout@v2
Expand All @@ -37,5 +33,5 @@ jobs:
run: |
cd $EXNAME
docker run --rm --privileged multiarch/qemu-user-static --credential yes --persistent yes
docker build --no-cache --build-arg CHIP=${{ matrix.chip }} --build-arg ARCH=${{ matrix.arch }} --tag $imagetag .
docker build --file Dockerfile.model --tag $modeltag --build-arg ARCH=${{ matrix.arch }} .
docker build --no-cache --build-arg CHIP=${{ matrix.chip }} --tag $imagetag .
docker build --file Dockerfile.model --tag $modeltag .
7 changes: 1 addition & 6 deletions .github/workflows/web-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ jobs:
env:
EXREPO: acap-computer-vision-examples
EXNAME: web-server
strategy:
matrix:
include:
- arch: armv7hf
- arch: aarch64
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v2
Expand All @@ -31,4 +26,4 @@ jobs:
run: |
cd $EXNAME
docker run --rm --privileged multiarch/qemu-user-static --credential yes --persistent yes
docker build --no-cache --build-arg ARCH=${{ matrix.arch }} --tag $imagetag .
docker build --no-cache --tag $imagetag .
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ step-by-step instructions on how to run applications on the camera.

The examples support the following architectures:

* armv7hf
* aarch64

### Example applications for video analytics
Expand Down
8 changes: 3 additions & 5 deletions hello-world-python/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# syntax=docker/dockerfile:1

ARG ARCH=armv7hf
ARG REPO=axisecp
ARG SDK_VERSION=1.15
ARG UBUNTU_VERSION=22.04

FROM arm32v7/ubuntu:${UBUNTU_VERSION} as runtime-image-armv7hf
FROM arm64v8/ubuntu:${UBUNTU_VERSION} as runtime-image-aarch64

FROM ${REPO}/acap-computer-vision-sdk:${SDK_VERSION}-${ARCH} AS cv-sdk
FROM runtime-image-${ARCH}
FROM ${REPO}/acap-computer-vision-sdk:${SDK_VERSION}-aarch64 AS cv-sdk

FROM arm64v8/ubuntu:${UBUNTU_VERSION}

# Get the Python package from the CV SDK
COPY --from=cv-sdk /axis/python /
Expand Down
23 changes: 5 additions & 18 deletions hello-world-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,23 @@ hello-world-python
Meet the following requirements to ensure compatibility with the example:

* Axis device
* Chip: ARTPEC-{7-8} DLPU devices (e.g., Q1615 MkIII)
* Firmware: 10.9 or higher
* [Docker ACAP](https://github.com/AxisCommunications/docker-acap#installing) installed and started, using TLS and SD card as storage
* Chip: ARTPEC-8 DLPU devices (e.g., Q1656)
* Firmware: 11.10 or higher
* [Docker ACAP](https://github.com/AxisCommunications/docker-acap#installing) version 3.0 installed and started, using TLS with TCP and IPC socket and SD card as storage
* Computer
* Either [Docker Desktop](https://docs.docker.com/desktop/) version 4.11.1 or higher,
* or [Docker Engine](https://docs.docker.com/engine/) version 20.10.17 or higher with BuildKit enabled using Docker Compose version 1.29.2 or higher

## How to run the code

### Export the environment variable for the architecture

Export the `ARCH` variable depending on the architecture of your camera:

```sh
# For arm32
export ARCH=armv7hf

# For arm64
export ARCH=aarch64
```

### Build the Docker image

With the architecture defined, the `hello-world-python` image can be built. The environment variables are supplied as build arguments such that they are made available to Docker during the build process:
Define and export the application image name in `APP_NAME` for use in the Docker Compose file.

```sh
# Define app name
export APP_NAME=hello-world-python

docker build --tag $APP_NAME --build-arg ARCH .
docker build --tag $APP_NAME .
```

### Set your device IP address and clear Docker memory
Expand Down
8 changes: 2 additions & 6 deletions minimal-ml-inference/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# syntax=docker/dockerfile:1

ARG ARCH=armv7hf
ARG REPO=axisecp
ARG SDK_VERSION=1.15
ARG UBUNTU_VERSION=22.04

FROM arm32v7/ubuntu:${UBUNTU_VERSION} as runtime-image-armv7hf
FROM arm64v8/ubuntu:${UBUNTU_VERSION} as runtime-image-aarch64

# Specify which ACAP Computer Vision SDK to use
FROM ${REPO}/acap-computer-vision-sdk:${SDK_VERSION}-${ARCH} AS cv-sdk
FROM ${REPO}/acap-computer-vision-sdk:${SDK_VERSION}-aarch64 AS cv-sdk

# Define the runtime image
FROM runtime-image-${ARCH}
FROM arm64v8/ubuntu:${UBUNTU_VERSION}

# Get packages from the CV SDK
COPY --from=cv-sdk /axis/python /
Expand Down
20 changes: 1 addition & 19 deletions minimal-ml-inference/Dockerfile.model
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
# syntax=docker/dockerfile:1

ARG ARCH=armv7hf
ARG UBUNTU_VERSION=22.04

FROM arm32v7/alpine as model-image-armv7hf
FROM arm64v8/alpine as model-image-aarch64
FROM arm64v8/alpine as model-image

FROM arm32v7/ubuntu:${UBUNTU_VERSION} as local-armv7hf
FROM arm64v8/ubuntu:${UBUNTU_VERSION} as local-aarch64

FROM local-${ARCH} as local

RUN <<EOF
apt-get update
apt-get install -y -f openssl
EOF

# Generate TSL/SSL test certificate
RUN openssl req -x509 -batch -subj '/CN=localhost' -days 10000 -newkey rsa:4096 -nodes -out server.pem -keyout server.key

FROM model-image-${ARCH}

# Get SSD Mobilenet V2
ADD https://github.com/google-coral/edgetpu/raw/master/test_data/ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite models/
ADD https://github.com/google-coral/edgetpu/raw/master/test_data/ssd_mobilenet_v2_coco_quant_postprocess.tflite models/
ADD https://github.com/google-coral/edgetpu/raw/master/test_data/coco_labels.txt models/
ADD https://github.com/google-coral/edgetpu/raw/master/test_data/COPYRIGHT models/
COPY --from=local server.key server.pem models/

CMD /bin/ls /models
57 changes: 19 additions & 38 deletions minimal-ml-inference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ This example composes three different container images into an application that

The first container contains the actual program built in this example. It then uses [gRPC](https://grpc.io/)/[protobuf](https://developers.google.com/protocol-buffers) to call the second container, the *inference-server*, that is used to capture images from the camera and perform the actual inference by implementing the [TensorFlow Serving API](https://github.com/tensorflow/serving). You can find more documentation on the [Machine Learning API documentation page](https://axiscommunications.github.io/acap-documentation/docs/api/computer-vision-sdk-apis.html#machine-learning-api). This example uses a containerized version of the [ACAP Runtime](https://github.com/AxisCommunications/acap-runtime#containerized-version) as the *inference-server*.

Lastly, there is a third container that holds the deep learning model, which is put into a volume that is accessible by the other two images. The layout of the Docker image containing the model is shown below. The *MODEL_PATH* variable in the configuration file you're using specifies what model to use. By default, the armv7hf configuration file uses the edgetpu model, while the aarch64 configuration file uses the vanilla model.
Lastly, there is a third container that holds the deep learning model, which is put into a volume that is accessible by the other two images. The layout of the Docker image containing the model is shown below. The *MODEL_PATH* variable in the configuration file you're using specifies what model to use.

```text
model
├── ssdlite-mobilenet-v2 - model for CPU
├── ssdlite-mobilenet-v2-tpu - model for TPU
├── ssdlite-mobilenet-v2 - tflite model
└── objects.txt - list of object labels
```

Expand All @@ -26,8 +25,8 @@ Following are the list of files and a brief description of each file in the exam
```text
minimal-ml-inference
├── config
│ ├── env.aarch64
│ └── env.armv7hf
│ ├── env.aarch64.artpec8
│ └── env.aarch64.cpu
├── simple_inference.py
├── Dockerfile
├── Dockerfile.model
Expand All @@ -46,52 +45,33 @@ minimal-ml-inference
Meet the following requirements to ensure compatibility with the example:

* Axis device
* Chip: ARTPEC-{7-8} DLPU devices (e.g., Q1615 MkIII)
* Firmware: 10.9 or higher
* [Docker ACAP](https://github.com/AxisCommunications/docker-acap#installing) installed and started, using TLS and SD card as storage
* Chip: ARTPEC-8 DLPU devices (e.g., Q1656)
* Firmware: 11.10 or higher
* [Docker ACAP](https://github.com/AxisCommunications/docker-acap#installing) version 3.0 installed and started, using TLS with TCP and IPC socket and SD card as storage
* Computer
* Either [Docker Desktop](https://docs.docker.com/desktop/) version 4.11.1 or higher,
* or [Docker Engine](https://docs.docker.com/engine/) version 20.10.17 or higher with BuildKit enabled using Docker Compose version 1.29.2 or higher

## How to run the code

### Export the environment variable for the architecture

Export the `ARCH` variable depending on the architecture of your camera:

```sh
# For arm32
export ARCH=armv7hf

# Valid options for chip on armv7hf are 'tpu' (hardware accelerator) or 'cpu'
export CHIP=tpu
```

```sh
# For arm64
export ARCH=aarch64

# Valid options for chip on aarch64 are 'artpec8' (hardware accelerator) or 'cpu'
export CHIP=artpec8
```

### Build the Docker images

With the architecture defined, the `acap4-minimal-ml-inference` and `acap-dl-models` images can be built. The environment variables are supplied as build arguments such that they are made available to Docker during the build process:
Define and export the application image name in `APP_NAME` and the model image name in `MODEL_NAME` for use in the Docker Compose file.
Define and export also the `CHIP` parameter to be used during the build to select the right manifest file.

```sh
# Define app name
export APP_NAME=acap4-minimal-ml-inference
export MODEL_NAME=acap-dl-models
export CHIP=artpec8 # Valid options are 'artpec8' (hardware accelerator) or 'cpu'

# Install qemu to allow build flask for a different architecture
# Install qemu to allow build for a different architecture
docker run --rm --privileged multiarch/qemu-user-static --credential yes --persistent yes

# Build app
docker build --tag $APP_NAME --build-arg ARCH .
# Build application image
docker build --tag $APP_NAME .

# Build inference model
docker build --file Dockerfile.model --tag $MODEL_NAME --build-arg ARCH .
# Build inference model image
docker build --file Dockerfile.model --tag $MODEL_NAME .
```

### Set your device IP address and clear Docker memory
Expand Down Expand Up @@ -134,17 +114,18 @@ docker save $MODEL_NAME | docker --tlsverify --host tcp://$DEVICE_IP:$DOCKER_POR
With the application image on the device, it can be started using `docker-compose.yml`:

```sh
docker --tlsverify --host tcp://$DEVICE_IP:$DOCKER_PORT compose --env-file ./config/env.$ARCH.$CHIP up
docker --tlsverify --host tcp://$DEVICE_IP:$DOCKER_PORT compose --env-file ./config/env.aarch64.$CHIP up

# Terminate with Ctrl-C and cleanup
docker --tlsverify --host tcp://$DEVICE_IP:$DOCKER_PORT compose --env-file ./config/env.$ARCH.$CHIP down --volumes
docker --tlsverify --host tcp://$DEVICE_IP:$DOCKER_PORT compose --env-file ./config/env.aarch64.$CHIP down --volumes
```

The expected output from the application is the raw predictions from the model specified in the environment variable.

### Hardware acceleration

The `./config` folder contains configuration files with the parameters to run the inference on different camera models, also giving the possibility to use the hardware accelerator. To achieve the best performance we recommend using the TPU (Tensor Processing Unit) equipped with ARTPEC-7 cameras (e.g. [Axis-Q1615 Mk III](https://www.axis.com/products/axis-q1615-mk-iii)) or the DLPU (Deep Learning Processing Unit) equipped in ARTPEC-8 cameras (e.g. [Axis-Q1656](https://www.axis.com/products/axis-q1656)).
The `./config` folder contains configuration files with the parameters to run the inference on different camera models, also giving the possibility to use the hardware accelerator.
To achieve the best performance we recommend using DLPU (Deep Learning Processing Unit) equipped ARTPEC-8 cameras. See [ACAP Computer Vision SDK hardware and compatibility](https://axiscommunications.github.io/acap-documentation/docs/axis-devices-and-compatibility/#acap-computer-vision-sdk-hardware-compatibility)

## License

Expand Down
3 changes: 0 additions & 3 deletions minimal-ml-inference/config/env.armv7hf.cpu

This file was deleted.

3 changes: 0 additions & 3 deletions minimal-ml-inference/config/env.armv7hf.tpu

This file was deleted.

Loading
Loading