pytorch  1.8.2
About: PyTorch provides Tensor computation (like NumPy) with strong GPU acceleration and Deep Neural Networks (in Python) built on a tape-based autograd system. LTS (Long Term Support) release.
  Fossies Dox: pytorch-1.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

image_input_op.cc
Go to the documentation of this file.
2
3#ifdef CAFFE2_USE_MKLDNN
6#endif
7
8namespace caffe2 {
9
10template <>
12 const std::vector<std::int64_t>&,
13 const c10::Device&) {
14 return false;
15}
16
18
19OPERATOR_SCHEMA(ImageInput)
20 .NumInputs(0, 1)
21 .NumOutputs(2, INT_MAX)
22 .TensorInferenceFunction([](const OperatorDef& def,
23 const vector<TensorShape>& /* unused */) {
26 int batch_size = helper.GetSingleArgument<int>("batch_size", 0);
27 int crop = helper.GetSingleArgument<int>("crop", -1);
28 int color = helper.GetSingleArgument<int>("color", 1);
29 CHECK_GT(crop, 0);
31 vector<int>{batch_size, crop, crop, color ? 3 : 1},
33 out[1] =
35 return out;
36 })
37 .SetDoc(R"DOC(
38Imports and processes images from a database. For each run of the operator,
39batch_size images will be processed. GPUs can optionally be used for
40part of the processing.
41
42The following transformations are applied to the image
43 - A bounding box is applied to the initial image (optional)
44 - The image is rescaled either up or down (with the scale argument) or
45 just up (with the minsize argument)
46 - The image is randomly cropped (crop size is passed as an argument but
47 the location of the crop is random except if is_test is passed in which case
48 the image in cropped at the center)
49 - The image is normalized. Each of its color channels can have separate
50 normalization values
51
52The dimension of the output image will always be cropxcrop
53)DOC")
54 .Arg(
55 "batch_size",
56 "Number of images to output for each run of the operator"
57 ". Must be 1 or greater")
58 .Arg("color", "Number of color channels (1 or 3). Defaults to 1")
59 .Arg("color_jitter", "Whether or not to do color jitter. Defaults to 0")
60 .Arg(
61 "img_saturation",
62 "Image saturation scale used in color jittering. "
63 "Defaults to 0.4")
64 .Arg(
65 "img_brightness",
66 "Image brightness scale used in color jittering. "
67 "Defaults to 0.4")
68 .Arg(
69 "img_contrast",
70 "Image contrast scale used in color jittering. "
71 "Defaults to 0.4")
72 .Arg(
73 "color_lighting",
74 "Whether or not to do color lighting."
75 " Defaults to 0")
76 .Arg(
77 "color_lighting_std",
78 "Std of normal distribution where color lighting"
79 " scaling factor is sampled. Defaults to 0.1")
80 .Arg(
81 "scale_jitter_type",
82 "Type 0: No scale jittering "
83 "Type 1: Inception-style scale jittering")
84 .Arg(
85 "label_type",
86 "Type 0: single integer label for multi-class "
87 "classification. Type 1: sparse active label indices for multi-label "
88 "classification. Type 2: dense label embedding vector for label "
89 "embedding regression")
90 .Arg(
91 "scale",
92 "Scale the size of the smallest dimension of the image to"
93 " this. Scale and minsize are mutually exclusive."
94 " Must be larger than crop")
95 .Arg(
96 "minsize",
97 "Scale the size of the smallest dimension of the image to"
98 " this only if the size is initially smaller. Scale and minsize are"
99 " mutually exclusive. Must be larger than crop.")
100 .Arg(
101 "warp",
102 "If 1, both dimensions of the image will be set to minsize or"
103 " scale; otherwise, the other dimension is proportionally scaled."
104 " Defaults to 0")
105 .Arg("crop", "Size to crop the image to. Must be provided")
106 .Arg("mirror", "Whether or not to mirror the image. Defaults to 0")
107 .Arg(
108 "mean",
109 "Mean by which to normalize color channels."
110 " Defaults to 0.")
111 .Arg(
112 "mean_per_channel",
113 "Vector of means per color channel "
114 " (1 or 3 elements). Defaults to mean argument. Channel order BGR")
115 .Arg(
116 "std",
117 "Standard deviation by which to normalize color channels."
118 " Defaults to 1.")
119 .Arg(
120 "std_per_channel",
121 "Vector of standard dev. per color channel "
122 " (1 or 3 elements). Defaults to std argument. Channel order is BGR")
123 .Arg("bounding_ymin", "Bounding box coordinate. Defaults to -1 (none)")
124 .Arg("bounding_xmin", "Bounding box coordinate. Defaults to -1 (none)")
125 .Arg("bounding_height", "Bounding box coordinate. Defaults to -1 (none)")
126 .Arg("bounding_width", "Bounding box coordinate. Defaults to -1 (none)")
127 .ArgIsTest("Set to 1 to do deterministic cropping. Defaults to 0")
128 .Arg("use_caffe_datum", "1 if the input is in Caffe format. Defaults to 0")
129 .Arg(
130 "use_gpu_transform",
131 "1 if GPU acceleration should be used."
132 " Defaults to 0. Can only be 1 in a CUDAContext")
133 .Arg(
134 "decode_threads",
135 "Number of CPU decode/transform threads."
136 " Defaults to 4")
137 .Arg("output_type", "If gpu_transform, can set to FLOAT or FLOAT16.")
138 .Arg("db", "Name of the database (if not passed as input)")
139 .Arg(
140 "db_type",
141 "Type of database (if not passed as input)."
142 " Defaults to leveldb")
143 .Arg(
144 "output_sizes",
145 "The sizes of any outputs besides the data and label "
146 "(should have a number of elements equal to the number of additional "
147 "outputs)")
148 .Arg(
149 "random_scale",
150 "[min, max] shortest-side desired for image resize. "
151 "Defaults to [-1, -1] or no random resize desired.")
152 .Input(0, "reader", "The input reader (a db::DBReader)")
153 .Output(0, "data", "Tensor containing the images")
154 .Output(1, "label", "Tensor containing the labels")
155 .Output(
156 2,
157 "additional outputs",
158 "Any outputs after the first 2 will be "
159 "Tensors read from the input TensorProtos");
160
161NO_GRADIENT(ImageInput);
162
163#ifdef CAFFE2_USE_MKLDNN
165#endif
166
167} // namespace caffe2
A helper class to index into arguments.
Definition: proto_utils.h:203
static T GetSingleArgument(const Def &def, const string &name, const T &default_value)
Definition: proto_utils.h:211
A templated class to allow one to wrap a CPU operator as an IDEEP operator.
bool ApplyTransformOnGPU(const std::vector< std::int64_t > &dims, const c10::Device &type)
If load images in color
#define CHECK_GT(val1, val2)
Copyright (c) 2016-present, Facebook, Inc.
Definition: blob.h:13
REGISTER_CPU_OPERATOR(ATen, ATenOp< CPUContext >)
REGISTER_IDEEP_OPERATOR(Softmax, IDEEPFallbackOp< SoftmaxOp< float, CPUContext > >)
parameter efficient embedding termed TT which can be plugged in into any model and trained end to end The benefits of our compressed TT layer are twofold instead of storing huge embedding it stores a sequence of much smaller dimensional and dimensional necessary for reconstructing the required which allows compressing the model significantly at the cost of a negligible performance drop the overall number of parameters can be relatively which allows to use larger batches or train efficiently in a case of limited resources DOC vector< int >
OPERATOR_SCHEMA(ATen)
return vector< TensorShape >
Definition: slice_op.cc:110
ArgumentHelper helper(def)
NO_GRADIENT(SparseLengthsSumFused4BitRowwiseFakeFP16NNPI)
TensorShape CreateTensorShape(vector< T_I > dims, ::caffe2::TensorProto_DataType dt)
SparseLengths8BitsRowwiseOp< CPUContext, 0, 1 >::LENGTHS SetDoc(R"DOC( Variation of SparseLengthsMean operator, where DATA is stored using 8bits. DATA was quantized with 8Bit row-wise quantization (see doc to FloatToRowwiseQuantized8Bits operator). To restore DATA from 8Bit, we use additional input that stores scales and biases. )DOC") .Input(0
Represents a a compute device on which a tensor is located.
Definition: Device.h:30