JialianW / GRiT

GRiT: A Generative Region-to-text Transformer for Object Understanding (https://arxiv.org/abs/2212.00280)
MIT License
293 stars 30 forks source link

No module named 'detectron2' #13

Open nikuson opened 10 months ago

nikuson commented 10 months ago

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 commented 8 months ago

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 commented 8 months ago

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: https://github.com/JialianW/GRiT/blob/39b33dbc0900e4be0458af14597fcb1a82d933bb/demo.py#L13-L14

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