-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[GSoC 2017] DeepGaze1 + Discriminant Saliency + BackgroundContrast #1252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Masterqsx
wants to merge
47
commits into
opencv:4.x
Choose a base branch
from
Masterqsx:saliency_shengxin_gsoc2017
base: 4.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
4aa9ae3
start of DeepGaze1 Module, aim to realize basic functionality, code s…
Masterqsx ef88359
realize DeepGaze1 training and be able to generate visually good sali…
Masterqsx 994e6b1
training part improved
Masterqsx ee5be35
implementation tested
Masterqsx 80ac5c0
fix bugs when compile with contrilib
Masterqsx af4fc83
add auc and visualize function
Masterqsx a15d257
remove hard coded size
Masterqsx 6a3260d
remove learning rate hard coding
Masterqsx ab9c2f1
remove extra warning
Masterqsx 3cb0dad
virtual destructor and bugs fixed
Masterqsx ac17ab8
modify cmake_list
Masterqsx 1190d73
cmake_list remove highgui dependency
Masterqsx 2353edd
replace long license header with shorter one
Masterqsx d92236b
make compatible with c++98
Masterqsx 2476dac
update all local change before rebase
Masterqsx 3e0639f
Fixes previous mistaken rebase
Masterqsx c6756c0
redo first pull request
Masterqsx cb25e49
add setting iteration number option to training
Masterqsx d6a2ea5
fix bugs
Masterqsx 14b218f
add MIT1003 dataset connector
Masterqsx ee9f764
fix datasets saliency sample bug
Masterqsx 717645d
fix datasets saliency sample bug
Masterqsx 7d03b3a
fix datasets saliency sample bug
Masterqsx c756d5a
fix datasets saliency sample bug
Masterqsx e3e02b8
add commandparser and more options in deepgaze1 sample
Masterqsx 2cfb0ac
fix indentation tab
Masterqsx f344de4
first push for sp
Masterqsx 2737b56
working on algorithm sp
Masterqsx 7e81b71
roughly finish sp algorithm
Masterqsx f8e2748
refine sp algorithm module
Masterqsx 86e0b2f
add sample of sp module
Masterqsx 55326e4
fix patchGenerator overflow bug
Masterqsx c712d7c
Merge branch 'sp_dev' into saliency_shengxin_gsoc2017
Masterqsx 92f07ad
roughly finish BD algorithm
Masterqsx 6f5d019
change meanCol from bgr to cielab color space
Masterqsx 123e03b
implement aggregated saliency optimization framework
Masterqsx a40edad
finish bd module
Masterqsx 362a8ab
add assert to prevent empty img
Masterqsx 07efdf3
add background weight adjust option
Masterqsx 7c10e2c
Merge branch 'bd_dev' into saliency_shengxin_gsoc2017
Masterqsx 8740be2
fix casting and tab indention
Masterqsx 1ee9867
fix ximgproc casting
Masterqsx 5caf182
change constructors of BackgroundContrast
Masterqsx 228ac29
Merge branch 'master' into saliency_shengxin_gsoc2017
Masterqsx 3ab6109
put comment in header file for implemented three saliency methods
Masterqsx eb20d8f
add alexnet download info in document and offer option to make DeepGa…
Masterqsx 145e295
fix tab problem
Masterqsx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,149 @@ | ||
name: "CaffeNet" | ||
input: "data" | ||
input_dim: 10 | ||
input_dim: 3 | ||
input_dim: 227 | ||
input_dim: 227 | ||
layer { | ||
name: "conv1" | ||
type: "Convolution" | ||
bottom: "data" | ||
top: "conv1" | ||
convolution_param { | ||
num_output: 96 | ||
kernel_size: 11 | ||
stride: 4 | ||
} | ||
} | ||
layer { | ||
name: "relu1" | ||
type: "ReLU" | ||
bottom: "conv1" | ||
top: "conv1" | ||
} | ||
layer { | ||
name: "pool1" | ||
type: "Pooling" | ||
bottom: "conv1" | ||
top: "pool1" | ||
pooling_param { | ||
pool: MAX | ||
kernel_size: 3 | ||
stride: 2 | ||
} | ||
} | ||
layer { | ||
name: "norm1" | ||
type: "LRN" | ||
bottom: "pool1" | ||
top: "norm1" | ||
lrn_param { | ||
local_size: 5 | ||
alpha: 0.0001 | ||
beta: 0.75 | ||
} | ||
} | ||
layer { | ||
name: "conv2" | ||
type: "Convolution" | ||
bottom: "norm1" | ||
top: "conv2" | ||
convolution_param { | ||
num_output: 256 | ||
pad: 2 | ||
kernel_size: 5 | ||
group: 2 | ||
} | ||
} | ||
layer { | ||
name: "relu2" | ||
type: "ReLU" | ||
bottom: "conv2" | ||
top: "conv2" | ||
} | ||
layer { | ||
name: "pool2" | ||
type: "Pooling" | ||
bottom: "conv2" | ||
top: "pool2" | ||
pooling_param { | ||
pool: MAX | ||
kernel_size: 3 | ||
stride: 2 | ||
} | ||
} | ||
layer { | ||
name: "norm2" | ||
type: "LRN" | ||
bottom: "pool2" | ||
top: "norm2" | ||
lrn_param { | ||
local_size: 5 | ||
alpha: 0.0001 | ||
beta: 0.75 | ||
} | ||
} | ||
layer { | ||
name: "conv3" | ||
type: "Convolution" | ||
bottom: "norm2" | ||
top: "conv3" | ||
convolution_param { | ||
num_output: 384 | ||
pad: 1 | ||
kernel_size: 3 | ||
} | ||
} | ||
layer { | ||
name: "relu3" | ||
type: "ReLU" | ||
bottom: "conv3" | ||
top: "conv3" | ||
} | ||
layer { | ||
name: "conv4" | ||
type: "Convolution" | ||
bottom: "conv3" | ||
top: "conv4" | ||
convolution_param { | ||
num_output: 384 | ||
pad: 1 | ||
kernel_size: 3 | ||
group: 2 | ||
} | ||
} | ||
layer { | ||
name: "relu4" | ||
type: "ReLU" | ||
bottom: "conv4" | ||
top: "conv4" | ||
} | ||
layer { | ||
name: "conv5" | ||
type: "Convolution" | ||
bottom: "conv4" | ||
top: "conv5" | ||
convolution_param { | ||
num_output: 256 | ||
pad: 1 | ||
kernel_size: 3 | ||
group: 2 | ||
} | ||
} | ||
layer { | ||
name: "relu5" | ||
type: "ReLU" | ||
bottom: "conv5" | ||
top: "conv5" | ||
} | ||
layer { | ||
name: "pool5" | ||
type: "Pooling" | ||
bottom: "conv5" | ||
top: "pool5" | ||
pooling_param { | ||
pool: MAX | ||
kernel_size: 3 | ||
stride: 2 | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
modules/datasets/include/opencv2/datasets/saliency_mit1003.hpp
This file contains hidden or 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,47 @@ | ||
// This file is part of OpenCV project. | ||
// It is subject to the license terms in the LICENSE file found in the top-level directory | ||
// of this distribution and at http://opencv.org/license.html. | ||
|
||
#ifndef OPENCV_DATASETS_SALIENCY_MIT1003_HPP | ||
#define OPENCV_DATASETS_SALIENCY_MIT1003_HPP | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "opencv2/datasets/dataset.hpp" | ||
|
||
#include <opencv2/core.hpp> | ||
#include <opencv2/imgproc.hpp> | ||
#include <opencv2/highgui.hpp> | ||
|
||
namespace cv | ||
{ | ||
namespace datasets | ||
{ | ||
|
||
//! @addtogroup datasets_saliency | ||
//! @{ | ||
|
||
struct SALIENCY_mit1003obj : public Object | ||
{ | ||
int id; | ||
std::string name; | ||
Mat img; | ||
Mat fixMap; | ||
Mat fixPts; | ||
}; | ||
|
||
class CV_EXPORTS SALIENCY_mit1003 : public Dataset | ||
{ | ||
public: | ||
virtual void load(const std::string &path) = 0; | ||
virtual std::vector<std::vector<Mat> > getDataset() = 0; | ||
static Ptr<SALIENCY_mit1003> create(); | ||
}; | ||
|
||
//! @} | ||
|
||
} | ||
} | ||
|
||
#endif |
This file contains hidden or 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,29 @@ | ||
// This file is part of OpenCV project. | ||
// It is subject to the license terms in the LICENSE file found in the top-level directory | ||
// of this distribution and at http://opencv.org/license.html. | ||
|
||
|
||
#include <opencv2/highgui.hpp> | ||
#include "opencv2/datasets/saliency_mit1003.hpp" | ||
#include <vector> | ||
#include <string> | ||
|
||
using namespace std; | ||
using namespace cv; | ||
using namespace cv::datasets; | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
if (argc < 2) return 0; | ||
|
||
Ptr<SALIENCY_mit1003> datasetConnector = SALIENCY_mit1003::create(); | ||
datasetConnector->load(argv[1]); | ||
vector<vector<Mat> > dataset(datasetConnector->getDataset()); //dataset[0] is original img, dataset[1] is fixMap, dataset[2] is fixPts | ||
//You can use mit1003 dataset do what ever you want | ||
for ( unsigned i = 0; i < dataset[0].size(); i++) | ||
{ | ||
imshow("img", dataset[0][i]); | ||
waitKey(0); | ||
} | ||
return 0; | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -96,4 +96,4 @@ int main(int argc, char *argv[]) | |
|
||
getchar(); | ||
return 0; | ||
} | ||
} |
This file contains hidden or 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,83 @@ | ||
// This file is part of OpenCV project. | ||
// It is subject to the license terms in the LICENSE file found in the top-level directory | ||
// of this distribution and at http://opencv.org/license.html. | ||
|
||
#include "opencv2/datasets/saliency_mit1003.hpp" | ||
#include "opencv2/datasets/util.hpp" | ||
|
||
namespace cv | ||
{ | ||
namespace datasets | ||
{ | ||
|
||
using namespace std; | ||
|
||
class SALIENCY_mit1003Imp : public SALIENCY_mit1003 | ||
{ | ||
public: | ||
SALIENCY_mit1003Imp() {} | ||
virtual ~SALIENCY_mit1003Imp() {} | ||
|
||
virtual void load(const string &path); | ||
virtual vector<vector<Mat> > getDataset(); | ||
|
||
private: | ||
void loadDataset(const string &path); | ||
}; | ||
|
||
void SALIENCY_mit1003Imp::load(const string &path) | ||
{ | ||
loadDataset(path); | ||
} | ||
|
||
void SALIENCY_mit1003Imp::loadDataset(const string &path) | ||
{ | ||
train.push_back( vector< Ptr<Object> >() ); | ||
test.push_back( vector< Ptr<Object> >() ); | ||
validation.push_back( vector< Ptr<Object> >() ); | ||
|
||
string imgPath( path + "/ALLSTIMULI/" ); | ||
string fixPath( path + "/ALLFIXATIONMAPS/" ); | ||
|
||
vector<string> imgNames; | ||
|
||
getDirList( imgPath, imgNames ); | ||
for ( unsigned i = 0; i < imgNames.size(); i++ ) | ||
{ | ||
Ptr<SALIENCY_mit1003obj> curr( new SALIENCY_mit1003obj ); | ||
curr->name = imgNames[i].substr( 0, imgNames[i].find_first_of('.') ); | ||
curr->id = i; | ||
curr->img = imread( imgPath + curr->name + ".jpeg" ); | ||
curr->fixMap = imread( fixPath + curr->name + "_fixMap.jpg", 0 ); | ||
curr->fixPts = imread( fixPath + curr->name + "_fixPts.jpg", 0 ); | ||
if ( curr->img.empty() || curr->fixMap.empty() || curr->fixPts.empty() ) continue; | ||
train.back().push_back(curr); | ||
test.back().push_back(curr); | ||
validation.back().push_back(curr); | ||
} | ||
|
||
} | ||
|
||
Ptr<SALIENCY_mit1003> SALIENCY_mit1003::create() | ||
{ | ||
return Ptr<SALIENCY_mit1003Imp>(new SALIENCY_mit1003Imp); | ||
} | ||
|
||
vector<vector<Mat> > SALIENCY_mit1003Imp::getDataset() | ||
{ | ||
vector<vector<Mat> > res = vector<vector<Mat> >( 3, vector<Mat>() ); | ||
for ( unsigned i = 0; i < train.size() ;i++ ) | ||
{ | ||
for ( unsigned j = 0; j < train[i].size() ;j++ ) | ||
{ | ||
Ptr<SALIENCY_mit1003obj> curr(static_cast<SALIENCY_mit1003obj *>(train[i][j].get())); | ||
res[0].push_back( curr->img ); | ||
res[1].push_back( curr->fixMap ); | ||
res[2].push_back( curr->fixPts ); | ||
} | ||
} | ||
return res; | ||
} | ||
|
||
} | ||
} |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you put the modified prototxt to the unrelated module?