mxnet.gluon.data.vision.transforms.CenterCrop¶
-
class
mxnet.gluon.data.vision.transforms.CenterCrop(size, interpolation=1)[source]¶ Crops the image src to the given size by trimming on all four sides and preserving the center of the image. Upsamples if src is smaller than size.
- Parameters
size (int or tuple of (W, H)) – Size of output image.
interpolation (int) – Interpolation method for resizing. By default uses bilinear interpolation. See OpenCV’s resize function for available choices.
- Inputs:
data: input tensor with (Hi x Wi x C) shape.
- Outputs:
out: output tensor with (H x W x C) shape.
Examples
>>> transformer = vision.transforms.CenterCrop(size=(1000, 500)) >>> image = mx.nd.random.uniform(0, 255, (2321, 3482, 3)).astype(dtype=np.uint8) >>> transformer(image) <NDArray 500x1000x3 @cpu(0)>
-
__init__(size, interpolation=1)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__(size[, interpolation])Initialize self.
apply(fn)Applies
fnrecursively to every child block as well as self.cast(dtype)Cast this Block to use another data type.
collect_params([select])Returns a
ParameterDictcontaining thisBlockand all of its children’s Parameters(default), also can returns the selectParameterDictwhich match some given regular expressions.forward(x)Overrides to implement forward computation using
NDArray.hybridize([active])Activates or deactivates
HybridBlocks recursively.initialize([init, ctx, verbose, force_reinit])Initializes
Parameters of thisBlockand its children.load_parameters(filename[, ctx, …])Load parameters from file previously saved by save_parameters.
load_params(filename[, ctx, allow_missing, …])[Deprecated] Please use load_parameters.
name_scope()Returns a name space object managing a child
Blockand parameter names.register_child(block[, name])Registers block as a child of self.
register_forward_hook(hook)Registers a forward hook on the block.
register_forward_pre_hook(hook)Registers a forward pre-hook on the block.
save_parameters(filename)Save parameters to file.
save_params(filename)[Deprecated] Please use save_parameters.
summary(*inputs)Print the summary of the model’s output and parameters.
Attributes
nameName of this
Block, without ‘_’ in the end.paramsReturns this
Block’s parameter dictionary (does not include its children’s parameters).prefixPrefix of this
Block.