Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Cresson Remi
LSGRM
Commits
4934c345
Commit
4934c345
authored
Dec 11, 2018
by
Gaetano Raffaele
Browse files
Working on the resume option to resume segmentation after fail or abort.
parent
e22de7db
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/otbLSGRM.cxx
View file @
4934c345
...
...
@@ -112,8 +112,17 @@ private:
AddChoice
(
"tiling.none"
,
"No tiling layout"
);
AddParameter
(
ParameterType_Int
,
"memory"
,
"Restrict memory use (mb)"
);
MandatoryOff
(
"memory"
);
AddParameter
(
ParameterType_Bool
,
"resume"
,
"Activate resume mode"
);
SetDefaultParameterBool
(
"resume"
,
false
);
AddParameter
(
ParameterType_Int
,
"resume.tilerow"
,
"Starting tile row in resume mode"
);
AddParameter
(
ParameterType_Int
,
"resume.tilecol"
,
"Starting tile column in resume mode"
);
SetDefaultParameterInt
(
"resume.tilerow"
,
0
);
SetDefaultParameterInt
(
"resume.tilecol"
,
0
);
//MandatoryOff("resume");
//MandatoryOff("resume.tilex");
//MandatoryOff("resume.tiley");
}
void
DoUpdateParameters
()
...
...
@@ -224,6 +233,12 @@ private:
otbAppLogINFO
(
"Setting maximum memory to "
<<
GetParameterInt
(
"memory"
)
<<
" MBytes"
);
controller
->
SetInternalMemoryAvailable
(
GetParameterInt
(
"memory"
));
}
// Resume mode?
if
(
GetParameterBool
(
"resume"
))
{
controller
.
SetResumingMode
(
GetParameterInt
(
"resume.tilerow"
),
GetParameterInt
(
"resume.tilecol"
));
}
// Run the segmentation
controller
->
RunSegmentation
();
...
...
include/lsgrmController.h
View file @
4934c345
...
...
@@ -44,6 +44,9 @@ public:
void
SetSpecificParameters
(
const
SegmentationParameterType
&
params
);
void
SetInputImage
(
ImageType
*
inputImage
);
void
SetInternalMemoryAvailable
(
long
long
unsigned
int
v
);
// expecting a value in Mbytes.
void
SetResumingMode
(
unsigned
int
rRow
,
unsigned
int
rCol
);
void
StopResumingMode
();
/* Accessors */
void
SetTilingModeNone
(){
m_TilingMode
=
LSGRM_TILING_NONE
;
Modified
();};
...
...
@@ -114,6 +117,10 @@ private:
unsigned
int
m_NumberOfFirstIterations
;
// number of iterations in the first step
unsigned
int
m_TileWidth
;
// regular tile width (i.e. not left tiles)
unsigned
int
m_TileHeight
;
// regular tile height (i.e. not bottom tiles)
bool
m_Resuming
;
// True if in resuming mode
unsigned
int
m_ResumeTileRow
;
// X index of starting tile in resume mode
unsigned
int
m_ResumeTileCol
;
// Y index of starting tile in resume mode
/* read-only variables */
LSGRMTilingMode
m_TilingMode
;
// tiling mode (none/user/auto)
...
...
include/lsgrmController.txx
View file @
4934c345
...
...
@@ -18,6 +18,9 @@ Controller<TSegmenter>::Controller()
m_NbTilesY = 0;
m_Threshold = 75;
m_Memory = 0;
m_Resuming = false;
m_ResumeTileRow = 0;
m_ResumeTileCol = 0;
}
...
...
@@ -122,7 +125,12 @@ void Controller<TSegmenter>::RunSegmentation()
m_InputImage->GetLargestPossibleRegion().GetSize()[0],
m_InputImage->GetLargestPossibleRegion().GetSize()[1],
m_InputImage->GetNumberOfComponentsPerPixel(),
isFusion);
isFusion,
m_Resuming,
m_ResumeTileRow,
m_ResumeTileCol);
if (m_Resuming) StopResumingMode();
#ifdef OTB_USE_MPI
GatherUsefulVariables(accumulatedMemory, isFusion);
...
...
@@ -461,5 +469,13 @@ std::vector<std::string> Controller<TSegmenter>::GetTemporaryFilesList()
return list;
}
template<class TSegmenter>
void Controller<TSegmenter>::SetResumingMode(unsigned int rX, unsigned int rY)
{
m_Resuming = true;
m_ResumeTileX = rx;
m_ResumeTileY = ry;
}
} // end of namespace lsgrm
#endif
include/lsgrmGraphOperations.h
View file @
4934c345
...
...
@@ -68,7 +68,10 @@ long long unsigned int RunPartialSegmentation(
const
unsigned
int
imageWidth
,
const
unsigned
int
imageHeight
,
const
unsigned
int
imageBands
,
bool
&
isFusion
);
bool
&
isFusion
,
bool
resume
=
false
,
unsigned
int
rRow
=
0
,
unsigned
int
rCol
=
0
);
template
<
class
TSegmenter
>
void
RemoveUselessNodes
(
ProcessingTile
&
tile
,
...
...
include/lsgrmGraphOperations.txx
View file @
4934c345
...
...
@@ -138,7 +138,10 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::ParamTy
const unsigned int imageWidth,
const unsigned int imageHeight,
const unsigned int imageBands,
bool& isFusion)
bool& isFusion,
bool resume,
unsigned int rRow,
unsigned int rCol)
{
long long unsigned int accumulatedMemory = 0;
isFusion = false;
...
...
@@ -155,6 +158,18 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::ParamTy
if (MyTurn(row*nbTilesX + col))
#endif
{
// If resume mode, get accumulated memory on previous tiles
if (resume && (row*nbTilesX+col) < (rRow*nbTilesX+rCol) ) {
// Load the graph
std::cout << "\tResuming graph..." << std::endl;
TSegmenter segmenter;
ReadGraph<TSegmenter>(segmenter.m_Graph, currentTile.nodeFileName, currentTile.edgeFileName);
// Retrieve the amount of memory to store this graph
std::cout << "\tGet graph memory..." << std::endl;
accumulatedMemory += segmenter.GetGraphMemory();
continue;
}
// Get the current tile
std::cout << "Processing tile " << row << ", " << col << std::endl;
ProcessingTile currentTile = tiles[row*nbTilesX + col];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment