Coder Social home page Coder Social logo

csd-rfcn's Introduction

By Jisoo Jeong, Seungeui Lee, Jee-soo Kim, Nojun Kwak


Updated guide for running on off-the-shelf Ubuntu 18.04

Preparing AWS instances

Launch standard Ubuntu 18.04 (spot) instance with at least 200 GB of storage.

Then run:

# Prepare environment
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt-get install nvidia-driver-418 gcc-6 g++-6
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 10

# Download CUDA
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/1/cuda_9.0.176.1_linux-run
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/2/cuda_9.0.176.2_linux-run
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/3/cuda_9.0.176.3_linux-run
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/4/cuda_9.0.176.4_linux-run

# Install
chmod +x cuda*
sudo sh cuda_9.0.176_384.81_linux-run --verbose --silent --toolkit --override
sudo sh cuda_9.0.176.1_linux-run --silent --accept-eula
sudo sh cuda_9.0.176.2_linux-run --silent --accept-eula
sudo sh cuda_9.0.176.3_linux-run --silent --accept-eula
sudo sh cuda_9.0.176.4_linux-run --silent --accept-eula

# Add to PATH
sudo sh -c "echo '/usr/local/cuda-9.0/lib64' >> /etc/ld.so.conf"
sudo ldconfig

# Here must intervene manually
vim .bashrc

# Add the following:
export PATH=/usr/local/cuda-9.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH

source .bashrc

# Download CUDNN
wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7_7.6.5.32-1+cuda9.0_amd64.deb
wget https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7-dev_7.6.5.32-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7_7.6.5.32-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda9.0_amd64.deb

# Get Conda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

# Here must intervene manually, agree to set up Conda in the very end
sh Miniconda3-latest-Linux-x86_64.sh

# Reboot to finish CUDA installation
sudo reboot

CSD-RFCN config

# Env
conda create -n pytorch0.4 python=3.6
conda activate pytorch0.4
conda install pytorch=0.4.0 cuda90 -c pytorch

# Get code
git clone https://github.com/soo89/CSD-RFCN
pip install -r requirements.txt
pip install scipy==1.1.0 scikit-image torchvision==0.1.6 Cython

# Compile CUDA code
cd CSD-RFCN/lib

# Manual intervention: see https://github.com/princewang1994/R-FCN.pytorch#compilation
vim make.sh
# Configure your arch etc.

sh make.sh

# Download VOC data
cd ~
mkdir data
git clone https://github.com/amdegroot/ssd.pytorch
sh ssd.pytorch/data/scripts/VOC2007.sh ~/data
sh ssd.pytorch/data/scripts/VOC2012.sh ~/data
rm -rf ssd.pytorch

# Link data (here I use /home/ubuntu/data, note: must use absolute path)
sed -i 's/\/home\/soo\/data/\/home\/ubuntu\/data/g' lib/model/utils/config.py

# Download resnet
mkdir pretrained_model && cd pretrained_model
pip install gdown
gdown https://drive.google.com/uc?id=1I4Jmh2bU6BJVnwqfg5EDe8KGGdec2UE8
mv resnet101_caffe.pth resnet101_rcnn.pth

Now, change some lines as advised here (both of the two comments): jwyang/faster-rcnn.pytorch#147 (comment)

Then in /lib/model/rfcn/rfcn_consistency.py in lines 111, 144, 156 replace int(semi_check) with int(semi_check.sum()).

Finally, you are ready to run this!

Outcome using one V100 w/ 16GB

Even reducing images to 100x100px and batch_size to 16 (from 256) I get out-of-memory error. (most of modifications in config.py are unnecessary, only data path should be changed given you have enough memory)


Installation & Preparation

We experimented with CSD using the RFCN pytorch framework. To use our model, complete the installation & preparation on the RFCN pytorch homepage

Check list

check DATA_DIR in '/lib/model/utils/config.py'

Supervised learning

python train_rfcn.py

CSD training

python train_csd.py

Evaluation

python test_net.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.