Skip to content

requirements.txt: dataset_init.py cannot run, and csrt is unavailable #16

Description

@rakhimovv

Two problems, one of which blocks step 2 of the README for every new user

1. dataset_init.py cannot run from a fresh install. It imports huggingface_hub at line 9, and requirements.txt does not declare it. So pip install -r requirements.txt followed by the README's own python dataset_init.py --output-dir ./dataset_VR fails with ModuleNotFoundError. matplotlib is undeclared too (imported by games/maze3d/main.py, games/maze3d/adapter.py, games/sokoban/board.py).

2. The declared environment cannot run --tracker-type csrt — the tracker README:21 names for reproducing the paper's results. extractor.py:417 reaches for cv2.TrackerCSRT_create, which ships only in a contrib OpenCV build, while requirements.txt:6 declares plain opencv-python. _create_tracker() falls through every branch, returns None, and extraction raises RuntimeError: 无法创建跟踪器,请安装 opencv-contrib-python — the message already names the right package.

Swapping that pin to opencv-contrib-python is not the fix, though, which is the part worth knowing: rembg>=2.0.68 (line 19, under # Image processing (AutoEnv)) depends on opencv-python-headless, so a second wheel lands in the same cv2 namespace and which one wins depends on install order.

Measured

Fresh venvs, Python 3.10, checking hasattr(cv2, 'TrackerCSRT_create'):

environment wheels installed CSRT
opencv-python + rembgwhat requirements.txt produces today opencv-python, opencv-python-headless No
opencv-contrib-python + rembg — the naive one-line fix opencv-contrib-python, opencv-python-headless No
rembg first, then opencv-contrib-python same two Yes (order-dependent)
a single ad-hoc pip install opencv-contrib-python rembg same two Yes (order-dependent)
opencv-contrib-python-headless + rembg opencv-contrib-python-headless, opencv-python-headless Yes
same, reverse install order same two Yes
full requirements.txt minus the two AutoEnv lines, with opencv-contrib-python opencv-contrib-python only Yes

The outcome depends on the install invocation, not only on the wheel set: what fails is the one that matters — editing line 6 and re-running pip install -r requirements.txt.

Also checked directly: plain opencv-python at both 4.8.0.76 (the declared floor) and 4.10.0.84 reports hasattr(cv2, 'TrackerCSRT_create') == False and has no cv2.legacy, so none of the versions I tested across the declared range provides it.

Suggested fix — one line

-opencv-python>=4.8.0
+opencv-contrib-python-headless>=4.8.0

plus matplotlib and huggingface-hub.

opencv-contrib-python-headless is the only candidate that survives rembg in both install orders, and it needs no restructuring of the file. The headless build drops only the GUI functions, and there is no imshow, namedWindow, waitKey, destroyAllWindows or createTrackbar anywhere in the tree, so nothing in the repo uses what it leaves out.

If you would rather keep a GUI-capable build, the alternative is to move rembg / onnxruntime-gpu out of requirements.txt — they are already labelled # Image processing (AutoEnv), i.e. they belong to the skin-generation tool rather than to the benchmark pipeline. I verified that core file (36 requirement lines, 61 installed distributions, with opencv-contrib-python) installs clean and provides CSRT.

Happy to send either shape as a PR — say which and it is a two-minute change.

For reference, OpenCV's own guidance is that only one of these wheels may be installed: "Do not install multiple different packages in the same environment. There is no plugin architecture: all the packages use the same namespace (cv2)." (opencv-python README) — which is why the rembg dependency is awkward however it is resolved.

Environment

Python 3.10.20, Linux, measured at 89b29a9.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions