superdsm.dsmcfg
- class superdsm.dsmcfg.DSM_Config
Bases:
StageFetches the hyperparameters from the
dsmnamespace and provides them as an output.The purpose of this stage is to provide the hyperparameters from the
dsmnamespace as the outputdsm_cfg, which is a dictionary of the hyperparameters without the leadingdsm/namespace prefix. This enables any stage to access the DSM-related hyperparameters, like theC2F_RegionAnalysisandGlobalEnergyMinimizationstages, without having to access thedsmhyperparameter namespace. Refer to Inputs and outputs for more information on the available inputs and outputs.Hyperparameters
The following hyperparameters are fetched:
dsm/cachesizeThe maximum number of entries used for caching during convex programming. This concerns invocations of the callback function
Fused by the cvxopt solver for nonlinear problems. Defaults to 1.dsm/cachetestThe test function to be used for cache testing. If
None, thennumpy.array_equalwill be used. Using other functions likenumpy.allclosehas shown to introduce numerical instabilities. Defaults toNone.dsm/sparsity_tolAbsolute values below this threshold will be treated as zeros during optimization. Defaults to 0.
dsm/initEither a function or a string. If this is function, then it will be called to determine the initialization, and the dimension of the vector \(\xi\) will be passed as a parameter. If this is a string, then the initialization corresponds to the result of convex programming using elliptical models (if set to
elliptical, see Supplemental Material 6 of Kostrykin and Rohr, TPAMI 2023) or a zeros vector of is used (otherwise). Defaults toelliptical.dsm/smooth_amountCorresponds to \(\sigma_G\) described in Deformable shape models. Defaults to 10, or to
AF_smooth_amount × scaleif computed automatically (forced to \(\geq 4\) andAF_smooth_amountdefaults to 0.2).dsm/smooth_subsampleCorresponds to the amount of sub-sampling used to obtain the matrix \(\tilde G_\omega\) in Kostrykin and Rohr (TPAMI 2023, Section 3.3). Defaults to 20, or to
AF_smooth_subsample × scaleif computed automatically (forced to \(\geq 8\) andAF_smooth_subsampledefaults to 0.4).dsm/epsilonCorresponds to the constant \(\epsilon\) which is used for the smooth approximation of the regularization term \(\|\xi\|_1 \approx \mathbb 1^\top_\Omega \sqrt{\xi^2 + \epsilon} - \sqrt{\epsilon} \cdot \#\Omega\) (see Supplemental Material 2 of Kostrykin and Rohr, TPAMI 2023). Defaults to 1.
dsm/alphaGoverns the regularization of the deformations and corresponds to \(\alpha\) described in Convex energy minimization. Increasing this value leads to a smoother segmentation result. Defaults to 0.5, or to
AF_alpha × scale^2if computed automatically (whereAF_alphacorresponds to \(\alpha_\text{factor}\) in Kostrykin and Rohr, TPAMI 2023, and defaults to 5e-4).dsm/scaleFixed factor used during convex programming to slightly improve numerical stabilities. Defaults to 1000.
dsm/gaussian_shape_multiplierThe Gaussian function with standard deviation \(\sigma_G\) used to construct the block Toeplitz matrix \(G_\omega\) is cut off after \(4 \sigma_G\) multiplied by this value (see Deformable shape models). Defaults to 2.
dsm/smooth_mat_dtypeA string indicating the data type used for the matrix \(G_\omega\). Defaults to
float32.dsm/smooth_mat_max_allocationsMaximum number of simultaneous allocation of the matrix \(\tilde G_\omega\) during parallel processing (see Section 3.3 of Kostrykin and Rohr, TPAMI 2023, each allocation might require a considerable amount of system memory).
dsm/background_marginGoverns the amount of image background included in the obtained image region. This is the width of the “stripe” of background retained around each connected foreground region (in pixels). See Supplemental Material 6 of Kostrykin and Rohr (TPAMI 2023) for details, however, due to a transmission error, the threshold \(\sigma_G\) in Eq. (S11) was misstated by a factor of 2 (the correct threshold is \(2\sigma_G\)). Defaults to 20, or to
AF_background_margin × scaleif computed automatically (forced to \(\geq 8\) andAF_background_margindefaults to 0.4).dsm/cp_timeoutThe maximum run time of convex programming for each object (in seconds). The convex optimization will be interrupted if it takes longer than that (the
cvxprog()function will report the statusfallbackin this case). If this is set toNone, the run time is not limited. Defaults to 300 (i.e. 5 minutes).
- ENABLED_BY_DEFAULT = True
- configure_ex(scale, radius, diameter)
Automatically computes the default configuration entries which are dependent on the scale of the objects in an image, using explicit values for the expected radius and diameter of the objects.
- Parameters:
scale – The average scale of objects in the image.
radius – The average radius of objects in the image.
diameter – The average diameter of objects in the image.
- Returns:
Dictionary of configuration entries of the form:
{ 'key': (factor, default_user_factor), }
Each hyperparameter
keyis associated with a new hyperparameterAF_key. The value of the hyperparameterkeywill be computed as the product offactorand the value of theAF_keyhyperparameter, which defaults todefault_user_factor. The value given forfactoris usuallyscale,radius,diameter, or a polynomial thereof. Another dictionary may be provided as a third component of the tuple, which can specify atype,min, andmaxvalues.
- process(input_data, cfg, out, log_root_dir)
Runs this pipeline stage.
- Parameters:
input_data – Dictionary of the inputs declared by this stage.
cfg – The hyperparameters to be used by this stage.
out – An instance of an
Outputsub-class,'muted'if no output should be produced, orNoneif the default output should be used.log_root_dir – Path of directory where log files will be written, or
Noneif no log files should be written.
- Returns:
Dictionary of the outputs declared by this stage.