Coder Social home page Coder Social logo

drfi_python's Introduction

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

drfi_python's People

Contributors

lizhihao6 avatar moonjian avatar

Watchers

 avatar

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.