AttributeError: module 'cv2' has no attribute 'INTER_AREA'
OpenCV INTER_AREA Error
AttributeError: module 'cv2' has no attribute 'INTER_AREA' during initialization, with a traceback ending in controlnet_aux/midas/midas/transforms.py. The server stops before the stream starts.
Cause
opencv 4.13 and newer are built against numpy 2.x. StreamDiffusionTD pins numpy to 1.26.4 because StreamDiffusion and mediapipe both break on numpy 2. When the newer opencv loads against the older numpy the module only partly initializes, so constants like INTER_AREA are never created and controlnet_aux fails on import.
This is usually caused by installing OpenCV packages manually while troubleshooting something else. A clean v0.3.1 install pins opencv to 4.8.1.78 on its own.
Fix (recommended)
Re-run the installer. This does not wipe your venv or re-download models, it re-runs the install phases, one of which removes conflicting opencv variants and reinstalls the pinned version.
cd \StreamDiffusion
venv\Scripts\activate
python -m sd_installer install --cuda cu128
Fix (targeted)
If you do not want the full re-run:
pip uninstall opencv-python opencv-python-headless opencv-contrib-python -y
pip install --no-deps opencv-python==4.8.1.78
The --no-deps matters. Without it pip can pull numpy 2 back in and you end up where you started.
Verify
python -c "import cv2, numpy; print(cv2.__version__, numpy.__version__, cv2.INTER_AREA)"
Expect 4.8.1.78 1.26.4 3.
Notes
repairdoes not currently fix this one. Use a command above instead.verifywill report both StreamDiffusion core and controlnet_aux as failed from this single cause, because StreamDiffusion imports controlnet_aux. One fix clears both, do not chase them separately.- Reported on RTX 5060 and RTX 5080, both CUDA 12.8 installs. It is not specific to your GPU.
- See also the Troubleshooting page.