Skip to content

vc-nju/drfi_python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DRFI-python

Python realization for Saliency Object Detection: A Discriminative Regional Feature Integration Approach.

Preview

Origin_photo Saliency_map

Feature

drfi_python is a python version for the paper mentioned above.

Some reasons you might be interested in our realization:

  1. Comparing to deep learning, it's a good traditional way to realize saliency object detection.
  2. The model is related to graph theory, multi-level segmentation and random forest.
  3. 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.

Requirements

  • python 3.x
  • opencv 3.4
  • scikit-image 0.14
  • scikit-learn 0.20

Installation

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/

Test Zoo

Let's take a look at a quick example.

  1. 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
  1. 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)
  1. Running test using python3:
python3 test.py
  1. Origin photo and its Saliency map are below:

Training

  1. 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]
  1. Running train using python3:
python3 train.py

Validation

  1. 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]
  1. Running validation using python3:
python3 val.py

Releases

No releases published

Packages

No packages published

Languages