Python realization for Saliency Object Detection: A Discriminative Regional Feature Integration Approach.
drfi_python is a python version for the paper mentioned above.
Some reasons you might be interested in our realization:
- Comparing to deep learning, it's a good traditional way to realize saliency object detection.
- The model is related to graph theory, multi-level segmentation and random forest.
- Comparing to CPP Version and MATLAB Version, our realization has more extensibilities because of huge python libraries.
We have trained and tested on MSRA-B, and it's auc is 0.923.
- python 3.x
- opencv 3.4
- scikit-image 0.14
- scikit-learn 0.20
git clone https://github.com/vc-nju/drfi_python.git && cd drfi_python
mkdir data && mkdir data/csv && mkdir data/model && mkdir data/result
The pre_train models can be downloaded from Google Drive and BaiduYun(passcode: 65mp). Please copy them to data/model/
Let's take a look at a quick example.
- Make sure you have downloaded the models and copy them to data/model/
Your data/model should be like this:
drfi_python
└───data
└───model
| mlp.pkl
| rf_salience.pkl
| rf_same_region.pkl
- Edit ./test.py module in your project:
# img_path and id can be replaced by yourself.
img_id = 1036
img_path = "data/MSRA-B/{}.jpg".format(img_id)
- Running test using python3:
python3 test.py
- Origin photo and its Saliency map are below:
- Edit ./train.py in your project:
# its is your traning set's img_ids
its = [i for i in range(1, TRAIN_IMGS + 1) if i % 5 != 0]
...
# change "data/MSRA-B/{}.jpg" to your path/to/origin_pic
img_paths = ["data/MSRA-B/{}.jpg".format(i) for i in its]
# change "data/MSRA-B/{}.png" to your path/to/ground_truth_pic
seg_paths = ["data/MSRA-B/{}.png".format(i) for i in its]
- Running train using python3:
python3 train.py
- Edit ./val.py in your project:
# its is your validation set's img_ids
its = [i for i in range(1, TRAIN_IMGS + 1) if i % 5 != 0]
...
# change "data/MSRA-B/{}.jpg" to your path/to/origin_pic
img_paths = ["data/MSRA-B/{}.jpg".format(i) for i in its]
# change "data/MSRA-B/{}.png" to your path/to/ground_truth_pic
seg_paths = ["data/MSRA-B/{}.png".format(i) for i in its]
- Running validation using python3:
python3 val.py