Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named 'detectron2' #13

Open
nikuson opened this issue Nov 18, 2023 · 2 comments
Open

No module named 'detectron2' #13

nikuson opened this issue Nov 18, 2023 · 2 comments

Comments

@nikuson
Copy link

nikuson commented Nov 18, 2023

Despite the fact that I cloned the detectoron2 repository

Traceback (most recent call last):
File "D:\Python\VisionGRIT\GRiT\demo.py", line 9, in
from detectron2.config import get_cfg
ModuleNotFoundError: No module named 'detectron2'

@mattmazzola
Copy link

mattmazzola commented Jan 3, 2024

I am also having trouble with the installation. The instructions don't appear to be up to date with the repository contents.

However, your statement

Despite the fact that I cloned the detectoron2 repository

Merely cloning the repository would not be enough.
See: https://github.com/JialianW/GRiT/blob/master/docs/INSTALL.md#installation-example

You clone, navigate to repo directory, then run pip install -e .

However, when I tried that there are issues with compiling binaries using ninja.
I was able to install detectron using prebuilt here: https://github.com/facebookresearch/detectron2/blob/main/INSTALL.md
However, now I am trying to see how to install centernet

A copy of CenterNet2 seems to exist in this repository here however, it's INSTALL instructions mention detectron2 again, and it includes a yet another copy of detectron2 making it seem like the need to clone dectron2 is old instruction

    ninja: build stopped: subcommand failed.
    Traceback (most recent call last):
      File "/home/vscode/miniconda3/envs/grit/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1666, in _run_ninja_build
        subprocess.run(
      File "/home/vscode/miniconda3/envs/grit/lib/python3.8/subprocess.py", line 516, in run
        raise CalledProcessError(retcode, process.args,
    subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.
...

RuntimeError: Error compiling objects for extension

Build tool versions

cmake version 3.16.3
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
ninja 1.11.1.git.kitware.jobserver-1

Maybe there are prebuilts for centernet

@mattmazzola
Copy link

I wanted to add some more information.

I think the instructions below are out of date

git clone https://github.com/facebookresearch/detectron2.git
cd detectron2
git checkout cc87e7ec
pip install -e .

The GRiT repo now directly includes a copy of detectron2 with centernet project copied
image

I think the updated instructions would be something like:

Clone Repo

git clone https://github.com/JialianW/GRiT.git
cd GRiT
pip install -r requirements.txt

Install included version of detectron

cd third_party/CenterNet2
pip install -e .
cd ../..

Also, I previously mistakenly though centernet was its own package; however, center module is explicitly added to the path here:

GRiT/demo.py

Lines 13 to 14 in 39b33db

sys.path.insert(0, 'third_party/CenterNet2/projects/CenterNet2/')
from centernet.config import add_centernet_config

So after installing the copy of detectron within CenterNet2 it should work
Hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants