Using this repository, one can generate predictions for the orthomosaics that were split using ImageSplitter. If you have not already split your orthomosaics, go to ImageSplitter to do so. Please follow the directions below carefully to generate accurate predictions.
First, clone the code
git clone https://github.com/GSteinberg/faster-rcnn.pytorch.git
Then, create a folder where you will put your split orthomasics:
cd faster-rcnn.pytorch && mkdir images
and the folder where you will put your pretrained model:
cd faster-rcnn.pytorch && mkdir -p models/res101/pascal_voc
and lastly, the folder where your generated predictions will be outputted:
cd faster-rcnn.pytorch && mkdir -p output/csvs
A more detailed walkthrough of the intallation process can be found at this blog by ankur6ue.
First, make sure your environment is set up with these three main prerequisites.
- Python 2.7 or 3.6
- Pytorch 1.0 or higher
- CUDA 8.0 or higher (optional)
Then, install all the python dependencies using pip:
pip install -r requirements.txt
or using conda (the below command will install the cpu-only version of pytorch and will not include any CUDA related packages. If you plan to run this with CUDA, you must install the CUDA compatible version of PyTorch and any CUDA packages on your own):
conda create --name <env> --file conda_requirements.txt
Compile the cuda dependencies using following simple commands:
cd lib
python setup.py build develop
It will compile all the modules you need, including NMS, ROI_Pooling, ROI_Align and ROI_Crop.
As pointed out in this issue, if you encounter errors during the compilation, you may need to export the CUDA path to your environment variable.
To generate predictions on your split orthomoasaics, these are the steps you must follow:
- Move all the images you want to generate predictions on into
images/
- Download the pretrained model here
- Move the pretrained model,
faster_rcnn_1_50_10067.pth
, tomodels/res101/pascal_voc/
- Run the following command to generate predictions
python demo.py --net res101 --checksession 1 --checkepoch 50 \
--checkpoint 10067 --cuda --load_dir models/ \
--crop_size 700 --crop_stride 70
Note: if you are running a cpu-only version of PyTorch, exclude the --cuda
flag from the above command.
You will find the generated coordinate predictions in faster-rcnn.pytorch/output/csvs/
.
This is a forked repository of Jianwei Yang's Faster R-CNN. Most of the code is unchanged meaning that Jianwei Yang and Jiasen Lu, as well as many others, wrote most of this code. I, Gabriel Steinberg, wrote a small percentage of the code that specializes it for detection of landmines and other UXOs in remotely sensed images.
Since most of the code is unchanged, problems one may have with installation or running the code may be solved by searching for your problem in the long list of issues in the original Faster R-CNN repository.
Please note that the original repository is no longer being actively maintained but I will be maintaining this fork for the forseeable future. That means that new issues placed in the original repository may remain unanswered by the original developers (other contributers may answer though) but I will attempt to answer any issue placed in this repository.
@article{jjfaster2rcnn,
Author = {Jianwei Yang and Jiasen Lu and Dhruv Batra and Devi Parikh},
Title = {A Faster Pytorch Implementation of Faster R-CNN},
Journal = {https://github.com/jwyang/faster-rcnn.pytorch},
Year = {2017}
}
@inproceedings{renNIPS15fasterrcnn,
Author = {Shaoqing Ren and Kaiming He and Ross Girshick and Jian Sun},
Title = {Faster {R-CNN}: Towards Real-Time Object Detection
with Region Proposal Networks},
Booktitle = {Advances in Neural Information Processing Systems ({NIPS})},
Year = {2015}
}