# Image segmentation using Python with container
The application allows you to perform image segmentation using the Qualcomm Neural Processing SDK with Python bindings, all from within a Docker container.
Note
This application isn't supported in the QLI 2.0 RC2 release.
Note
This application isn't supported on the Ubuntu Server.
## Set up the host container
**Figure : Workflow to set up host container**
To set up the host container, do the following on your Linux host computer with Docker:
1. Ensure that you complete the [Prerequisites](https://docs.qualcomm.com/doc/80-80021-50/topic/download-model-and-label-files.html).
2. Install [Qualcomm® Package Manager (QPM3)](https://qpm.qualcomm.com/#/main/tools/details/QPM3).
3. Download and extract Qualcomm Neural Processing SDK:
qpm-cli --login
Copy to clipboard
4. Download scripts and model attachments to run the sample mode.
1. Download the Dockerfile and scripts and prepare the directory for storing the image.
git clone https://git.codelinaro.org/clo/le/sdk-tools.git -b imsdk-tools.lnx.1.0
Copy to clipboard
cd sdk-tools/snpe-container-python
Copy to clipboard
mkdir images
Copy to clipboard
The `snpe-container-python` file has the Dockerfile and scripts. Run all the commands from this directory.
2. Copy the test image in a new folder called `inputs` and rename the test image as `input_image.jpg`.
mkdir inputs
Copy to clipboard
cp ./inputs
Copy to clipboard
cd inputs
Copy to clipboard
mv input_image.jpg
Copy to clipboard
3. Set up the host device for cross compilation:
sudo groupadd docker
Copy to clipboard
sudo usermod -aG docker $USER
Copy to clipboard
newgrp docker
Copy to clipboard
Until the host device is rebooted, continue running these commands for every new console that's used to run the Docker.
sudo apt-get install qemu-user-static qemu-system-arm
Copy to clipboard
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
Copy to clipboard
docker buildx rm builder
Copy to clipboard
docker buildx create --name builder --driver docker-container --use
Copy to clipboard
docker buildx inspect --bootstrap
Copy to clipboard
4. Build the Docker image. Populate the `/targets/config.json` file.
The following code shows an updated sample `config.json` file.
The following inputs are mandatory:
- `SNPE_version`
- `Base_Image`
- `Target_platform`: The following are field values for each SoC:
- For QCS6490–`qcm6490`
- For Dragonwing IQ-8275–`qcs8300`
- For Dragonwing IQ-9075–`qcs9100`
- `URL` (ensure that the address provided isn't the same as your current directory)
Note
To prevent code failures, ensure that you remove the comments before using it.
{
"SNPE_version":"2.41.0.251128",
"Base_Image": "ubuntu:22.04",
"Target_platform": "qcm6490",
"Additional_tag_container": "",
"Additional_tag_image": "",
"URL": "/snpe-container-python/images",
"DeviceID" : "null"
}
Copy to clipboard
5. Build the Docker image:
sudo apt install jq
Copy to clipboard
cd /snpe-container-python
Copy to clipboard
source scripts/host/docker_env_setup.sh
Copy to clipboard
qml-docker-build-image targets/config.json
Copy to clipboard
Save the Docker image:
qml-docker-device-save-image targets/config.json
Copy to clipboard
The Docker image is compressed and the TAR file is saved at the directory specified in the `URL` field in `config.json`.
- If `Additional_tag_image` is empty, the compressed image is stored as `qml.tar`.
- If `Additional_tag_image` is populated, the compressed image is stored as `qml-.tar`.
6. Push the Docker image on the target device:
scp /qml.tar root@:/opt
Copy to clipboard
7. Start the container:
ssh root@
Copy to clipboard
mount -o remount, rw /usr
Copy to clipboard
systemctl restart docker
Copy to clipboard
docker load < /opt/qml.tar
Copy to clipboard
8. Run the Docker image on the target device:
docker run -it -d --device=/dev/fastrpc-cdsp-secure \
--device /dev/kgsl-3d0 --device /dev/dma_heap/system --device /dev/dma_heap/qcom,system \
-v /usr/lib/libCB.so.1:/usr/lib/libCB.so.1 \
-v /usr/lib/libOpenCL.so.1:/usr/lib/libOpenCL.so.1 \
-v /usr/lib/libOpenCL_adreno.so.1:/usr/lib/libOpenCL_adreno.so.1 \
-v /usr/lib/libcdsprpc.so:/usr/lib/libcdsprpc.so \
-v /usr/lib/libdmabufheap.so.0:/usr/lib/libdmabufheap.so.0 \
-v /usr/lib/libglib-2.0.so.0:/usr/lib/libglib-2.0.so.0 \
-v /usr/lib/libgsl.so.1:/usr/lib/libgsl.so.1 \
-v /usr/lib/libgthread-2.0.so.0:/usr/lib/libgthread-2.0.so.0 \
-v /usr/lib/libllvm-qcom.so.1:/usr/lib/libllvm-qcom.so.1 \
-v /usr/lib/libpcre.so.1:/usr/lib/libpcre.so.1 \
-v /usr/lib/libvmmem.so.0:/usr/lib/libvmmem.so.0 \
-v /usr/lib/libatomic.so.1:/usr/lib/libatomic.so.1 \
-h qml --name qml qml
Copy to clipboard
A Docker image called `qml` should be running. To check this image, run the following command:
docker ps
Copy to clipboard
9. Push `input_image.jpg` to the target device.
scp /input_image.jpg root@:/opt/
Copy to clipboard
ssh root@
Copy to clipboard
docker cp /opt/input_image.jpg qml:/opt/
Copy to clipboard
10. Copy the `deeplab_resnet50.dlc` model to the Docker:
cd /etc/models/
Copy to clipboard
wget https://github.com/quic/sample-apps-for-qualcomm-linux/releases/download/GA1.7-rel/deeplabv3_resnet50.dlc
Copy to clipboard
docker cp /etc/models/deeplabv3_resnet50.dlc qml:/opt/
Copy to clipboard
## Run the application on the target device
1. Run the Qualcomm Neural Processing SDK model using Python bindings:
docker exec qml python3 /mnt/qml/src/python/snpe/test_snpe/snpe_segmentation_app.py -d /opt/deeplabv3_resnet50.dlc -i /opt/input_image.jpg -r dsp -o /mnt/qml/output/ -b USERBUFFER_FLOAT -p /usr/lib/libSNPE.so
Copy to clipboard
- The output image is saved in the container at `/opt/`.
- The output from the DLC model (RAW file) is saved at `/mnt/qml/output/`.
2. Copy the output from the container to the target device:
docker cp qml:/opt/output.jpg /opt/
Copy to clipboard
3. To pull the image from the target device to host, run the command on your Linux host computer:
scp root@:/opt/output.jpg ./
Copy to clipboard
## Expected output

**Figure : Expected output for image segmentation using Python binding**
Last Published: Mar 26, 2026
[Previous Topic
Image segmentation](https://docs.qualcomm.com/bundle/publicresource/80-80021-50/topics/gst-ai-segmentation.md) [Next Topic
Parallel inferencing](https://docs.qualcomm.com/bundle/publicresource/80-80021-50/topics/gst-ai-parallel-inference.md)