Spaces:
Runtime error
Startup fails: mixed OpenCV install — cv2.dnn has no attribute DictValue
This Space fails at startup with:
AttributeError: module 'cv2.dnn' has no attribute 'DictValue'
raised at cv2/typing/__init__.py (LayerId = cv2.dnn.DictValue), reached from app.py via caption_anything/model.py's import cv2.
The installed OpenCV is internally inconsistent: the cv2/typing layer comes from a much newer OpenCV than the compiled cv2.dnn binary it runs against. That happens when more than one OpenCV flavour (for example opencv-python plus a headless or contrib build pulled in by another dependency) is installed into the same environment and their files overwrite each other. requirements.txt pins opencv-python==4.5.5.64, but something in the install brings a second, newer cv2 typing layer on top of it.
Fix: pin exactly one consistent OpenCV build and make sure no second flavour is installed — for example a single line such as opencv-python==4.10.0.84 in requirements.txt, with any other opencv-* requirement removed. The check after rebuilding: python -c "import cv2; print(cv2.__version__); cv2.dnn.DictValue" should print a version and the attribute instead of raising.