1 #include <caffe2/video/video_input_op.h> 5 REGISTER_CPU_OPERATOR(VideoInput, VideoInputOp<CPUContext>);
7 OPERATOR_SCHEMA(VideoInput)
10 .TensorInferenceFunction(
11 [](
const OperatorDef& def,
12 const vector<TensorShape>& ) {
13 ArgumentHelper helper(def);
14 int batch_size = helper.GetSingleArgument<
int>(
"batch_size", 0);
16 helper.GetSingleArgument<
int>(
"clip_per_video", 1);
17 int crop_height = helper.GetSingleArgument<
int>(
18 "crop_height", helper.GetSingleArgument<
int>(
"crop_size", 0));
19 int crop_width = helper.GetSingleArgument<
int>(
20 "crop_width", helper.GetSingleArgument<
int>(
"crop_size", 0));
21 int length_rgb = helper.GetSingleArgument<
int>(
"length_rgb", 0);
22 int channels_rgb = helper.GetSingleArgument<
int>(
"channels_rgb", 3);
23 int length_of = helper.GetSingleArgument<
int>(
"length_of", 0);
24 int channels_of = helper.GetSingleArgument<
int>(
"channels_of", 2);
27 bool get_rgb = helper.GetSingleArgument<
bool>(
"get_rgb",
true);
28 bool get_optical_flow =
29 helper.GetSingleArgument<
bool>(
"get_optical_flow",
false);
31 helper.GetSingleArgument<
bool>(
"do_multi_label",
false);
33 helper.GetSingleArgument<
bool>(
"get_video_id",
false);
39 if (get_optical_flow) {
47 vector<TensorShape> out(output_size);
48 CHECK_GT(crop_height, 0);
49 CHECK_GT(crop_width, 0);
50 batch_size *= clip_per_video;
52 out[index++] = CreateTensorShape(
53 vector<int>{batch_size,
60 if (get_optical_flow) {
61 out[index++] = CreateTensorShape(
62 vector<int>{batch_size,
69 if (!do_multi_label) {
70 out[index++] = CreateTensorShape(
71 vector<int>{1, batch_size}, TensorProto::INT32);
73 int num_of_class = helper.GetSingleArgument<
int>(
"num_of_class", 0);
74 out[index++] = CreateTensorShape(
75 vector<int>{batch_size, num_of_class}, TensorProto::INT32);
78 out[index] = CreateTensorShape(
79 vector<int>{1, batch_size}, TensorProto::INT32);
85 NO_GRADIENT(VideoInput);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...