# Image segmentation using Python with container
Source: [https://docs.qualcomm.com/doc/80-70020-50/topic/image-segmentation-using-python.html](https://docs.qualcomm.com/doc/80-70020-50/topic/image-segmentation-using-python.html)
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 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-70020-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.0Copy to clipboard
cd sdk-tools/snpe-container-pythonCopy to clipboard
mkdir imagesCopy 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 inputsCopy to clipboard
cp ./inputsCopy to clipboard
cd inputsCopy to clipboard
mv input_image.jpgCopy to clipboard
3. Set up the host device for cross
compilation:
sudo groupadd dockerCopy to clipboard
sudo usermod -aG docker $USERCopy to clipboard
newgrp dockerCopy 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-armCopy to clipboard
docker run --rm --privileged multiarch/qemu-user-static --reset -p yesCopy to clipboard
docker buildx rm builderCopy to clipboard
docker buildx create --name builder --driver docker-container --useCopy to clipboard
docker buildx inspect --bootstrapCopy 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.35.0.250530",
"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 jqCopy to clipboard
cd /snpe-container-pythonCopy to clipboard
source scripts/host/docker_env_setup.shCopy to clipboard
qml-docker-build-image targets/config.jsonCopy to clipboard
Save
the Docker
image:
qml-docker-device-save-image targets/config.jsonCopy 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-<field
value>.tar.
6. Push the Docker image on the target
device:
scp /qml.tar root@:/optCopy to clipboard
7. Start the
container:
ssh root@Copy to clipboard
mount -o remount, rw /usrCopy to clipboard
systemctl restart dockerCopy to clipboard
docker load < /opt/qml.tarCopy 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:/usr/lib/libCB.so \
-v /usr/lib/libOpenCL.so:/usr/lib/libOpenCL.so \
-v /usr/lib/libOpenCL_adreno.so:/usr/lib/libOpenCL_adreno.so \
-v /usr/lib/libbase.so.0:/usr/lib/libbase.so.0 \
-v /usr/lib/libcdsprpc.so:/usr/lib/libcdsprpc.so \
-v /usr/lib/libcutils.so.0:/usr/lib/libcutils.so.0 \
-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:/usr/lib/libgsl.so \
-v /usr/lib/libgthread-2.0.so.0:/usr/lib/libgthread-2.0.so.0 \
-v /usr/lib/libion.so.0:/usr/lib/libion.so.0 \
-v /usr/lib/libllvm-qcom.so:/usr/lib/libllvm-qcom.so \
-v /usr/lib/liblog.so.0:/usr/lib/liblog.so.0 \
-v /usr/lib/libpcre.so.1:/usr/lib/libpcre.so.1 \
-v /usr/lib/libsync.so.0:/usr/lib/libsync.so.0 \
-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 qmlCopy to clipboard
A Docker image called
qml should be running. To check this image, run the
following
command:
docker psCopy 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:
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.soCopy 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

**Parent Topic:** [Run AI/ML sample applications](https://docs.qualcomm.com/doc/80-70020-50/topic/ai-ml-sample-applications.html)
Last Published: Jan 30, 2026
[Previous Topic
Image segmentation](https://docs.qualcomm.com/bundle/publicresource/80-70020-50/topics/gst-ai-segmentation.md) [Next Topic
Parallel inferencing](https://docs.qualcomm.com/bundle/publicresource/80-70020-50/topics/gst-ai-parallel-inference.md)