-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cassiePython
committed
Aug 6, 2019
1 parent
4485056
commit 30e747f
Showing
25 changed files
with
1,911 additions
and
2 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,109 @@ | ||
# RCNN | ||
This is a Implementation of R-CNN | ||
# Implementation of R-CNN | ||
|
||
This is a Implementation of R-CNN. (R-CNN: Regions with Convolutional Neural Network Features) | ||
|
||
## Prerequisites | ||
- Python 3.5 | ||
- Pytorch 0.4.1 | ||
- sklearn 0.18.1 | ||
- cv2 3.4.0 | ||
|
||
You can run the code in Windows/Linux with CPU/GPU. | ||
|
||
## Dataset | ||
|
||
For simplicity, rather than use PASCAL VOC 2012 dataset, I choose a samll dataset 17flowers. It can be downloaded from my Google Drive: | ||
|
||
https://drive.google.com/open?id=1qAkLZ-Wa8mca2xz-RZI3XW1Syjk2JfOB | ||
|
||
## Structure | ||
|
||
The project is structured as follows: | ||
|
||
``` | ||
├── checkpoints/ | ||
├── data/ | ||
| ├── dataset_factory.py | ||
| ├── dataset_factory.py | ||
├── generate/ | ||
├── loss/ | ||
| ├── losses.py | ||
├── models/ | ||
| ├── model_factory.py | ||
| ├── models.py | ||
├── networks/ | ||
| ├── network_factory.py | ||
| ├── networks.py | ||
├── options/ | ||
| ├── base_options.py | ||
| ├── test_options.py | ||
| ├── train_options.py | ||
├── sample_dataset/ | ||
| ├── 2flowers | ||
| ├── 17flowers | ||
│ ├── fine_tune_list.txt | ||
| ├── train_list.txt | ||
├── utils/ | ||
| ├── selectivesearch.py | ||
| ├── util.py | ||
├── evaluate.py | ||
├── train_step1.py | ||
├── train_step2.py | ||
├── train_step3.py | ||
├── train_step4.py | ||
``` | ||
|
||
## Getting started | ||
|
||
### Supervised Train | ||
|
||
In this step, we use pre-trained AlexNet of Pytorch and train it using 17flowers dataset. | ||
|
||
``` | ||
$ python train_step1.py | ||
``` | ||
|
||
You can directly run it with default parameters. | ||
|
||
### Finetune | ||
|
||
In this step, we finetune the model on the 2flowers dataset. | ||
|
||
``` | ||
$ python train_step2.py --batch_size 128 --load_alex_epoch 100 --options_dir finetune | ||
``` | ||
|
||
Here we use the pre-trained AlexNet with 100 training epoch in the first step. "Options_dir" decides where to save parameters. | ||
|
||
### Train SVM | ||
|
||
In this step, we use features extracted from the last step to train SVMs. As stated in the paper, class-specific SVMs are trained in this step. Here there are two SVMs. | ||
|
||
``` | ||
$ python train_step3.py --load_finetune_epoch 100 --options_dir svm | ||
``` | ||
|
||
Here we adopt the finetuned AlexNet with 100 epoch in last step as feature extracter. | ||
|
||
### Box Regression | ||
|
||
In this step, we train a regression network to refine bounding boxes. | ||
|
||
``` | ||
$ python train_step4.py --decay_rate 0.5 --options_dir regression --batch_size 512 | ||
``` | ||
|
||
### Evaluate | ||
|
||
``` | ||
$ python evaluate.py --load_finetune_epoch 100 --load_reg_epoch 40 --img_path ./sample_dataset/2flowers/jpg/1/image_1281.jpg | ||
``` | ||
|
||
 | ||
|
||
## References | ||
|
||
- Selective-search: https://github.com/AlpacaDB/selectivesearch | ||
- R-CNN with Tensorflow: https://github.com/bigbrother33/Deep-Learning | ||
|
||
Many codes related to image proposals are copied directly from "R-CNN with Tensorflow", and this project has shown more details about R-CNN in chinese. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
|
||
class DatasetFactory: | ||
def __init__(self): | ||
pass | ||
|
||
@staticmethod | ||
def get_by_name(dataset_name, opt): | ||
if dataset_name == 'AlexnetDataset': | ||
from data.datasets import AlexnetDataset | ||
dataset = AlexnetDataset(opt) | ||
elif dataset_name == 'FinetuneDataset': | ||
from data.datasets import FinetuneDataset | ||
dataset = FinetuneDataset(opt) | ||
elif dataset_name == 'SVMDataset': | ||
from data.datasets import SVMDataset | ||
dataset = SVMDataset(opt) | ||
elif dataset_name == 'RegDataset': | ||
from data.datasets import RegDataset | ||
dataset = RegDataset(opt) | ||
else: | ||
raise ValueError("Dataset [%s] not recognized." % dataset_name) | ||
|
||
print('Dataset {} was created'.format(dataset.name)) | ||
return dataset | ||
|
||
class DatasetBase: | ||
def __init__(self, opt): | ||
self._name = 'BaseDataset' | ||
self._root = opt.data_dir | ||
self._opt = opt | ||
|
||
@property | ||
def name(self): | ||
return self._name | ||
|
||
@property | ||
def path(self): | ||
return self._root |
Oops, something went wrong.