Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a4c9afe
Add Fastapi for processing
cwlacewe Mar 18, 2026
2e192f8
Add fastapi version to display detections as processed
cwlacewe Mar 19, 2026
4218dca
Latest for filtering demo; further optimizations needed to exceed 11 fps
cwlacewe Mar 24, 2026
6fad9a4
demo cleanup
cwlacewe Mar 30, 2026
250b823
Harden finetune code and add documentation
cwlacewe Mar 31, 2026
e9d6ad8
Move finetune README location
cwlacewe Mar 31, 2026
6692cc7
Moved finetune instructions to doc/ and added placeholder for latest …
cwlacewe Mar 31, 2026
37a50eb
Code cleanup
cwlacewe Apr 6, 2026
0d5f1a2
Update streamlock
cwlacewe Apr 6, 2026
978a587
Update dependencies; Add hash script/files
cwlacewe Apr 7, 2026
5612c94
Update dependencies; lint Dockerfiles
cwlacewe Apr 8, 2026
8eba4dc
Update notes in pipeline.md, clean/reorg fastapi code, add health end…
cwlacewe Apr 13, 2026
96315b4
[FastAPI] Use single requirements.txt for all devices, Add CUDA env v…
cwlacewe May 6, 2026
1bc1eaf
[frontend] Update to obtain model labels from fastapi endpoint; [fast…
cwlacewe Jun 5, 2026
42efd72
Demo ready version: [VSCODE} Added devcontainer and update fastapi la…
cwlacewe Jun 9, 2026
45c6ac7
update pipeline.md
cwlacewe Jun 9, 2026
9164fca
Merge branch 'main' into cwl_demo
cwlacewe Jun 9, 2026
247a16c
Added "# scorecard-ignore: pinned-dependencies" to finetune DOckerfile
cwlacewe Jun 9, 2026
eade75a
Update finetune Dockerfile to mimic fastapi Dockerfile
cwlacewe Jun 9, 2026
6c55956
Improve synchronization to minimize race conditions and images teari…
cwlacewe Jun 10, 2026
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
181 changes: 181 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@

FROM openvisualcloud/xeon-ubuntu2204-media-nginx:23.1@sha256:d19eb597dc210134063803630ae2ea1ec84dfd4189138f59551e2f5ed047284a AS build

ARG DEBIAN_FRONTEND=noninteractive
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="$VIRTUAL_ENV/bin:/usr/local/cuda/bin:${PATH}"
ENV LD_LIBRARY_PATH="$VIRTUAL_ENV/lib:/usr/local/cuda/lib64:${LD_LIBRARY_PATH}"

# Prevent Python from writing .pyc files and enable unbuffered logging
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1

# hadolint ignore=DL3008
RUN apt-get update && \
apt-get install -y --only-upgrade --no-install-recommends libc-bin libc6 && \
apt-get install -y -q --no-install-recommends python3-setuptools \
python3-dev python3-pip python3-venv \
curl libgl1-mesa-glx \
# Update and install necessary build tools and dependencies for OpenCV
build-essential \
cmake \
git \
wget \
unzip \
yasm \
pkg-config \
libgl1 \
libglib2.0-0 \
libgtk2.0-dev \
libtbb-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libxvidcore-dev \
libxine2-dev \
libv4l-dev \
libdc1394-dev \
libatlas-base-dev \
gfortran && \
# Install necessary CUDA packages
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb -o /tmp/cuda-keyring.deb && \
dpkg -i /tmp/cuda-keyring.deb && rm /tmp/cuda-keyring.deb && \
apt-get update && \
apt-get install -y -q --no-install-recommends \
cuda-toolkit-12-4 \
libcudnn9-dev-cuda-12 \
libnpp-dev-12-4 \
&& \
rm -rf /var/lib/apt/lists/* && apt-get clean

RUN python3 -m venv ${VIRTUAL_ENV} && \
${VIRTUAL_ENV}/bin/pip install --no-cache-dir \
"pip==26.0.1" \
"torch==2.10.0" \
"torchvision==0.25.0" \
"numpy==1.26.0"

# OPENCV W/ CUDA SUPPORT
ENV PYTHON_VERSION=3.10
ENV OPENCV_VERSION="4.11.0"
ENV DEPENDENCY_DIR=/tmp/build_opencv
ENV NUMPY_PATH="${VIRTUAL_ENV}/lib/python${PYTHON_VERSION}/site-packages/numpy/core/include"
ENV SYS_PATH="/usr/include/python${PYTHON_VERSION}"

# Clone OpenCV and OpenCV Contrib repositories
WORKDIR ${DEPENDENCY_DIR}
RUN git clone --branch ${OPENCV_VERSION} --depth 1 https://github.com/opencv/opencv.git ${DEPENDENCY_DIR}/opencv && \
git clone --branch ${OPENCV_VERSION} --depth 1 https://github.com/opencv/opencv_contrib.git ${DEPENDENCY_DIR}/opencv_contrib

# Create build directory and run CMake
WORKDIR ${DEPENDENCY_DIR}/opencv/build
RUN ln -s /usr/include/x86_64-linux-gnu/cudnn*.h /usr/local/cuda/include/ && \
ln -s /usr/lib/x86_64-linux-gnu/libcudnn*.so* /usr/local/cuda/lib64/
RUN cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX="${VIRTUAL_ENV}" \
-D OPENCV_EXTRA_MODULES_PATH="${DEPENDENCY_DIR}/opencv_contrib/modules" \
-D WITH_CUDA=ON \
-D WITH_CUDNN=ON \
-D WITH_CUBLAS=ON \
-D WITH_FFMPEG=ON \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D OPENCV_DNN_CUDA=ON \
-D CUDA_ARCH_BIN=70,75,80,86,89,90 \
-D CUDA_FAST_MATH=ON \
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
-D CUDNN_INCLUDE_DIR=/usr/include/x86_64-linux-gnu \
-D CUDNN_LIBRARY=/usr/lib/x86_64-linux-gnu/libcudnn.so \
-D BUILD_opencv_cudaimgproc=ON \
-D BUILD_opencv_cudaarithm=ON \
-D BUILD_opencv_cudafilters=ON \
-D BUILD_opencv_cudacodec=ON \
-D WITH_NVCUVID=ON \
-D WITH_NVCUVENC=ON \
-D WITH_VAAPI=ON \
-D WITH_FFMPEG=ON \
-D BUILD_opencv_python3=ON \
-D PYTHON3_EXECUTABLE="${VIRTUAL_ENV}/bin/python3" \
-D PYTHON3_NUMPY_INCLUDE_DIRS="${VIRTUAL_ENV}/lib/python3.10/site-packages/numpy/core/include" \
-D OPENCV_SKIP_PYTHON_LOADER=ON \
-D BUILD_EXAMPLES=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF .. \
&& make -j$(nproc) && make install && ldconfig

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN mkdir -p /tmp/cv2_deps && \
PY_CV2_SO=$(find "${VIRTUAL_ENV}" -name "cv2*.so" | head -n 1) && \
ldd "${PY_CV2_SO}" | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /tmp/cv2_deps/ && \
cp -v /usr/local/cuda/lib64/libnpp*.so* /tmp/cv2_deps/ && \
cp -v /usr/local/cuda/lib64/libcudart.so* /tmp/cv2_deps/ && \
cp -P /usr/local/cuda/lib64/libnvrtc.so* /tmp/cv2_deps/ && \
cp -v /usr/lib/x86_64-linux-gnu/libnvidia-encode.so* /tmp/cv2_deps/ || true


# Clean up
RUN rm -rf ${DEPENDENCY_DIR}


FROM openvisualcloud/xeon-ubuntu2204-media-nginx:23.1@sha256:d19eb597dc210134063803630ae2ea1ec84dfd4189138f59551e2f5ed047284a

ARG DEBIAN_FRONTEND=noninteractive
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="$VIRTUAL_ENV/bin:/usr/local/cuda/bin:${PATH}"

# Install Runtime Libraries, FFmpeg/VA-API headers, and cuDNN
# Includes libva and ffmpeg libraries required for HEVC decoding
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
python3 \
libgl1 \
libglib2.0-0 \
libtbb12 \
# Critical for Hardware Decoding (HEVC)
libva2 \
libva-drm2 \
libva-x11-2 \
libavcodec58 \
libavformat58 \
libswscale5 \
libv4l-0 && \
# Install necessary CUDA packages
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb -o /tmp/cuda-keyring.deb && \
dpkg -i /tmp/cuda-keyring.deb && rm /tmp/cuda-keyring.deb && \
apt-get update && \
apt-get install -y -q --no-install-recommends libcudnn9-cuda-12 \
libavcodec-dev \
libavformat-dev \
libavutil-dev nvidia-cuda-dev && \
rm -rf /var/lib/apt/lists/*

# Copy the entire pre-compiled virtual environment from the build stage
COPY --from=build ${VIRTUAL_ENV} ${VIRTUAL_ENV}
# Copy NPP (NVIDIA Performance Primitives) libs - Required for OpenCV CUDA
# COPY --from=build /usr/local/cuda/lib64/libnpp*.so* /usr/local/cuda/lib64/
# Copy additional required CUDA math/parallel libs
RUN mkdir -p /usr/local/cuda/lib64
COPY --from=build /tmp/cv2_deps/* /usr/local/cuda/lib64/
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:${VIRTUAL_ENV}/lib:${LD_LIBRARY_PATH}"
RUN ldconfig

ARG DEVICE="CPU"
ENV DEVICE="${DEVICE}"

# Set the working directory in the container
WORKDIR /home
COPY requirements.txt /home/
ENV NVIDIA_DRIVER_CAPABILITIES=all

# RUN pip3 install --no-cache-dir "pytest>=9.0.3" && \
# pip3 install --no-cache-dir --require-hashes -r /home/requirements.CPU.txt --index-url https://download.pytorch.org/whl/cpu --extra-index-url https://pypi.org/simple && \
# pip3 uninstall -y ultralytics opencv-python opencv-contrib-python opencv-python-headless && \
# pip3 install --no-cache-dir --require-hashes -r /home/requirements.GPU.txt && \
# pip3 uninstall -y opencv-python opencv-contrib-python opencv-python-headless


RUN pip3 install --no-cache-dir --require-hashes -r /home/requirements.txt && \
pip3 uninstall -y opencv-python opencv-contrib-python opencv-python-headless
74 changes: 74 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
{
"name": "Pipeline Dev",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// "image": "mcr.microsoft.com/devcontainers/base:bullseye"
"build": {
// Path is relative to the devcontainer.json file.
"dockerfile" : "Dockerfile",
// "context" : "..",
// "dockerfile" : "../fastapi/Dockerfile",
"context" : "../fastapi",
"args":{
"HTTP_PROXY" : "${localEnv:HTTP_PROXY}",
"http_proxy" : "${localEnv:http_proxy}",
"HTTPS_PROXY" : "${localEnv:HTTPS_PROXY}",
"https_proxy" : "${localEnv:https_proxy}",
"NO_PROXY" : "${localEnv:NO_PROXY}",
"no_proxy" : "${localEnv:no_proxy}",
}
},
"containerEnv" : {
"HTTP_PROXY" : "${localEnv:HTTP_PROXY}",
"http_proxy" : "${localEnv:http_proxy}",
"HTTPS_PROXY" : "${localEnv:HTTPS_PROXY}",
"https_proxy" : "${localEnv:https_proxy}",
"NO_PROXY" : "${localEnv:NO_PROXY}",
"no_proxy" : "${localEnv:no_proxy}",
},

"runArgs" : [ "--rm", "--gpus", "all", "--ipc=host", "--name", "pipeline_dev", "-p", "8011:8000","--cap-add=SYS_NICE", "--shm-size=8gb"], //, "--net=host", "--privileged", "--shm-size=2gb"],

"postStartCommand": "apt-get update -o Acquire::Check-Date=false -y && apt-get install -y gdb sudo && cp -rp /workspace/app/*.md /app/ && cp -rp /workspace/app/.vscode /app/ && cp -rp /workspace/app/.gitignore /app/ && cp -rp /workspace/app/.github /app/",
// "postAttachCommand": "sudo chown -R ${localEnv:USER} /workspaces",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Configure tool-specific properties.
"customizations": {
"vscode" : {
"extensions" : [
"ms-python.python",
"ms-python.vscode-pylance",
"esbenp.prettier-vscode"
]
}
},

"workspaceFolder": "/home",
"workspaceMount": "source=./,target=/workspace/app,type=bind,consistency=cached",

// For training only
// "mounts": [
// "source=/data1/dataset,target=/workspace/dataset,type=bind"
// ],

// For fastapi
"mounts": [
"source=./inputs,target=/watch_dir,type=bind",
"source=./fastapi,target=/home,type=bind"
// "source=./fastapi/resources,target=/home/resources,type=bind",
// "source=./fastapi/tests,target=/home/tests,type=bind"
],

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
// "containerUser": "${localEnv:USER}",
// "remoteUser": "${localEnv:USER}",
"updateRemoteUserUID": true //automatically updates the container user's UID and GID to match your local user's UID and GID to prevent permission issues with bind mounts
}
26 changes: 26 additions & 0 deletions .github/assets/fastapi/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
av>=17.0.1
cucim>=23.10.0
cupy-cuda12x>=13.6.0
fastapi>=0.135.1
nncf>=2.19.0
numpy>=1.26.4
nvidia-cuda-runtime-cu12>=12.8.90
nvidia-cudnn-cu12>=9.10.2.21
onnx>=1.21.0
onnxruntime-gpu>=1.23.2
onnxslim>=0.1.82
openvino-dev>=2024.6.0
pip>=26.0.1
protobuf>=5.29.6,<6 # For VDMS
pynvvideocodec>=2.1.0
pytest>=9.0.3
requests>=2.33.0
tensorrt_cu12==10.14.1.48.post1
torch==2.10.0
torchvision==0.25.0
ultralytics>=8.4.8
uvicorn>=0.42.0
vdms>=0.0.23
wheel>=0.46.3

pillow>=12.1.1
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
cucim>=23.10.0
cupy-cuda12x>=13.6.0
numpy>=1.26.4
nvidia-cuda-runtime-cu12>=12.8.90
nvidia-cudnn-cu12>=9.10.2.21
onnx>=1.21.0
onnxruntime-gpu>=1.23.2
onnxslim>=0.1.82
pip>=26.0.1
protobuf>=5.29.6,<6 # For VDMS
requests>=2.33.0
tensorrt_cu12==10.14.1.48.post1
torch==2.10.0
torchvision==0.25.0
vdms>=0.0.23
ultralytics>=8.4.8

pillow>=12.1.1

3 changes: 2 additions & 1 deletion .github/assets/udf/requirements.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Flask>=3.1.2
Flask>=3.1.3
inotify>=0.2.12
numpy>=2.2.6
opencv-python-headless>=4.13.0.90
pip>=26.0.1
protobuf>=5.29.6,<6 # For VDMS
vdms>=0.0.23
werkzeug>=3.1.6
wheel>=0.46.3
13 changes: 0 additions & 13 deletions .github/assets/video/requirements.CPU.in

This file was deleted.

16 changes: 1 addition & 15 deletions .github/assets/video/requirements.in
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
--index-url https://download.pytorch.org/whl/cpu
--extra-index-url https://pypi.org/simple

torch==2.10.0+cpu
torchvision==0.25.0+cpu

inotify>=0.2.12
opencv-python-headless>=4.11.0.86
openvino-dev>=2024.6.0
pip>=26.0.1
protobuf>=5.29.6,<6 # For VDMS
psutil>=7.2.1
pyyaml>=6.0.3
requests>=2.33.0
tornado>=6.5.5
ultralytics>=8.4.7
vdms>=0.0.23
wheel>=0.46.3

pillow>=12.1.1
12 changes: 9 additions & 3 deletions .github/scripts/get_py_hashes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ SCRIPT_DIR=$(dirname "$(realpath "$0")")
GH_DIR=$(dirname "${SCRIPT_DIR}")
REPO_DIR=$(dirname "${GH_DIR}")

# FASTAPI
# uv pip compile ${GH_DIR}/assets/fastapi/requirements.CPU.in --no-header --no-annotate -o ${REPO_DIR}/fastapi/requirements.CPU.txt --generate-hashes --allow-unsafe --index-strategy unsafe-best-match
# pip-compile --no-header --no-annotate -o ${REPO_DIR}/fastapi/requirements.GPU.txt --generate-hashes --allow-unsafe ${GH_DIR}/assets/fastapi/requirements.GPU.in
pip-compile --no-header --no-annotate -o ${REPO_DIR}/fastapi/requirements.txt --generate-hashes --allow-unsafe ${GH_DIR}/assets/fastapi/requirements.in

# FINETUNE
pip-compile --no-header --no-annotate -o ${REPO_DIR}/finetune/requirements.txt --generate-hashes --allow-unsafe ${GH_DIR}/assets/finetune/requirements.in

# FRONTEND
pip-compile --no-header --no-annotate -o ${REPO_DIR}/frontend/requirements.txt --generate-hashes --allow-unsafe ${GH_DIR}/assets/frontend/requirements.in

# UDF
pip-compile --no-header --no-annotate -o ${REPO_DIR}/udf/requirements.txt --generate-hashes --allow-unsafe ${GH_DIR}/assets/udf/requirements.in

# VIDEO
uv pip compile ${GH_DIR}/assets/video/requirements.in --no-header --no-annotate -o ${REPO_DIR}/video/requirements.txt --generate-hashes --allow-unsafe --index-strategy unsafe-best-match
uv pip compile ${GH_DIR}/assets/video/requirements.CPU.in --no-header --no-annotate -o ${REPO_DIR}/video/requirements.CPU.txt --generate-hashes --allow-unsafe --index-strategy unsafe-best-match
pip-compile --no-header --no-annotate -o ${REPO_DIR}/video/requirements.GPU.txt --generate-hashes --allow-unsafe ${GH_DIR}/assets/video/requirements.GPU.in
pip-compile --no-header --no-annotate -o ${REPO_DIR}/video/requirements.txt --generate-hashes --allow-unsafe ${GH_DIR}/assets/video/requirements.in
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@
**/_*
**/DockerImageTars/
build/*
video/resources/models/intel
video/resources/models/ultralytics
fastapi/resources/models/intel
fastapi/resources/models/ultralytics
fastapi/tests/*_results*
fastapi/tests/*_test_imgs
fastapi/tests/*.mp4
finetune/.env
finetune/app/*-Results
inputs/camera_config.yaml
Loading