Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM mcr.microsoft.com/devcontainers/base:ubuntu-20.04

SHELL [ "bash", "-c" ]

# update apt and install packages
RUN apt update && \
apt install -yq \
build-essential \
cmake \
dkms \
ffmpeg \
libturbojpeg \
libgl1-mesa-glx \
python3-dev \
ninja-build \
jq \
jp \
tree \
tldr

# add git-lfs and install
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash && \
sudo apt-get install -yq git-lfs && \
git lfs install

############################################
# Setup user
############################################

USER vscode

# Setup conda
RUN cd /tmp && \
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
bash ./Miniconda3-latest-Linux-x86_64.sh -b && \
rm ./Miniconda3-latest-Linux-x86_64.sh
Empty file added .devcontainer/devcontainer.env
Empty file.
76 changes: 76 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"name": "GRiT",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {}
},
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/azure-cli:1": {},
"ghcr.io/azure/azure-dev/azd:0": {},
"ghcr.io/devcontainers/features/powershell:1": {},
"ghcr.io/devcontainers/features/common-utils:2": {},
"ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {},
},
// "forwardPorts": [],
"postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh",
"customizations": {
"vscode": {
"settings": {
"python.analysis.autoImportCompletions": true,
"python.analysis.autoImportUserSymbols": true,
"python.defaultInterpreterPath": "~/miniconda3/envs/grit/bin/python",
"python.formatting.provider": "black",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"isort.check": true,
"dev.containers.copyGitConfig": true,
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "/usr/bin/zsh"
},
},
"[python]": {
}
},
"extensions": [
"aaron-bond.better-comments",
"eamodio.gitlens",
"EditorConfig.EditorConfig",
"foxundermoon.shell-format",
"GitHub.copilot-chat",
"GitHub.copilot",
"lehoanganh298.json-lines-viewer",
"mhutchie.git-graph",
"ms-azuretools.vscode-docker",
"ms-dotnettools.dotnet-interactive-vscode",
"ms-python.black-formatter",
"ms-python.flake8",
"ms-python.isort",
"ms-python.python",
"ms-python.vscode-pylance",
"njpwerner.autodocstring",
"redhat.vscode-yaml",
"stkb.rewrap",
"yzhang.markdown-all-in-one",
"mechatroner.rainbow-csv",
"dotenv.dotenv-vscode",
"alefragnani.Bookmarks"
]
}
},
"mounts": [
],
"runArgs": [
"--gpus",
"all",
// "--ipc",
// "host",
"--ulimit",
"memlock=-1",
"--env-file",
".devcontainer/devcontainer.env"
],
}
49 changes: 49 additions & 0 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
git config --global safe.directory '*'
git config --global core.editor "code --wait"
git config --global pager.branch false

# Activate conda by default
echo "source /home/vscode/miniconda3/bin/activate" >> ~/.zshrc
echo "source /home/vscode/miniconda3/bin/activate" >> ~/.bashrc

# Use grit environment by default
echo "conda activate grit" >> ~/.zshrc
echo "conda activate grit" >> ~/.bashrc

# Activate conda on current shell
source /home/vscode/miniconda3/bin/activate

# Create and activate grit environment
conda create -y -n grit python=3.8
conda activate grit

echo "Installing CUDA..."
# Even though cuda package installs cuda-nvcc, it doesn't pin the same version so we explicitly set both
conda install -y -c nvidia cuda=11.3 cuda-nvcc=11.3

export CUDA_HOME=/home/vscode/miniconda3/envs/grit
echo "export CUDA_HOME=$CUDA_HOME" >> ~/.zshrc
echo "export CUDA_HOME=$CUDA_HOME" >> ~/.bashrc

mkdir -p models
cd models

if [ ! -f grit_b_densecap_objectdet.pth ]; then
echo "Downloading pretrained model..."
wget https://datarelease.blob.core.windows.net/grit/models/grit_b_densecap_objectdet.pth
else
echo "Skipping download, pretrained model already exists."
fi

cd ..

echo "Installing requirements..."
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
pip install -r requirements.txt

cd third_party/CenterNet2
echo "Installing CenterNet2..."
pip install -e .
cd ../..

echo "postCreateCommand.sh completed!"
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

# 4 space indentation
[*.{py,json}]
indent_style = space
indent_size = 4

# 2 space indentation
[*.{md,sh,yaml,yml}]
indent_style = space
indent_size = 2
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
# Flake8 Options: https://flake8.pycqa.org/en/latest/user/options.html#index-of-options
max-line-length = 120
ignore = F541, E501, F841
29 changes: 29 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# https://git-scm.com/docs/gitattributes

# Set the default behavior, in case people don't have core.autocrlf set.
# https://git-scm.com/docs/gitattributes#_end_of_line_conversion
* text=auto

# common python attributes, taken from https://github.com/alexkaratarakis/gitattributes/blob/710900479a2bedeec7003d381719521ffbb18bf8/Python.gitattributes
# Source files
# ============
*.pxd text diff=python
*.py text diff=python
*.py3 text diff=python
*.pyw text diff=python
*.pyx text diff=python
*.pyz text diff=python
*.pyi text diff=python

# Binary files
# ============
*.db binary
*.p binary
*.pkl binary
*.pickle binary
*.pyc binary export-ignore
*.pyo binary export-ignore
*.pyd binary

# Jupyter notebook
*.ipynb text eol=lf
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ _darcs
/projects/*/datasets
/models
/snippet

# Ignore Demo Output
visualization
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,26 @@ the flag `--test-task`. Play it as follows! :star_struck:

### *Output for Dense Captioning (rich descriptive sentences)*

~~~
python demo.py --test-task DenseCap --config-file configs/GRiT_B_DenseCap_ObjectDet.yaml --input demo_images --output visualization --opts MODEL.WEIGHTS models/grit_b_densecap_objectdet.pth
~~~
```bash
python demo.py \
--test-task DenseCap \
--config-file configs/GRiT_B_DenseCap_ObjectDet.yaml \
--input demo_images \
--output visualization/dense_caption \
--opts MODEL.WEIGHTS models/grit_b_densecap_objectdet.pth
```

### *Output for Object Detection (short class names)*

~~~
python demo.py --test-task ObjectDet --config-file configs/GRiT_B_DenseCap_ObjectDet.yaml --input demo_images --output visualization --opts MODEL.WEIGHTS models/grit_b_densecap_objectdet.pth
~~~
```bash
python demo.py \
--test-task ObjectDet \
--config-file configs/GRiT_B_DenseCap_ObjectDet.yaml \
--input demo_images \
--output visualization/object_detection \
--opts MODEL.WEIGHTS models/grit_b_densecap_objectdet.pth
```

Output images will be saved under the `visualization` folder, which looks like:
<p align="center"> <img src='docs/demo.png' align="center"> </p>

Expand Down