Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
49a1e013
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
49a1e013
编写于
7月 31, 2020
作者:
C
Cathy Wong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
C++ API: Reorder transforms.h alphabetically
上级
6f701461
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
161 addition
and
160 deletion
+161
-160
mindspore/ccsrc/minddata/dataset/include/transforms.h
mindspore/ccsrc/minddata/dataset/include/transforms.h
+161
-160
未找到文件。
mindspore/ccsrc/minddata/dataset/include/transforms.h
浏览文件 @
49a1e013
...
...
@@ -46,59 +46,21 @@ class TensorOperation : public std::enable_shared_from_this<TensorOperation> {
// Transform operations for performing computer vision.
namespace
vision
{
class
NormalizeOperation
;
// Transform Op classes (in alphabetical order)
class
CenterCropOperation
;
class
CropOperation
;
class
CutOutOperation
;
class
DecodeOperation
;
class
ResizeOperation
;
class
NormalizeOperation
;
class
PadOperation
;
class
RandomColorAdjustOperation
;
class
RandomCropOperation
;
class
CenterCropOperation
;
class
UniformAugOperation
;
class
RandomHorizontalFlipOperation
;
class
RandomVerticalFlipOperation
;
class
RandomRotationOperation
;
class
PadOperation
;
class
CutOutOperation
;
class
RandomColorAdjustOperation
;
class
CropOperation
;
class
RandomVerticalFlipOperation
;
class
ResizeOperation
;
class
SwapRedBlueOperation
;
/// \brief Function to create a Normalize TensorOperation.
/// \notes Normalize the input image with respect to mean and standard deviation.
/// \param[in] mean - a vector of mean values for each channel, w.r.t channel order.
/// \param[in] std - a vector of standard deviations for each channel, w.r.t. channel order.
/// \return Shared pointer to the current TensorOperation.
std
::
shared_ptr
<
NormalizeOperation
>
Normalize
(
std
::
vector
<
float
>
mean
,
std
::
vector
<
float
>
std
);
/// \brief Function to create a Decode TensorOperation.
/// \notes Decode the input image in RGB mode.
/// \param[in] rgb - a boolean of whether to decode in RGB mode or not.
/// \return Shared pointer to the current TensorOperation.
std
::
shared_ptr
<
DecodeOperation
>
Decode
(
bool
rgb
=
true
);
/// \brief Function to create a Resize TensorOperation.
/// \notes Resize the input image to the given size..
/// \param[in] size - a vector representing the output size of the resized image.
/// If size is a single value, the image will be resized to this value with
/// the same image aspect ratio. If size has 2 values, it should be (height, width).
/// \param[in] interpolation An enum for the mode of interpolation
/// \return Shared pointer to the current TensorOperation.
std
::
shared_ptr
<
ResizeOperation
>
Resize
(
std
::
vector
<
int32_t
>
size
,
InterpolationMode
interpolation
=
InterpolationMode
::
kLinear
);
/// \brief Function to create a RandomCrop TensorOperation.
/// \notes Crop the input image at a random location.
/// \param[in] size - a vector representing the output size of the cropped image.
/// If size is a single value, a square crop of size (size, size) is returned.
/// If size has 2 values, it should be (height, width).
/// \param[in] padding - a vector with the value of pixels to pad the image. If 4 values are provided,
/// it pads the left, top, right and bottom respectively.
/// \param[in] pad_if_needed - a boolean whether to pad the image if either side is smaller than
/// the given output size.
/// \param[in] fill_value - a vector representing the pixel intensity of the borders, it is used to
/// fill R, G, B channels respectively.
/// \return Shared pointer to the current TensorOperation.
std
::
shared_ptr
<
RandomCropOperation
>
RandomCrop
(
std
::
vector
<
int32_t
>
size
,
std
::
vector
<
int32_t
>
padding
=
{
0
,
0
,
0
,
0
},
bool
pad_if_needed
=
false
,
std
::
vector
<
uint8_t
>
fill_value
=
{
0
,
0
,
0
});
class
UniformAugOperation
;
/// \brief Function to create a CenterCrop TensorOperation.
/// \notes Crops the input image at the center to the given size.
...
...
@@ -108,37 +70,32 @@ std::shared_ptr<RandomCropOperation> RandomCrop(std::vector<int32_t> size, std::
/// \return Shared pointer to the current TensorOperation.
std
::
shared_ptr
<
CenterCropOperation
>
CenterCrop
(
std
::
vector
<
int32_t
>
size
);
/// \brief Function to create a UniformAugment TensorOperation.
/// \notes Tensor operation to perform randomly selected augmentation.
/// \param[in] transforms - a vector of TensorOperation transforms.
/// \param[in] num_ops - integer representing the number of OPs to be selected and applied.
/// \return Shared pointer to the current TensorOperation.
std
::
shared_ptr
<
UniformAugOperation
>
UniformAugment
(
std
::
vector
<
std
::
shared_ptr
<
TensorOperation
>>
transforms
,
int32_t
num_ops
=
2
);
/// \brief Function to create a Crop TensorOp
/// \notes Crop an image based on location and crop size
/// \param[in] coordinates Starting location of crop. Must be a vector of two values, in the form of {x_coor, y_coor}
/// \param[in] size Size of the cropped area. Must be a vector of two values, in the form of {height, width}
/// \return Shared pointer to the current TensorOp
std
::
shared_ptr
<
CropOperation
>
Crop
(
std
::
vector
<
int32_t
>
coordinates
,
std
::
vector
<
int32_t
>
size
);
/// \brief Function to create a RandomHorizontalFlip TensorOperation.
/// \notes Tensor operation to perform random horizontal flip.
/// \param[in] prob - float representing the probability of flip.
/// \return Shared pointer to the current TensorOperation.
std
::
shared_ptr
<
RandomHorizontalFlipOperation
>
RandomHorizontalFlip
(
float
prob
=
0.5
);
/// \brief Function to create a CutOut TensorOp
/// \notes Randomly cut (mask) out a given number of square patches from the input image
/// \param[in] length Integer representing the side length of each square patch
/// \param[in] num_patches Integer representing the number of patches to be cut out of an image
/// \return Shared pointer to the current TensorOp
std
::
shared_ptr
<
CutOutOperation
>
CutOut
(
int32_t
length
,
int32_t
num_patches
=
1
);
/// \brief Function to create a
RandomVerticalFlip
TensorOperation.
/// \notes
Tensor operation to perform random vertical flip
.
/// \param[in]
prob - float representing the probability of flip
.
/// \brief Function to create a
Decode
TensorOperation.
/// \notes
Decode the input image in RGB mode
.
/// \param[in]
rgb - a boolean of whether to decode in RGB mode or not
.
/// \return Shared pointer to the current TensorOperation.
std
::
shared_ptr
<
RandomVerticalFlipOperation
>
RandomVerticalFlip
(
float
prob
=
0.5
);
std
::
shared_ptr
<
DecodeOperation
>
Decode
(
bool
rgb
=
true
);
/// \brief Function to create a RandomRotation TensorOp
/// \notes Rotates the image according to parameters
/// \param[in] degrees A float vector size 2, representing the starting and ending degree
/// \param[in] resample An enum for the mode of interpolation
/// \param[in] expand A boolean representing whether the image is expanded after rotation
/// \param[in] center A float vector size 2, representing the x and y center of rotation.
/// \param[in] fill_value A uint8_t vector size 3, representing the rgb value of the fill color
/// \return Shared pointer to the current TensorOp
std
::
shared_ptr
<
RandomRotationOperation
>
RandomRotation
(
std
::
vector
<
float
>
degrees
,
InterpolationMode
resample
=
InterpolationMode
::
kNearestNeighbour
,
bool
expand
=
false
,
std
::
vector
<
float
>
center
=
{
-
1
,
-
1
},
std
::
vector
<
uint8_t
>
fill_value
=
{
0
,
0
,
0
});
/// \brief Function to create a Normalize TensorOperation.
/// \notes Normalize the input image with respect to mean and standard deviation.
/// \param[in] mean - a vector of mean values for each channel, w.r.t channel order.
/// \param[in] std - a vector of standard deviations for each channel, w.r.t. channel order.
/// \return Shared pointer to the current TensorOperation.
std
::
shared_ptr
<
NormalizeOperation
>
Normalize
(
std
::
vector
<
float
>
mean
,
std
::
vector
<
float
>
std
);
/// \brief Function to create a Pad TensorOp
/// \notes Pads the image according to padding parameters
...
...
@@ -162,13 +119,6 @@ std::shared_ptr<RandomRotationOperation> RandomRotation(
std
::
shared_ptr
<
PadOperation
>
Pad
(
std
::
vector
<
int32_t
>
padding
,
std
::
vector
<
uint8_t
>
fill_value
=
{
0
},
BorderType
padding_mode
=
BorderType
::
kConstant
);
/// \brief Function to create a CutOut TensorOp
/// \notes Randomly cut (mask) out a given number of square patches from the input image
/// \param[in] length Integer representing the side length of each square patch
/// \param[in] num_patches Integer representing the number of patches to be cut out of an image
/// \return Shared pointer to the current TensorOp
std
::
shared_ptr
<
CutOutOperation
>
CutOut
(
int32_t
length
,
int32_t
num_patches
=
1
);
/// \brief Randomly adjust the brightness, contrast, saturation, and hue of the input image
/// \param[in] brightness Brightness adjustment factor. Must be a vector of one or two values
/// if it's a vector of two values it needs to be in the form of [min, max]. Default value is {1, 1}
...
...
@@ -185,222 +135,273 @@ std::shared_ptr<RandomColorAdjustOperation> RandomColorAdjust(std::vector<float>
std
::
vector
<
float
>
saturation
=
{
1.0
,
1.0
},
std
::
vector
<
float
>
hue
=
{
0.0
,
0.0
});
/// \brief Function to create a Crop TensorOp
/// \notes Crop an image based on location and crop size
/// \param[in] coordinates Starting location of crop. Must be a vector of two values, in the form of {x_coor, y_coor}
/// \param[in] size Size of the cropped area. Must be a vector of two values, in the form of {height, width}
/// \brief Function to create a RandomCrop TensorOperation.
/// \notes Crop the input image at a random location.
/// \param[in] size - a vector representing the output size of the cropped image.
/// If size is a single value, a square crop of size (size, size) is returned.
/// If size has 2 values, it should be (height, width).
/// \param[in] padding - a vector with the value of pixels to pad the image. If 4 values are provided,
/// it pads the left, top, right and bottom respectively.
/// \param[in] pad_if_needed - a boolean whether to pad the image if either side is smaller than
/// the given output size.
/// \param[in] fill_value - a vector representing the pixel intensity of the borders, it is used to
/// fill R, G, B channels respectively.
/// \return Shared pointer to the current TensorOperation.
std
::
shared_ptr
<
RandomCropOperation
>
RandomCrop
(
std
::
vector
<
int32_t
>
size
,
std
::
vector
<
int32_t
>
padding
=
{
0
,
0
,
0
,
0
},
bool
pad_if_needed
=
false
,
std
::
vector
<
uint8_t
>
fill_value
=
{
0
,
0
,
0
});
/// \brief Function to create a RandomHorizontalFlip TensorOperation.
/// \notes Tensor operation to perform random horizontal flip.
/// \param[in] prob - float representing the probability of flip.
/// \return Shared pointer to the current TensorOperation.
std
::
shared_ptr
<
RandomHorizontalFlipOperation
>
RandomHorizontalFlip
(
float
prob
=
0.5
);
/// \brief Function to create a RandomRotation TensorOp
/// \notes Rotates the image according to parameters
/// \param[in] degrees A float vector size 2, representing the starting and ending degree
/// \param[in] resample An enum for the mode of interpolation
/// \param[in] expand A boolean representing whether the image is expanded after rotation
/// \param[in] center A float vector size 2, representing the x and y center of rotation.
/// \param[in] fill_value A uint8_t vector size 3, representing the rgb value of the fill color
/// \return Shared pointer to the current TensorOp
std
::
shared_ptr
<
CropOperation
>
Crop
(
std
::
vector
<
int32_t
>
coordinates
,
std
::
vector
<
int32_t
>
size
);
std
::
shared_ptr
<
RandomRotationOperation
>
RandomRotation
(
std
::
vector
<
float
>
degrees
,
InterpolationMode
resample
=
InterpolationMode
::
kNearestNeighbour
,
bool
expand
=
false
,
std
::
vector
<
float
>
center
=
{
-
1
,
-
1
},
std
::
vector
<
uint8_t
>
fill_value
=
{
0
,
0
,
0
});
/// \brief Function to create a RandomVerticalFlip TensorOperation.
/// \notes Tensor operation to perform random vertical flip.
/// \param[in] prob - float representing the probability of flip.
/// \return Shared pointer to the current TensorOperation.
std
::
shared_ptr
<
RandomVerticalFlipOperation
>
RandomVerticalFlip
(
float
prob
=
0.5
);
/// \brief Function to create a Resize TensorOperation.
/// \notes Resize the input image to the given size..
/// \param[in] size - a vector representing the output size of the resized image.
/// If size is a single value, the image will be resized to this value with
/// the same image aspect ratio. If size has 2 values, it should be (height, width).
/// \param[in] interpolation An enum for the mode of interpolation
/// \return Shared pointer to the current TensorOperation.
std
::
shared_ptr
<
ResizeOperation
>
Resize
(
std
::
vector
<
int32_t
>
size
,
InterpolationMode
interpolation
=
InterpolationMode
::
kLinear
);
/// \brief Function to create a SwapRedBlue TensorOp
/// \notes Swaps the red and blue channels in image
/// \return Shared pointer to the current TensorOp
std
::
shared_ptr
<
SwapRedBlueOperation
>
SwapRedBlue
();
/// \brief Function to create a UniformAugment TensorOperation.
/// \notes Tensor operation to perform randomly selected augmentation.
/// \param[in] transforms - a vector of TensorOperation transforms.
/// \param[in] num_ops - integer representing the number of OPs to be selected and applied.
/// \return Shared pointer to the current TensorOperation.
std
::
shared_ptr
<
UniformAugOperation
>
UniformAugment
(
std
::
vector
<
std
::
shared_ptr
<
TensorOperation
>>
transforms
,
int32_t
num_ops
=
2
);
/* ####################################### Derived TensorOperation classes ################################# */
class
Normalize
Operation
:
public
TensorOperation
{
class
CenterCrop
Operation
:
public
TensorOperation
{
public:
NormalizeOperation
(
std
::
vector
<
float
>
mean
,
std
::
vector
<
float
>
std
);
explicit
CenterCropOperation
(
std
::
vector
<
int32_t
>
size
);
~
Normalize
Operation
()
=
default
;
~
CenterCrop
Operation
()
=
default
;
std
::
shared_ptr
<
TensorOp
>
Build
()
override
;
bool
ValidateParams
()
override
;
private:
std
::
vector
<
float
>
mean_
;
std
::
vector
<
float
>
std_
;
std
::
vector
<
int32_t
>
size_
;
};
class
Decode
Operation
:
public
TensorOperation
{
class
Crop
Operation
:
public
TensorOperation
{
public:
explicit
DecodeOperation
(
bool
rgb
=
tru
e
);
CropOperation
(
std
::
vector
<
int32_t
>
coordinates
,
std
::
vector
<
int32_t
>
siz
e
);
~
Decode
Operation
()
=
default
;
~
Crop
Operation
()
=
default
;
std
::
shared_ptr
<
TensorOp
>
Build
()
override
;
bool
ValidateParams
()
override
;
private:
bool
rgb_
;
std
::
vector
<
int32_t
>
coordinates_
;
std
::
vector
<
int32_t
>
size_
;
};
class
Resize
Operation
:
public
TensorOperation
{
class
CutOut
Operation
:
public
TensorOperation
{
public:
explicit
ResizeOperation
(
std
::
vector
<
int32_t
>
size
,
InterpolationMode
interpolation_mode
=
InterpolationMode
::
kLinear
);
explicit
CutOutOperation
(
int32_t
length
,
int32_t
num_patches
=
1
);
~
Resize
Operation
()
=
default
;
~
CutOut
Operation
()
=
default
;
std
::
shared_ptr
<
TensorOp
>
Build
()
override
;
bool
ValidateParams
()
override
;
private:
std
::
vector
<
int32_t
>
size
_
;
InterpolationMode
interpolation
_
;
int32_t
length
_
;
int32_t
num_patches
_
;
};
class
RandomCrop
Operation
:
public
TensorOperation
{
class
Decode
Operation
:
public
TensorOperation
{
public:
RandomCropOperation
(
std
::
vector
<
int32_t
>
size
,
std
::
vector
<
int32_t
>
padding
=
{
0
,
0
,
0
,
0
},
bool
pad_if_needed
=
false
,
std
::
vector
<
uint8_t
>
fill_value
=
{
0
,
0
,
0
});
explicit
DecodeOperation
(
bool
rgb
=
true
);
~
RandomCrop
Operation
()
=
default
;
~
Decode
Operation
()
=
default
;
std
::
shared_ptr
<
TensorOp
>
Build
()
override
;
bool
ValidateParams
()
override
;
private:
std
::
vector
<
int32_t
>
size_
;
std
::
vector
<
int32_t
>
padding_
;
bool
pad_if_needed_
;
std
::
vector
<
uint8_t
>
fill_value_
;
bool
rgb_
;
};
class
CenterCrop
Operation
:
public
TensorOperation
{
class
Normalize
Operation
:
public
TensorOperation
{
public:
explicit
CenterCropOperation
(
std
::
vector
<
int32_t
>
size
);
NormalizeOperation
(
std
::
vector
<
float
>
mean
,
std
::
vector
<
float
>
std
);
~
CenterCrop
Operation
()
=
default
;
~
Normalize
Operation
()
=
default
;
std
::
shared_ptr
<
TensorOp
>
Build
()
override
;
bool
ValidateParams
()
override
;
private:
std
::
vector
<
int32_t
>
size_
;
std
::
vector
<
float
>
mean_
;
std
::
vector
<
float
>
std_
;
};
class
UniformAug
Operation
:
public
TensorOperation
{
class
Pad
Operation
:
public
TensorOperation
{
public:
explicit
UniformAugOperation
(
std
::
vector
<
std
::
shared_ptr
<
TensorOperation
>>
transforms
,
int32_t
num_ops
=
2
);
PadOperation
(
std
::
vector
<
int32_t
>
padding
,
std
::
vector
<
uint8_t
>
fill_value
=
{
0
},
BorderType
padding_mode
=
BorderType
::
kConstant
);
~
UniformAug
Operation
()
=
default
;
~
Pad
Operation
()
=
default
;
std
::
shared_ptr
<
TensorOp
>
Build
()
override
;
bool
ValidateParams
()
override
;
private:
std
::
vector
<
std
::
shared_ptr
<
TensorOperation
>>
transforms_
;
int32_t
num_ops_
;
std
::
vector
<
int32_t
>
padding_
;
std
::
vector
<
uint8_t
>
fill_value_
;
BorderType
padding_mode_
;
};
class
Random
HorizontalFlip
Operation
:
public
TensorOperation
{
class
Random
ColorAdjust
Operation
:
public
TensorOperation
{
public:
explicit
RandomHorizontalFlipOperation
(
float
probability
=
0.5
);
RandomColorAdjustOperation
(
std
::
vector
<
float
>
brightness
=
{
1.0
,
1.0
},
std
::
vector
<
float
>
contrast
=
{
1.0
,
1.0
},
std
::
vector
<
float
>
saturation
=
{
1.0
,
1.0
},
std
::
vector
<
float
>
hue
=
{
0.0
,
0.0
});
~
Random
HorizontalFlip
Operation
()
=
default
;
~
Random
ColorAdjust
Operation
()
=
default
;
std
::
shared_ptr
<
TensorOp
>
Build
()
override
;
bool
ValidateParams
()
override
;
private:
float
probability_
;
std
::
vector
<
float
>
brightness_
;
std
::
vector
<
float
>
contrast_
;
std
::
vector
<
float
>
saturation_
;
std
::
vector
<
float
>
hue_
;
};
class
Random
VerticalFli
pOperation
:
public
TensorOperation
{
class
Random
Cro
pOperation
:
public
TensorOperation
{
public:
explicit
RandomVerticalFlipOperation
(
float
probability
=
0.5
);
RandomCropOperation
(
std
::
vector
<
int32_t
>
size
,
std
::
vector
<
int32_t
>
padding
=
{
0
,
0
,
0
,
0
},
bool
pad_if_needed
=
false
,
std
::
vector
<
uint8_t
>
fill_value
=
{
0
,
0
,
0
});
~
Random
VerticalFli
pOperation
()
=
default
;
~
Random
Cro
pOperation
()
=
default
;
std
::
shared_ptr
<
TensorOp
>
Build
()
override
;
bool
ValidateParams
()
override
;
private:
float
probability_
;
std
::
vector
<
int32_t
>
size_
;
std
::
vector
<
int32_t
>
padding_
;
bool
pad_if_needed_
;
std
::
vector
<
uint8_t
>
fill_value_
;
};
class
Random
Rotation
Operation
:
public
TensorOperation
{
class
Random
HorizontalFlip
Operation
:
public
TensorOperation
{
public:
RandomRotationOperation
(
std
::
vector
<
float
>
degrees
,
InterpolationMode
interpolation_mode
,
bool
expand
,
std
::
vector
<
float
>
center
,
std
::
vector
<
uint8_t
>
fill_value
);
explicit
RandomHorizontalFlipOperation
(
float
probability
=
0.5
);
~
Random
Rotation
Operation
()
=
default
;
~
Random
HorizontalFlip
Operation
()
=
default
;
std
::
shared_ptr
<
TensorOp
>
Build
()
override
;
bool
ValidateParams
()
override
;
private:
std
::
vector
<
float
>
degrees_
;
InterpolationMode
interpolation_mode_
;
std
::
vector
<
float
>
center_
;
bool
expand_
;
std
::
vector
<
uint8_t
>
fill_value_
;
float
probability_
;
};
class
Pad
Operation
:
public
TensorOperation
{
class
RandomRotation
Operation
:
public
TensorOperation
{
public:
PadOperation
(
std
::
vector
<
int32_t
>
padding
,
std
::
vector
<
uint8_t
>
fill_value
=
{
0
}
,
BorderType
padding_mode
=
BorderType
::
kConstant
);
RandomRotationOperation
(
std
::
vector
<
float
>
degrees
,
InterpolationMode
interpolation_mode
,
bool
expand
,
std
::
vector
<
float
>
center
,
std
::
vector
<
uint8_t
>
fill_value
);
~
Pad
Operation
()
=
default
;
~
RandomRotation
Operation
()
=
default
;
std
::
shared_ptr
<
TensorOp
>
Build
()
override
;
bool
ValidateParams
()
override
;
private:
std
::
vector
<
int32_t
>
padding_
;
std
::
vector
<
float
>
degrees_
;
InterpolationMode
interpolation_mode_
;
std
::
vector
<
float
>
center_
;
bool
expand_
;
std
::
vector
<
uint8_t
>
fill_value_
;
BorderType
padding_mode_
;
};
class
CutOut
Operation
:
public
TensorOperation
{
class
RandomVerticalFlip
Operation
:
public
TensorOperation
{
public:
explicit
CutOutOperation
(
int32_t
length
,
int32_t
num_patches
=
1
);
explicit
RandomVerticalFlipOperation
(
float
probability
=
0.5
);
~
CutOut
Operation
()
=
default
;
~
RandomVerticalFlip
Operation
()
=
default
;
std
::
shared_ptr
<
TensorOp
>
Build
()
override
;
bool
ValidateParams
()
override
;
private:
int32_t
length_
;
int32_t
num_patches_
;
float
probability_
;
};
class
R
andomColorAdjust
Operation
:
public
TensorOperation
{
class
R
esize
Operation
:
public
TensorOperation
{
public:
RandomColorAdjustOperation
(
std
::
vector
<
float
>
brightness
=
{
1.0
,
1.0
},
std
::
vector
<
float
>
contrast
=
{
1.0
,
1.0
}
,
std
::
vector
<
float
>
saturation
=
{
1.0
,
1.0
},
std
::
vector
<
float
>
hue
=
{
0.0
,
0.0
}
);
explicit
ResizeOperation
(
std
::
vector
<
int32_t
>
size
,
InterpolationMode
interpolation_mode
=
InterpolationMode
::
kLinear
);
~
R
andomColorAdjust
Operation
()
=
default
;
~
R
esize
Operation
()
=
default
;
std
::
shared_ptr
<
TensorOp
>
Build
()
override
;
bool
ValidateParams
()
override
;
private:
std
::
vector
<
float
>
brightness_
;
std
::
vector
<
float
>
contrast_
;
std
::
vector
<
float
>
saturation_
;
std
::
vector
<
float
>
hue_
;
std
::
vector
<
int32_t
>
size_
;
InterpolationMode
interpolation_
;
};
class
Crop
Operation
:
public
TensorOperation
{
class
UniformAug
Operation
:
public
TensorOperation
{
public:
CropOperation
(
std
::
vector
<
int32_t
>
coordinates
,
std
::
vector
<
int32_t
>
size
);
explicit
UniformAugOperation
(
std
::
vector
<
std
::
shared_ptr
<
TensorOperation
>>
transforms
,
int32_t
num_ops
=
2
);
~
Crop
Operation
()
=
default
;
~
UniformAug
Operation
()
=
default
;
std
::
shared_ptr
<
TensorOp
>
Build
()
override
;
bool
ValidateParams
()
override
;
private:
std
::
vector
<
int32_t
>
coordinate
s_
;
std
::
vector
<
int32_t
>
size
_
;
std
::
vector
<
std
::
shared_ptr
<
TensorOperation
>>
transform
s_
;
int32_t
num_ops
_
;
};
class
SwapRedBlueOperation
:
public
TensorOperation
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录