Skip to content

All processing in graph demo - #3

Open
mpashchenkov wants to merge 7 commits into
mp/internal_demofrom
mp/internal_scd
Open

All processing in graph demo#3
mpashchenkov wants to merge 7 commits into
mp/internal_demofrom
mp/internal_scd

Conversation

@mpashchenkov

Copy link
Copy Markdown
Owner

No description provided.

@mpashchenkov

mpashchenkov commented Mar 11, 2021

Copy link
Copy Markdown
Owner Author

@aDanPin main.cpp kernels.hpp kernels.cpp

std::istringstream stream_to_split(in_str);

while (std::getline(stream_to_split, label, ',')) {
labels.push_back(label);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two whitespace instead four

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.


slog::info << "Device info: " << slog::endl;

for (const auto &device : devices) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this cycle needed if you use gapi?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Print CPU, GPU info. M B need to cut or change.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of сode carved out

}

// Create tracker for reid
TrackerParams tracker_reid_params;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be initialize using initializer-list?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set of numbers in brackets will create questions.

tracker_reid_params.objects_type = "face";

// Create Tracker for action recognition
TrackerParams tracker_action_params;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set of numbers in brackets will create questions.

if (!fd_model_path.empty()) {
cv::GMat detections =
cv::gapi::infer<nets::FaceDetector>(in);
faces = custom::FaceDetectorPostProc::on( in

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is using some::gapi::stuff::on() not in kernel valid?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

namespace cv {
namespace gapi {
namespace wip {
class GCaptureSource : public IStreamSource

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have same class in out G-API framework, isn`t?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another heir with the same name (GCaptureSource)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For TOP K rising hands case

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is purely a conflict, please rename

if (!no_show_) {
cv::imshow(top_window ? top_window_name_ : main_window_name_, frame);
}
} No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooooooooouuuuu
Sir, one Enter please!!

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@@ -0,0 +1,7 @@
# This file can be used with the --list option of the model downloader.
face-detection-adas-????
face-reidentification-retail-????

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arcface

@@ -1,4 +1,4 @@
#!/usr/bin/env python3

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be risky

@@ -0,0 +1,135 @@
# Smart Classroom C++ Demo

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it is the old file?

@@ -0,0 +1,44 @@
#!/usr/bin/env python

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need our special script here or the standard smart classroom's one can be reused?

@@ -0,0 +1,188 @@
// Copyright (C) 2021 Intel Corporation

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For every file coming from the original demo, can you please mention it in the file's header comment?
It'd simplify the review a lot.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased.

@@ -0,0 +1,50 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased.


ActionDetectorConfig action_config;
ActionDetectionKernelInput ad_kernel_input;
if (!ad_model_path.empty()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd instead introduce operator+= for a network package like @aDanPin did for graph arguments.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. But it doesn't solve this problem.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it will, see on the right

GetBinPath(ad_model_path),
FLAGS_d_act,
}.cfgOutputLayers(outputBlobList);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move all of this out of main(). It makes reading and understanding the main() flow really hard when it is that long.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to .hpp. Added comments for main steps.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what is moved where but the code producing the network packages based on options is still there.

May not be a problem now, though.

}
slog::info << "Execution successful" << slog::endl;
return 0;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please decompose main() into pieces. What I'd expect to see there is only building GComputation object. Everything else (e.g. preparing compile arguments) should be moved out.

@@ -0,0 +1,404 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can all these kernels be thin wrappers over the functionality written in the original smart classroom?

Such approach would better illustrate the idea how cheap is moving from "traditional" code to G-API execution model.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Some code depends on IE. Drawing depends on KuhnMunkers ....

@@ -0,0 +1,580 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it inherited or not?

@mpashchenkov
mpashchenkov force-pushed the mp/internal_scd branch 2 times, most recently from bbba898 to 8835cdf Compare April 1, 2021 10:59

@dmatveev dmatveev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please complete the clean-up and let's move it to OMZ repo.

config::createFaceRecPtr(frec_kernel_input, rec_config);
face_id_to_label_map = frec_kernel_input.ptr->GetIDToLabelMap();
}
} // namespace preparation No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline is missing


namespace cv {
namespace gapi {
namespace wip {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a cv::gapi thing so no need to put these fake namespaces here. It is a custom input source written to handle the app specifics.


} // namespace
std::string GetBinPath(const std::string &pathXML) {
CV_Assert(pathXML.substr(pathXML.size() - 4, pathXML.size()) == ".xml");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fail with .XML. Not sure if it is the case though

std::string GetBinPath(const std::string &pathXML) {
CV_Assert(pathXML.substr(pathXML.size() - 4, pathXML.size()) == ".xml");
std::string pathBIN(pathXML);
return pathBIN.replace(pathBIN.size() - 3, 3, "bin");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may not work with .BIN in a case-sensitive OS/FS. Still, not sure if it is the case

loadedDevices.insert(device);
}
/** Create default net's parameters **/
cv::gapi::ie::Params<nets::FaceDetector> det_net({}, {}, {});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't say I like it.

So do we have operator+= for GNetworkPackage?

Comment on lines +199 to +201
cv::GArray<cv::GMat> embeddings(std::vector<cv::Mat>{});
cv::GArray<DetectedAction> persons_with_actions(std::vector<DetectedAction>{});
cv::GArray<detection::DetectedObject> faces(std::vector<detection::DetectedObject>{});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it needs to be value-initialized like this?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got the idea but please put a comment since it may be not very obvious for the reader. :)

outs += GOut(top_k);
}
/** Draw ROI and labels **/
auto rendered = cv::gapi::wip::draw::render3ch(frame,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if you do rendering, do you need the original frame to be among the inputs?

If the rendering is optional, I'd either produce the original input image intact OR a rendered one as the same graph output.

Comment on lines +275 to +277
networks,
TrackerParamsPack{ tracker_reid_params, tracker_action_params },
logger_params));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably this block should be indented deeper here, but it may change with the OMZ guidelines.

face_detector->enqueue(frame);
face_detector->submitRequest();
}
cc.setSource(cv::gin(cv::gapi::wip::make_src<cv::gapi::wip::CustomCapSource>(cap)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use setSource<>() version since it is less scary (no make_src is required)

/** TOP_K part. SPACE_KEY is pushed, monitoring enabled
* Compile and start graph **/
if (!cap.grab()) break;
cc.setSource(cv::gin(cv::gapi::wip::make_src<cv::gapi::wip::CustomCapSource>(cap)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use setSource<>()

@dmatveev

Copy link
Copy Markdown

@mpashchenkov is gallery/infer2 thing already pushed here? I don't see any updates since my last comment on this PR.

Is it done at the OMZ repo already? Should this PR be closed then?

@dmatveev dmatveev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please go ahead with the OMZ integration.

Comment on lines +69 to +80
bool fileExists(const std::string& name) {
std::ifstream f(name.c_str());
return f.good();
}

std::string folderName(const std::string& path) {
size_t found_pos;
found_pos = path.find_last_of(separator());
if (found_pos != std::string::npos)
return path.substr(0, found_pos);
return std::string(".") + separator();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see too much code for .hpp here, and the functions are neither static nor inline

May cause problems if the header is included more than once

Also, don't see a point in having so much code in .hpp if it is not a template.

slog::err << "Cannot find target action: " << FLAGS_top_id << slog::endl;
return 1;
}
cv::VideoCapture cap(video_path != "cam" ? video_path : 0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure how this ?: works but barely remember that both true- and false- branch should have the same expression type. MAYBE it results into a proper constructor overload being called but I don't really know.

const std::vector<cv::Mat>& landmarks,
const std::vector<cv::Rect>& face_rois,
std::vector<cv::Mat>& out_images) {
cv::Mat out_image = in.clone();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need this clone?
Does AlignFaces works really inplace or reallocate its every face image?

mpashchenkov pushed a commit that referenced this pull request Apr 27, 2021
mpashchenkov pushed a commit that referenced this pull request Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants