@@ -23,6 +23,7 @@ show_help() {
2323 echo " Options:"
2424 echo " --download-models Download default models"
2525 echo " --build-engines Build TensorRT engines for default models"
26+ echo " --opencv-cuda Setup OpenCV with CUDA support"
2627 echo " --server Start the Comfystream server, UI and ComfyUI"
2728 echo " --help Show this help message"
2829 echo " "
@@ -49,7 +50,7 @@ if [ "$1" = "--build-engines" ]; then
4950 # Build Static Engine for Dreamshaper
5051 python src/comfystream/scripts/build_trt.py --model /workspace/ComfyUI/models/unet/dreamshaper-8-dmd-1kstep.safetensors --out-engine /workspace/ComfyUI/output/tensorrt/static-dreamshaper8_SD15_\$ stat-b-1-h-512-w-512_00001_.engine
5152
52- # Build Engine for DepthAnything2
53+ # Build Engine for Depth Anything V2
5354 if [ ! -f " $DEPTH_ANYTHING_DIR /depth_anything_vitl14-fp16.engine" ]; then
5455 if [ ! -d " $DEPTH_ANYTHING_DIR " ]; then
5556 mkdir -p " $DEPTH_ANYTHING_DIR "
@@ -59,9 +60,66 @@ if [ "$1" = "--build-engines" ]; then
5960 else
6061 echo " Engine for DepthAnything2 already exists, skipping..."
6162 fi
63+
64+ # Build Engine for Depth Anything2 (large)
65+ if [ ! -f " $DEPTH_ANYTHING_DIR /depth_anything_v2_vitl-fp16.engine" ]; then
66+ cd " $DEPTH_ANYTHING_DIR "
67+ python /workspace/ComfyUI/custom_nodes/ComfyUI-Depth-Anything-Tensorrt/export_trt.py --trt-path " ${DEPTH_ANYTHING_DIR} /depth_anything_v2_vitl-fp16.engine" --onnx-path " ${DEPTH_ANYTHING_DIR} /depth_anything_v2_vitl.onnx"
68+ else
69+ echo " Engine for DepthAnything2 (large) already exists, skipping..."
70+ fi
6271 shift
6372fi
6473
74+ if [ " $1 " = " --opencv-cuda" ]; then
75+ cd /workspace/comfystream
76+ conda activate comfystream
77+
78+ # Check if OpenCV CUDA build already exists
79+ if [ ! -f " /workspace/comfystream/opencv-cuda-release.tar.gz" ]; then
80+ # Download and extract OpenCV CUDA build
81+ DOWNLOAD_NAME=" opencv-cuda-release.tar.gz"
82+ wget -q -O " $DOWNLOAD_NAME " https://github.com/JJassonn69/ComfyUI-Stream-Pack/releases/download/v1.0/opencv-cuda-release.tar.gz
83+ tar -xzf " $DOWNLOAD_NAME " -C /workspace/comfystream/
84+ rm " $DOWNLOAD_NAME "
85+ else
86+ echo " OpenCV CUDA build already exists, skipping download."
87+ fi
88+
89+ # Install required libraries
90+ apt-get update && apt-get install -y \
91+ libgflags-dev \
92+ libgoogle-glog-dev \
93+ libjpeg-dev \
94+ libavcodec-dev \
95+ libavformat-dev \
96+ libavutil-dev \
97+ libswscale-dev
98+
99+ # Remove existing cv2 package
100+ SITE_PACKAGES_DIR=" /workspace/miniconda3/envs/comfystream/lib/python3.11/site-packages"
101+ rm -rf " ${SITE_PACKAGES_DIR} /cv2" *
102+
103+ # Copy new cv2 package
104+ cp -r /workspace/comfystream/cv2 " ${SITE_PACKAGES_DIR} /"
105+
106+ # Handle library dependencies
107+ CONDA_ENV_LIB=" /workspace/miniconda3/envs/comfystream/lib"
108+
109+ # Remove existing libstdc++ and copy system one
110+ rm -f " ${CONDA_ENV_LIB} /libstdc++.so" *
111+ cp /usr/lib/x86_64-linux-gnu/libstdc++.so* " ${CONDA_ENV_LIB} /"
112+
113+ # Copy OpenCV libraries
114+ cp /workspace/comfystream/opencv/build/lib/libopencv_* /usr/lib/x86_64-linux-gnu/
115+
116+ # remove the opencv-contrib and cv2 folders
117+ rm -rf /workspace/comfystream/opencv_contrib
118+ rm -rf /workspace/comfystream/cv2
119+
120+ echo " OpenCV CUDA installation completed"
121+ shift
122+ fi
65123
66124if [ " $1 " = " --server" ]; then
67125 /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
0 commit comments