Skip to content

Commit e0fef9b

Browse files
committed
Revert "remove auto resize"
This reverts commit 6d9f0cd.
1 parent 2770875 commit e0fef9b

31 files changed

+166
-87
lines changed

demos/classification_benchmark_demo/cpp/main.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static const char num_inf_req_message[] = "Optional. Number of infer requests.";
4242
static const char image_grid_resolution_message[] = "Optional. Set image grid resolution in format WxH. "
4343
"Default value is 1280x720.";
4444
static const char ntop_message[] = "Optional. Number of top results. Default value is 5. Must be >= 1.";
45+
static const char input_resizable_message[] = "Optional. Enables resizable input.";
4546
static const char no_show_message[] = "Optional. Disable showing of processed images.";
4647
static const char execution_time_message[] = "Optional. Time in seconds to execute program. "
4748
"Default is -1 (infinite time).";
@@ -59,6 +60,7 @@ DEFINE_string(nstreams, "", num_streams_message);
5960
DEFINE_uint32(nireq, 0, num_inf_req_message);
6061
DEFINE_uint32(nt, 5, ntop_message);
6162
DEFINE_string(res, "1280x720", image_grid_resolution_message);
63+
DEFINE_bool(auto_resize, false, input_resizable_message);
6264
DEFINE_bool(no_show, false, no_show_message);
6365
DEFINE_uint32(time, std::numeric_limits<gflags::uint32>::max(), execution_time_message);
6466
DEFINE_string(u, "", utilization_monitors_message);
@@ -71,6 +73,7 @@ static void showUsage() {
7173
std::cout << " -h " << help_message << std::endl;
7274
std::cout << " -i \"<path>\" " << image_message << std::endl;
7375
std::cout << " -m \"<path>\" " << model_message << std::endl;
76+
std::cout << " -auto_resize " << input_resizable_message << std::endl;
7477
std::cout << " -labels \"<path>\" " << labels_message << std::endl;
7578
std::cout << " -layout \"<string>\" " << layout_message << std::endl;
7679
std::cout << " -gt \"<path>\" " << gt_message << std::endl;
@@ -141,7 +144,7 @@ int main(int argc, char *argv[]) {
141144
i--;
142145
} else {
143146
readerMetrics.update(readingStart);
144-
// Clone cropped image to keep memory layout dense to enable openvino auto resize
147+
// Clone cropped image to keep memory layout dense to enable -auto_resize
145148
inputImages.push_back(centerSquareCrop(tmpImage).clone());
146149
size_t lastSlashIdx = name.find_last_of("/\\");
147150
if (lastSlashIdx != std::string::npos) {
@@ -201,7 +204,7 @@ int main(int argc, char *argv[]) {
201204
slog::info << ov::get_openvino_version() << slog::endl;
202205
ov::Core core;
203206

204-
AsyncPipeline pipeline(std::unique_ptr<ModelBase>(new ClassificationModel(FLAGS_m, FLAGS_nt, labels, FLAGS_layout)),
207+
AsyncPipeline pipeline(std::unique_ptr<ModelBase>(new ClassificationModel(FLAGS_m, FLAGS_nt, FLAGS_auto_resize, labels, FLAGS_layout)),
205208
ConfigFactory::getUserConfig(FLAGS_d, FLAGS_nireq, FLAGS_nstreams, FLAGS_nthreads), core);
206209

207210
Presenter presenter(FLAGS_u, 0);

demos/common/cpp/models/include/models/classification_model.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ class ClassificationModel : public ImageModel {
2727
/// @param modelFileName name of model to load.
2828
/// @param nTop - number of top results.
2929
/// Any detected object with confidence lower than this threshold will be ignored.
30+
/// @param useAutoResize - if true, image will be resized by openvino.
31+
/// Otherwise, image will be preprocessed and resized using OpenCV routines.
3032
/// @param labels - array of labels for every class.
3133
/// @param layout - model input layout
32-
ClassificationModel(const std::string& modelFileName, size_t nTop, const std::vector<std::string>& labels,
33-
const std::string& layout = "");
34+
ClassificationModel(const std::string& modelFileName, size_t nTop, bool useAutoResize,
35+
const std::vector<std::string>& labels, const std::string& layout = "");
3436

3537
std::unique_ptr<ResultBase> postprocess(InferenceResult& infResult) override;
3638

demos/common/cpp/models/include/models/detection_model.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ class DetectionModel : public ImageModel {
2525
/// @param modelFileName name of model to load
2626
/// @param confidenceThreshold - threshold to eliminate low-confidence detections.
2727
/// Any detected object with confidence lower than this threshold will be ignored.
28+
/// @param useAutoResize - if true, image will be resized by openvino.
29+
/// Otherwise, image will be preprocessed and resized using OpenCV routines.
2830
/// @param labels - array of labels for every class. If this array is empty or contains less elements
2931
/// than actual classes number, default "Label #N" will be shown for missing items.
3032
/// @param layout - model input layout
31-
DetectionModel(const std::string& modelFileName, float confidenceThreshold, const std::vector<std::string>& labels,
32-
const std::string& layout = "");
33+
DetectionModel(const std::string& modelFileName, float confidenceThreshold, bool useAutoResize,
34+
const std::vector<std::string>& labels, const std::string& layout = "");
3335

3436
static std::vector<std::string> loadLabels(const std::string& labelFilename);
3537

demos/common/cpp/models/include/models/detection_model_faceboxes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class ModelFaceBoxes : public DetectionModel {
3636
};
3737
static const int INIT_VECTOR_SIZE = 200;
3838

39-
ModelFaceBoxes(const std::string& modelFileName, float confidenceThreshold, float boxIOUThreshold,
40-
const std::string& layout = "");
39+
ModelFaceBoxes(const std::string& modelFileName, float confidenceThreshold, bool useAutoResize,
40+
float boxIOUThreshold, const std::string& layout = "");
4141
std::unique_ptr<ResultBase> postprocess(InferenceResult& infResult) override;
4242

4343
protected:

demos/common/cpp/models/include/models/detection_model_retinaface.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ class ModelRetinaFace
4242
/// @param model_name name of model to load
4343
/// @param confidenceThreshold - threshold to eliminate low-confidence detections.
4444
/// Any detected object with confidence lower than this threshold will be ignored.
45+
/// @param useAutoResize - if true, image will be resized by openvino.
4546
/// @param boxIOUThreshold - threshold for NMS boxes filtering, varies in [0.0, 1.0] range.
4647
/// @param layout - model input layout
47-
ModelRetinaFace(const std::string& model_name, float confidenceThreshold, float boxIOUThreshold,
48-
const std::string& layout = "");
48+
ModelRetinaFace(const std::string& model_name, float confidenceThreshold, bool useAutoResize,
49+
float boxIOUThreshold, const std::string& layout = "");
4950
std::unique_ptr<ResultBase> postprocess(InferenceResult& infResult) override;
5051

5152
protected:

demos/common/cpp/models/include/models/detection_model_retinaface_pt.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ class ModelRetinaFacePT : public DetectionModel {
4646
/// @param model_name name of model to load
4747
/// @param confidenceThreshold - threshold to eliminate low-confidence detections.
4848
/// Any detected object with confidence lower than this threshold will be ignored.
49+
/// @param useAutoResize - if true, image will be resized by openvino.
4950
/// @param boxIOUThreshold - threshold for NMS boxes filtering, varies in [0.0, 1.0] range.
5051
/// @param layout - model input layout
51-
ModelRetinaFacePT(const std::string& modelFileName, float confidenceThreshold, float boxIOUThreshold,
52-
const std::string& layout = "");
52+
ModelRetinaFacePT(const std::string& modelFileName, float confidenceThreshold, bool useAutoResize,
53+
float boxIOUThreshold, const std::string& layout = "");
5354
std::unique_ptr<ResultBase> postprocess(InferenceResult& infResult) override;
5455

5556
protected:

demos/common/cpp/models/include/models/detection_model_ssd.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ class ModelSSD : public DetectionModel {
2727
/// @param modelFileName name of model to load
2828
/// @param confidenceThreshold - threshold to eliminate low-confidence detections.
2929
/// Any detected object with confidence lower than this threshold will be ignored.
30+
/// @param useAutoResize - if true, image will be resized by openvino.
31+
/// Otherwise, image will be preprocessed and resized using OpenCV routines.
3032
/// @param labels - array of labels for every class. If this array is empty or contains less elements
3133
/// than actual classes number, default "Label #N" will be shown for missing items.
3234
/// @param layout - model input layout
3335
ModelSSD(const std::string& modelFileName,
34-
float confidenceThreshold,
36+
float confidenceThreshold, bool useAutoResize,
3537
const std::vector<std::string>& labels = std::vector<std::string>(),
3638
const std::string& layout = "");
3739

demos/common/cpp/models/include/models/detection_model_yolo.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class ModelYolo : public DetectionModel {
5050
/// @param modelFileName name of model to load
5151
/// @param confidenceThreshold - threshold to eliminate low-confidence detections.
5252
/// Any detected object with confidence lower than this threshold will be ignored.
53+
/// @param useAutoResize - if true, image will be resized by openvino.
54+
/// Otherwise, image will be preprocessed and resized using OpenCV routines.
5355
/// @param useAdvancedPostprocessing - if true, an advanced algorithm for filtering/postprocessing will be used
5456
/// (with better processing of multiple crossing objects). Otherwise, classic algorithm will be used.
5557
/// @param boxIOUThreshold - threshold to treat separate output regions as one object for filtering
@@ -59,7 +61,7 @@ class ModelYolo : public DetectionModel {
5961
/// @param anchors - vector of anchors coordinates. Required for YOLOv4, for other versions it may be omitted.
6062
/// @param masks - vector of masks values. Required for YOLOv4, for other versions it may be omitted.
6163
/// @param layout - model input layout
62-
ModelYolo(const std::string& modelFileName, float confidenceThreshold,
64+
ModelYolo(const std::string& modelFileName, float confidenceThreshold, bool useAutoResize,
6365
bool useAdvancedPostprocessing = true, float boxIOUThreshold = 0.5, const std::vector<std::string>& labels = std::vector<std::string>(),
6466
const std::vector<float>& anchors = std::vector<float>(), const std::vector<int64_t>& masks = std::vector<int64_t>(),
6567
const std::string& layout = "");

demos/common/cpp/models/include/models/hpe_model_associative_embedding.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
#include <opencv2/opencv.hpp>
2121
#include <openvino/openvino.hpp>
2222
#include <utils/image_utils.h>
23-
#include "models/model_base.h"
23+
#include "models/image_model.h"
2424
#include <models/results.h>
2525

26-
class HpeAssociativeEmbedding : public ModelBase {
26+
class HpeAssociativeEmbedding : public ImageModel {
2727
public:
2828
/// Constructor
2929
/// @param modelFileName name of model to load

demos/common/cpp/models/include/models/image_model.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ class ImageModel : public ModelBase {
2323
public:
2424
/// Constructor
2525
/// @param modelFileName name of model to load
26+
/// @param useAutoResize - if true, image is resized by openvino
2627
/// @param layout - model input layout
27-
ImageModel(const std::string& modelFileName, const std::string& layout = "")
28-
: ModelBase(modelFileName, layout) {}
28+
ImageModel(const std::string& modelFileName, bool useAutoResize, const std::string& layout = "");
2929

3030
virtual std::shared_ptr<InternalModelData> preprocess(const InputData& inputData, ov::InferRequest& request) override;
3131

3232
protected:
33+
bool useAutoResize;
34+
3335
size_t netInputHeight = 0;
3436
size_t netInputWidth = 0;
3537
};

0 commit comments

Comments
 (0)