-
Notifications
You must be signed in to change notification settings - Fork 561
/
chain_actions.cc
720 lines (631 loc) · 23.9 KB
/
chain_actions.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
/**
* DeepDetect
* Copyright (c) 2019 Emmanuel Benazera
* Author: Emmanuel Benazera <emmanuel.benazera@jolibrain.com>
*
* This file is part of deepdetect.
*
* deepdetect is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* deepdetect is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with deepdetect. If not, see <http://www.gnu.org/licenses/>.
*/
#include "chain_actions.h"
#include <unordered_set>
#include <opencv2/opencv.hpp>
#ifdef USE_CUDA_CV
#include <opencv2/cudaimgproc.hpp>
#endif
#if CV_VERSION_MAJOR >= 3
#define CV_BGR2RGB cv::COLOR_BGR2RGB
#define CV_RGB2BGR cv::COLOR_RGB2BGR
#endif
#include "utils/utils.hpp"
#ifdef USE_DLIB
#include "backends/dlib/dlib_actions.h"
#endif
namespace dd
{
void ImgsCropAction::apply(oatpp::Object<DTO::PredictBody> &model_out,
ChainData &cdata)
{
auto predictions = model_out->predictions;
ChainInputData &input_data = model_out->_chain_input;
std::vector<std::pair<int, int>> imgs_size = input_data._img_sizes;
std::vector<std::string> bbox_ids;
std::vector<cv::Mat> imgs = input_data._imgs;
std::vector<cv::Mat> cropped_imgs;
std::vector<cv::Mat> masks;
#ifdef USE_CUDA_CV
std::vector<cv::cuda::GpuMat> cuda_imgs = input_data._cuda_imgs;
std::vector<cv::cuda::GpuMat> cropped_cuda_imgs;
std::vector<cv::cuda::GpuMat> cuda_masks;
#endif
// check for action parameters
double bratio = _params->padding_ratio;
bool save_crops = _params->save_crops;
bool gen_mask = _params->generate_mask;
std::string save_path = _params->save_path;
if (!save_path.empty())
save_path += "/";
int fixed_width = _params->fixed_width;
int fixed_height = _params->fixed_height;
// iterate image batch
for (size_t i = 0; i < predictions->size(); i++)
{
auto pred = predictions->at(i);
std::string uri = pred->uri;
int im_cols, im_rows;
#ifdef USE_CUDA_CV
if (!cuda_imgs.empty())
{
im_cols = cuda_imgs.at(i).cols;
im_rows = cuda_imgs.at(i).rows;
}
else
#endif
{
im_cols = imgs.at(i).cols;
im_rows = imgs.at(i).rows;
}
int orig_cols = imgs_size.at(i).second;
int orig_rows = imgs_size.at(i).first;
// iterate bboxes per image
for (size_t j = 0; j < pred->classes->size(); j++)
{
auto bbox = pred->classes->at(j)->bbox;
if (bbox == nullptr)
throw ActionBadParamException(
"crop action cannot find bbox object for uri " + uri);
double xmin = bbox->xmin / orig_cols * im_cols;
double ymin = bbox->ymin / orig_rows * im_rows;
double xmax = bbox->xmax / orig_cols * im_cols;
double ymax = bbox->ymax / orig_rows * im_rows;
double deltax = bratio * (xmax - xmin);
double deltay = bratio * (ymax - ymin);
double cxmin = std::max(0.0, xmin - deltax);
double cxmax
= std::min(static_cast<double>(im_cols), xmax + deltax);
double cymin = std::max(0.0, ymin - deltay);
double cymax
= std::min(static_cast<double>(im_rows), ymax + deltay);
if (_params->min_width > (cxmax - cxmin))
fixed_width = _params->min_width;
if (_params->min_height > (cymax - cymin))
fixed_height = _params->min_height;
if (_params->force_square)
{
if (fixed_width == 0)
fixed_width = static_cast<int>(cxmax - cxmin);
if (fixed_height == 0)
fixed_height = static_cast<int>(cymax - cymin);
if (fixed_height > fixed_width)
fixed_width = fixed_height;
if (fixed_width > fixed_height)
fixed_height = fixed_width;
}
if (fixed_width > 0)
{
double xcenter = cxmin + (cxmax - cxmin) / 2.0;
cxmin = int(xcenter - fixed_width / 2.0);
cxmax = int(xcenter + fixed_width / 2.0);
if (cxmin < 0)
{
cxmax += -cxmin;
cxmin = 0;
}
if (cxmax > im_cols)
{
cxmin -= cxmax - im_cols;
cxmax = im_cols;
}
}
if (fixed_height > 0)
{
double ycenter = cymin + (cymax - cymin) / 2.0;
cymin = int(ycenter - fixed_height / 2.0);
cymax = int(ycenter + fixed_height / 2.0);
if (cymin < 0)
{
cymax += -cymin;
cymin = 0;
}
if (cymax > im_rows)
{
cymin -= cymax - im_rows;
cymax = im_rows;
}
}
if (cxmin >= im_cols || cymin >= im_rows || cxmax < 0 || cymax < 0)
{
_chain_logger->warn("bounding box does not intersect image, "
"skipping crop action");
continue;
}
cv::Rect roi(cxmin, cymin, cxmax - cxmin, cymax - cymin);
// roi corresponding to the bbox inside the crop
cv::Rect mask_roi(bbox->xmin - cxmin, bbox->ymin - cymin,
bbox->xmax - bbox->xmin,
bbox->ymax - bbox->ymin);
#ifdef USE_CUDA_CV
if (!cuda_imgs.empty())
{
cv::cuda::GpuMat cropped_img = cuda_imgs.at(i)(roi).clone();
// Generate mask for diffusion
if (gen_mask)
{
cv::cuda::GpuMat cuda_mask(cropped_img.rows,
cropped_img.cols, CV_8UC1,
cv::Scalar(0));
// XXX: Use streams for non-blocking call
cuda_mask(mask_roi).setTo(255);
cuda_masks.push_back(cuda_mask);
}
// save crops if requested
if (save_crops)
{
cv::Mat cropped_img_cpu;
cropped_img.download(cropped_img_cpu);
std::string puri = dd_utils::split(uri, '/').back();
cv::imwrite(save_path + "crop_" + puri + "_"
+ std::to_string(j) + ".png",
cropped_img_cpu);
}
cropped_cuda_imgs.push_back(std::move(cropped_img));
}
else
#endif
{
cv::Mat cropped_img = imgs.at(i)(roi).clone();
// Generate mask for diffusion models
if (gen_mask)
{
cv::Mat mask(cropped_img.rows, cropped_img.cols, CV_8UC1,
cv::Scalar(0));
cv::rectangle(mask, mask_roi, 255, cv::FILLED);
masks.push_back(mask);
}
// save crops if requested
if (save_crops)
{
std::string puri = dd_utils::split(uri, '/').back();
cv::imwrite(save_path + "crop_" + puri + "_"
+ std::to_string(j) + ".png",
cropped_img);
}
cropped_imgs.push_back(std::move(cropped_img));
}
// adding bbox id
std::string bbox_id = genid(uri, "bbox" + std::to_string(j));
bbox_ids.push_back(bbox_id);
pred->classes->at(j)->class_id = bbox_id;
}
}
// store crops into action output store
APIData action_out;
#ifdef USE_CUDA_CV
if (!cropped_cuda_imgs.empty())
{
action_out.add("data_cuda_img", cropped_cuda_imgs);
if (gen_mask)
action_out.add("cuda_mask", cuda_masks);
}
else
#endif
{
action_out.add("data_raw_img", cropped_imgs);
if (gen_mask)
action_out.add("mask", masks);
}
action_out.add("cids", bbox_ids);
cdata.add_action_data(_action_id, action_out);
}
void ImgsRotateAction::apply(oatpp::Object<DTO::PredictBody> &model_out,
ChainData &cdata)
{
// get label
auto predictions = model_out->predictions;
ChainInputData &input_data = model_out->_chain_input;
std::vector<std::pair<int, int>> imgs_size = input_data._img_sizes;
// TODO does not support CUDA
std::vector<cv::Mat> imgs = input_data._imgs;
std::vector<cv::Mat> rimgs;
std::vector<std::string> uris;
// check for action parameters
std::string orientation = _params->orientation;
bool save_img = _params->save_img;
std::string save_path = _params->save_path;
if (!save_path.empty())
save_path += "/";
for (size_t i = 0; i < predictions->size(); i++) // iterate predictions
{
auto pred = predictions->at(i);
std::string uri = pred->uri;
cv::Mat img = imgs.at(i);
// rotate and make image available to next service
if (pred->classes->size() > 0)
{
uris.push_back(uri);
// TODO check that it cannot be null
std::string cat1 = pred->classes->at(0)->cat;
cv::Mat rimg, timg;
if (cat1 == "0") // all tests in absolute orientation
{
rimg = img;
}
else if (cat1 == "90")
{
cv::transpose(img, timg);
int orient = 1;
if (orientation == "relative")
orient = 0; // 270
cv::flip(timg, rimg, orient);
}
else if (cat1 == "180")
{
cv::flip(img, rimg, -1);
}
else if (cat1 == "270")
{
cv::transpose(img, timg);
int orient = 0;
if (orientation == "relative")
orient = 1; // 90
cv::flip(timg, rimg, orient);
}
if (!rimg.empty())
{
rimgs.push_back(rimg);
// save image if requested
if (save_img)
{
std::string puri = dd_utils::split(uri, '/').back();
cv::imwrite(
save_path + "rot_" + puri + "_" + cat1 + ".png", rimg);
}
}
}
}
// store rotated images into action output store
APIData action_out;
action_out.add("data_raw_img", rimgs);
action_out.add("cids", uris);
cdata.add_action_data(_action_id, action_out);
}
void make_even(cv::Mat &mat, int &width, int &height)
{
if (width % 2 != 0)
width -= 1;
if (height % 2 != 0)
height -= 1;
if (width != mat.cols || height != mat.rows)
{
cv::Rect roi{ 0, 0, width, height };
mat = mat(roi);
}
}
void
ImgsCropRecomposeAction::apply(oatpp::Object<DTO::PredictBody> &model_out,
ChainData &cdata)
{
oatpp::Object<DTO::PredictBody> first_model = cdata.get_model_data("0");
ChainInputData &input_data = first_model->_chain_input;
// image
std::vector<cv::Mat> imgs = input_data._imgs;
#ifdef USE_CUDA_CV
std::vector<cv::cuda::GpuMat> cuda_imgs = input_data._cuda_imgs;
std::vector<cv::cuda::GpuMat> cropped_cuda_imgs;
#endif
std::vector<std::pair<int, int>> imgs_size = input_data._img_sizes;
// bbox
auto predictions = first_model->predictions;
// generated images
// XXX: Images are always read from RAM, never from CUDA memory.
// This may change in the future
std::map<std::string, cv::Mat> gen_imgs;
for (size_t i = 0; i < model_out->predictions->size(); ++i)
{
auto images = model_out->predictions->at(i)->images;
if (images->size() == 0)
throw ActionBadParamException(
"Recompose requires output.image = true in previous model");
gen_imgs.insert(
{ *model_out->predictions->at(i)->uri, images->at(0)->get_img() });
}
std::vector<cv::Mat> rimgs;
std::vector<std::string> uris;
bool save_img = _params->save_img;
std::string save_path = _params->save_path;
if (!save_path.empty())
save_path += "/";
auto pred_body = DTO::PredictBody::createShared();
// need: original image, bbox coordinates, new image
for (size_t i = 0; i < predictions->size(); i++)
{
auto pred = predictions->at(i);
std::string uri = pred->uri;
uris.push_back(uri);
cv::Mat input_img;
int input_width, input_height;
cv::Mat rimg;
#ifdef USE_CUDA_CV
cv::cuda::GpuMat cuda_input_img;
cv::cuda::GpuMat cuda_rimg;
if (!cuda_imgs.empty())
{
cuda_input_img = cuda_imgs.at(i);
input_width = cuda_input_img.cols;
input_height = cuda_input_img.rows;
cuda_rimg = cuda_input_img.clone();
}
else
#endif
{
input_img = imgs.at(i);
input_width = input_img.cols;
input_height = input_img.rows;
rimg = input_img.clone();
}
int orig_width = imgs_size.at(i).second;
int orig_height = imgs_size.at(i).first;
for (size_t j = 0; j < pred->classes->size(); j++)
{
auto bbox = pred->classes->at(j)->bbox;
std::string cls_id = pred->classes->at(j)->class_id;
cv::Mat gen_img = gen_imgs.at(cls_id);
int gen_width = gen_img.cols;
int gen_height = gen_img.rows;
// support odd width & height
make_even(gen_img, gen_width, gen_height);
if (gen_width > input_width || gen_height > input_height)
{
throw ActionBadParamException(
"Recomposing image is impossible, crop is too big: "
+ std::to_string(gen_width) + ","
+ std::to_string(gen_height) + "/"
+ std::to_string(orig_width) + ","
+ std::to_string(orig_height));
}
double xmin = bbox->xmin / orig_width * input_width;
double ymin = bbox->ymin / orig_height * input_height;
double xmax = bbox->xmax / orig_width * input_width;
double ymax = bbox->ymax / orig_height * input_height;
int cx = static_cast<int>((xmin + xmax) / 2);
int cy = static_cast<int>((ymin + ymax) / 2);
cx = std::min(std::max(cx, gen_width / 2),
input_width - gen_width / 2);
cy = std::min(std::max(cy, gen_height / 2),
input_height - gen_height / 2);
cv::Rect roi{ cx - gen_width / 2, cy - gen_height / 2, gen_width,
gen_height };
#ifdef USE_CUDA_CV
if (cuda_rimg.cols != 0)
{
cv::cuda::GpuMat cuda_gen_img;
cuda_gen_img.upload(gen_img);
cuda_gen_img.copyTo(cuda_rimg(roi));
}
else
#endif
{
gen_img.copyTo(rimg(roi));
}
}
rimgs.push_back(rimg);
auto action_pred = DTO::Prediction::createShared();
action_pred->uri = uri.c_str();
action_pred->images = oatpp::Vector<DTO::DTOImage>::createShared();
#ifdef USE_CUDA_CV
if (cuda_rimg.cols != 0)
{
action_pred->images->push_back({ cuda_rimg });
}
else
#endif
{
action_pred->images->push_back({ rimg });
}
pred_body->predictions->push_back(action_pred);
// save image if requested
if (save_img)
{
std::string puri = dd_utils::split(uri, '/').back();
#ifdef USE_CUDA_CV
if (cuda_rimg.cols != 0)
cuda_rimg.download(rimg);
#endif
cv::imwrite(save_path + "recompose_" + puri + ".png", rimg);
}
}
// Output: new image -> only works in "image" output mode
APIData action_out;
action_out.add("data_raw_img", rimgs);
action_out.add("cids", uris);
action_out.add("output", pred_body);
cdata.add_action_data(_action_id, action_out);
}
cv::Scalar bbox_palette[]
= { { 82, 188, 227 }, { 196, 110, 49 }, { 39, 54, 227 },
{ 68, 227, 81 }, { 77, 157, 255 }, { 255, 112, 207 },
{ 240, 228, 65 }, { 94, 242, 151 }, { 236, 121, 242 },
{ 28, 77, 120 } };
size_t bbox_palette_size = 10;
void ImgsDrawBBoxAction::apply(oatpp::Object<DTO::PredictBody> &model_out,
ChainData &cdata)
{
auto predictions = model_out->predictions;
ChainInputData &input_data = model_out->_chain_input;
std::vector<std::pair<int, int>> imgs_size = input_data._img_sizes;
// TODO does not support CUDA
std::vector<cv::Mat> imgs = input_data._imgs;
std::vector<cv::Mat> rimgs;
std::vector<std::string> uris;
auto pred_body = DTO::PredictBody::createShared();
bool save_img = _params->save_img;
int ref_thickness = _params->thickness;
std::string save_path = _params->save_path;
if (!save_path.empty())
save_path += "/";
for (size_t i = 0; i < predictions->size(); i++)
{
auto pred = predictions->at(i);
std::string uri = pred->uri;
uris.push_back(uri);
int im_cols = imgs.at(i).cols;
int im_rows = imgs.at(i).rows;
int orig_cols = imgs_size.at(i).second;
int orig_rows = imgs_size.at(i).first;
cv::Mat rimg = imgs.at(i).clone();
// iterate bboxes per image
for (size_t j = 0; j < pred->classes->size(); j++)
{
auto bbox = pred->classes->at(j)->bbox;
std::string cat = pred->classes->at(j)->cat;
if (bbox == nullptr)
throw ActionBadParamException(
"draw action cannot find bbox object for uri " + uri);
double xmin = bbox->xmin / orig_cols * im_cols;
double ymin = bbox->ymin / orig_rows * im_rows;
double xmax = bbox->xmax / orig_cols * im_cols;
double ymax = bbox->ymax / orig_rows * im_rows;
// draw bbox
cv::Point pt1{ int(xmin), int(ymin) };
cv::Point pt2{ int(xmax), int(ymax) };
size_t cls_hash = std::hash<std::string>{}(cat);
cv::Scalar color = bbox_palette[cls_hash % bbox_palette_size];
cv::rectangle(rimg, pt1, pt2, cv::Scalar(255, 255, 255),
ref_thickness + 2);
cv::rectangle(rimg, pt1, pt2, color, ref_thickness);
// draw class & confidences
std::string label;
if (_params->write_cat)
label = cat;
if (_params->write_cat && _params->write_prob)
label += " - ";
if (_params->write_prob)
label += std::to_string(pred->classes->at(j)->prob);
// font size relatively to base opencv font size
float font_size = 2;
int x_txt = static_cast<int>(xmin + 5);
if (x_txt > im_cols - 15)
x_txt = im_cols - 15;
int y_txt = std::min(im_rows - 20,
static_cast<int>(ymax + 2 + font_size * 12));
cv::putText(rimg, label, cv::Point(x_txt, y_txt),
cv::FONT_HERSHEY_PLAIN, font_size,
cv::Scalar(255, 255, 255), ref_thickness + 2);
cv::putText(rimg, label, cv::Point(x_txt, y_txt),
cv::FONT_HERSHEY_PLAIN, font_size, color,
ref_thickness);
}
rimgs.push_back(rimg);
// save image if requested
if (save_img)
{
std::string puri = dd_utils::split(uri, '/').back();
std::string rimg_path = save_path + "bbox_" + puri + ".png";
this->_chain_logger->info("draw_bbox: Saved image to path {}",
rimg_path);
cv::imwrite(rimg_path, rimg);
}
if (_params->output_images)
{
auto action_pred = DTO::Prediction::createShared();
action_pred->vals = DTO::DTOVector<uint8_t>(std::vector<uint8_t>(
rimg.data, rimg.data + (rimg.total() * rimg.elemSize())));
action_pred->uri = uri.c_str();
pred_body->predictions->push_back(action_pred);
}
}
APIData action_out;
action_out.add("data_raw_img", rimgs);
action_out.add("cids", uris);
if (_params->output_images)
{
action_out.add("output", pred_body);
}
cdata.add_action_data(_action_id, action_out);
}
void ClassFilter::apply(oatpp::Object<DTO::PredictBody> &model_out,
ChainData &cdata)
{
if (_params->classes == nullptr)
{
throw ActionBadParamException(
"filter action is missing classes parameter");
}
std::unordered_set<std::string> on_classes_us;
for (auto s : *_params->classes)
on_classes_us.insert(*s);
std::unordered_set<std::string>::const_iterator usit;
auto predictions = model_out->predictions;
for (size_t i = 0; i < predictions->size(); i++)
{
oatpp::Object<DTO::Prediction> pred = predictions->at(i);
auto new_classes
= oatpp::Vector<oatpp::Object<DTO::PredictClass>>::createShared();
for (size_t j = 0; j < pred->classes->size(); j++)
{
std::string cat = pred->classes->at(j)->cat;
if ((usit = on_classes_us.find(cat)) != on_classes_us.end())
{
new_classes->push_back(pred->classes->at(j));
}
}
pred->classes = new_classes;
}
// empty action data
cdata.add_action_data(_action_id, APIData());
// actions_data.push_back(APIData());
}
void *ChainActionFactory::add_chain_action(const std::string &action_name,
const action_function &func)
{
auto ®istry = ChainActionFactory::get_action_registry();
registry[action_name] = func;
return nullptr;
}
std::unordered_map<std::string, action_function> &
ChainActionFactory::get_action_registry()
{
static std::unordered_map<std::string, action_function> registry;
return registry;
}
void ChainActionFactory::apply_action(
const std::string &action_type,
oatpp::Object<DTO::PredictBody> &model_out, ChainData &cdata,
const std::shared_ptr<spdlog::logger> &chain_logger)
{
if (_call_dto->id == nullptr)
{
std::string action_id = std::to_string(cdata._action_data.size());
_call_dto->id = action_id.c_str();
}
auto ®istry = get_action_registry();
auto hit = registry.find(action_type);
if (hit != registry.end())
{
hit->second(_call_dto, model_out, cdata, chain_logger);
}
else
{
throw ActionBadParamException("unknown action " + action_type);
}
}
CHAIN_ACTION("crop", ImgsCropAction)
CHAIN_ACTION("rotate", ImgsRotateAction)
CHAIN_ACTION("recompose", ImgsCropRecomposeAction)
CHAIN_ACTION("draw_bbox", ImgsDrawBBoxAction)
CHAIN_ACTION("filter", ClassFilter)
#ifdef USE_DLIB
CHAIN_ACTION("dlib_align_crop", DlibAlignCropAction)
#endif
} // end of namespace