Detectron and Segment Anything

Published

Nov 2023

This environment has features the Detectron2 and Segment Anything packages by Facebook Research. For full details about their functionality, be sure to check out their documentation to see if they are right for you.

It is intended as an environment that users can use to test the suitability of these packages without having to find a combination of compatible versions of PyTorch, CUDA and other relevant dependencies.

Once satisfied that this is a good fit for your research, this can be cloned to serve as a basis for a new environment that you control to add any additional specialist packages that you need. Alternatively, these definitions and install scripts can be copied and tailored to your use case.

Executable Path

/apps/mambaforge/envs/detectron-sam/bin/python3 </path/to/script.py>

Activation Path

source /apps/mambaforge/envs/detectron-sam/bin/activate

Environment Definition

Code
!cat /apps/conda-envs/detectron-sam.yml
name: detectron-sam
channels:
  # Add channels as needed for your research packages from most specific to least specific
  - conda-forge
  - pytorch
  - nvidia

dependencies:
  # Required libraries to launch Jupyter Lab jobs
  - jupyter
  - jupyterlab

  # Required libraries to interface with the SLURM queue with Dask
  - dask
  - dask-jobqueue

  # PyTorch
  - pytorch=2.0
  - torchvision=0.15
  - pytorch-cuda=11.7

  # Image Processing
  - opencv
  - pycocotools 
  - matplotlib 
  
  # Compilers and Package managers
  - ninja
  - onnxruntime 
  - onnx
  - pip

Environment Install Script

Code
!cat /apps/conda-envs/install-detectron-sam.sh
mamba env create -f detectron-sam.yml
conda activate detectron-sam
CC=gcc-10 CXX=g++-10 python -m pip install /apps/facebookresearch/detectron2
pip install /apps/facebookresearch/segment-anything

Full Package List

Code
!pip list
Package                   Version
------------------------- ------------------
absl-py                   2.1.0
antlr4-python3-runtime    4.9.3
anyio                     4.1.0
argon2-cffi               23.1.0
argon2-cffi-bindings      21.2.0
arrow                     1.3.0
asttokens                 2.4.1
async-lru                 2.0.4
attrs                     23.1.0
Babel                     2.13.1
beautifulsoup4            4.12.2
black                     24.2.0
bleach                    6.1.0
bokeh                     3.3.1
Brotli                    1.1.0
cached-property           1.5.2
certifi                   2023.11.17
cffi                      1.16.0
charset-normalizer        3.3.2
click                     8.1.7
cloudpickle               3.0.0
coloredlogs               15.0.1
comm                      0.1.4
contourpy                 1.2.0
cycler                    0.12.1
Cython                    3.0.6
cytoolz                   0.12.2
dask                      2023.11.0
dask-jobqueue             0.8.2
debugpy                   1.8.0
decorator                 5.1.1
defusedxml                0.7.1
detectron2                0.6
distributed               2023.11.0
entrypoints               0.4
exceptiongroup            1.2.0
executing                 2.0.1
fastjsonschema            2.19.0
filelock                  3.13.1
flatbuffers               23.5.26
fonttools                 4.45.1
fqdn                      1.5.1
fsspec                    2023.10.0
fvcore                    0.1.5.post20221221
gmpy2                     2.1.2
grpcio                    1.62.0
humanfriendly             10.0
hydra-core                1.3.2
idna                      3.6
importlib-metadata        6.8.0
importlib-resources       6.1.1
iopath                    0.1.9
ipykernel                 6.26.0
ipython                   8.18.1
ipywidgets                8.1.1
isoduration               20.11.0
jedi                      0.19.1
Jinja2                    3.1.2
json5                     0.9.14
jsonpointer               2.4
jsonschema                4.20.0
jsonschema-specifications 2023.11.1
jupyter                   1.0.0
jupyter_client            8.6.0
jupyter-console           6.6.3
jupyter_core              5.5.0
jupyter-events            0.9.0
jupyter-lsp               2.2.1
jupyter_server            2.11.1
jupyter_server_terminals  0.4.4
jupyterlab                4.0.9
jupyterlab_pygments       0.3.0
jupyterlab_server         2.25.2
jupyterlab-widgets        3.0.9
kiwisolver                1.4.5
locket                    1.0.0
lz4                       4.3.2
Markdown                  3.5.2
MarkupSafe                2.1.3
matplotlib                3.8.2
matplotlib-inline         0.1.6
mistune                   3.0.2
mpmath                    1.3.0
msgpack                   1.0.7
munkres                   1.1.4
mypy-extensions           1.0.0
nbclient                  0.8.0
nbconvert                 7.11.0
nbformat                  5.9.2
nest-asyncio              1.5.8
networkx                  3.2.1
notebook                  7.0.6
notebook_shim             0.2.3
numpy                     1.26.2
omegaconf                 2.3.0
onnx                      1.15.0
onnxruntime               1.16.3
opencv-python             4.8.1
overrides                 7.4.0
packaging                 23.2
pandas                    2.1.3
pandocfilters             1.5.0
parso                     0.8.3
partd                     1.4.1
pathspec                  0.12.1
pexpect                   4.8.0
pickleshare               0.7.5
Pillow                    10.1.0
pip                       23.3.1
pkgutil_resolve_name      1.3.10
platformdirs              4.0.0
ply                       3.11
portalocker               2.8.2
prometheus-client         0.19.0
prompt-toolkit            3.0.41
protobuf                  4.24.4
psutil                    5.9.5
ptyprocess                0.7.0
pure-eval                 0.2.2
pyarrow                   14.0.1
pyarrow-hotfix            0.6
pycocotools               2.0.6
pycparser                 2.21
Pygments                  2.17.2
pyparsing                 3.1.1
PyQt5                     5.15.9
PyQt5-sip                 12.12.2
PySocks                   1.7.1
python-dateutil           2.8.2
python-json-logger        2.0.7
pytz                      2023.3.post1
PyYAML                    6.0.1
pyzmq                     25.1.1
qtconsole                 5.5.1
QtPy                      2.4.1
referencing               0.31.1
requests                  2.31.0
rfc3339-validator         0.1.4
rfc3986-validator         0.1.1
rpds-py                   0.13.2
segment-anything          1.0
Send2Trash                1.8.2
setuptools                68.2.2
sip                       6.7.12
six                       1.16.0
sniffio                   1.3.0
sortedcontainers          2.4.0
soupsieve                 2.5
stack-data                0.6.2
sympy                     1.12
tabulate                  0.9.0
tblib                     2.0.0
tensorboard               2.16.2
tensorboard-data-server   0.7.2
termcolor                 2.4.0
terminado                 0.18.0
tinycss2                  1.2.1
toml                      0.10.2
tomli                     2.0.1
toolz                     0.12.0
torch                     2.0.0.post304
torchvision               0.15.2a0+ab7b3e6
tornado                   6.3.3
tqdm                      4.66.2
traitlets                 5.14.0
types-python-dateutil     2.8.19.14
typing_extensions         4.8.0
typing-utils              0.1.0
tzdata                    2023.3
uri-template              1.3.0
urllib3                   2.1.0
wcwidth                   0.2.12
webcolors                 1.13
webencodings              0.5.1
websocket-client          1.6.4
Werkzeug                  3.0.1
wheel                     0.42.0
widgetsnbextension        4.0.9
xyzservices               2023.10.1
yacs                      0.1.8
zict                      3.0.0
zipp                      3.17.0