All processing in graph demo - #3
Conversation
|
@aDanPin main.cpp kernels.hpp kernels.cpp |
e4806bb to
45101a5
Compare
| std::istringstream stream_to_split(in_str); | ||
|
|
||
| while (std::getline(stream_to_split, label, ',')) { | ||
| labels.push_back(label); |
|
|
||
| slog::info << "Device info: " << slog::endl; | ||
|
|
||
| for (const auto &device : devices) { |
There was a problem hiding this comment.
Print CPU, GPU info. M B need to cut or change.
There was a problem hiding this comment.
Part of сode carved out
| } | ||
|
|
||
| // Create tracker for reid | ||
| TrackerParams tracker_reid_params; |
There was a problem hiding this comment.
Could it be initialize using initializer-list?
There was a problem hiding this comment.
Set of numbers in brackets will create questions.
| tracker_reid_params.objects_type = "face"; | ||
|
|
||
| // Create Tracker for action recognition | ||
| TrackerParams tracker_action_params; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Is using some::gapi::stuff::on() not in kernel valid?
| namespace cv { | ||
| namespace gapi { | ||
| namespace wip { | ||
| class GCaptureSource : public IStreamSource |
There was a problem hiding this comment.
We already have same class in out G-API framework, isn`t?
There was a problem hiding this comment.
Another heir with the same name (GCaptureSource)
There was a problem hiding this comment.
For TOP K rising hands case
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Ooooooooouuuuu
Sir, one Enter please!!
ad76ace to
0f45376
Compare
| @@ -0,0 +1,7 @@ | |||
| # This file can be used with the --list option of the model downloader. | |||
| face-detection-adas-???? | |||
| face-reidentification-retail-???? | |||
ca51988 to
7f02574
Compare
| @@ -1,4 +1,4 @@ | |||
| #!/usr/bin/env python3 | |||
| @@ -0,0 +1,135 @@ | |||
| # Smart Classroom C++ Demo | |||
| @@ -0,0 +1,44 @@ | |||
| #!/usr/bin/env python | |||
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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.
| @@ -0,0 +1,50 @@ | |||
| // Copyright (C) 2021 Intel Corporation | |||
| // SPDX-License-Identifier: Apache-2.0 | |||
|
|
||
| ActionDetectorConfig action_config; | ||
| ActionDetectionKernelInput ad_kernel_input; | ||
| if (!ad_model_path.empty()) { |
There was a problem hiding this comment.
I'd instead introduce operator+= for a network package like @aDanPin did for graph arguments.
There was a problem hiding this comment.
Hmm. But it doesn't solve this problem.
| GetBinPath(ad_model_path), | ||
| FLAGS_d_act, | ||
| }.cfgOutputLayers(outputBlobList); | ||
| } |
There was a problem hiding this comment.
I'd move all of this out of main(). It makes reading and understanding the main() flow really hard when it is that long.
There was a problem hiding this comment.
Moved to .hpp. Added comments for main steps.
There was a problem hiding this comment.
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; | ||
| } |
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 | |||
bbba898 to
8835cdf
Compare
dmatveev
left a comment
There was a problem hiding this comment.
👍
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 |
|
|
||
| namespace cv { | ||
| namespace gapi { | ||
| namespace wip { |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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({}, {}, {}); |
There was a problem hiding this comment.
Can't say I like it.
So do we have operator+= for GNetworkPackage?
| 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>{}); |
There was a problem hiding this comment.
Does it needs to be value-initialized like this?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
| networks, | ||
| TrackerParamsPack{ tracker_reid_params, tracker_action_params }, | ||
| logger_params)); |
There was a problem hiding this comment.
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))); |
There was a problem hiding this comment.
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))); |
|
@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? |
a3f5cb4 to
967e17c
Compare
dmatveev
left a comment
There was a problem hiding this comment.
Please go ahead with the OMZ integration.
| 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(); | ||
| } |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Do you really need this clone?
Does AlignFaces works really inplace or reallocate its every face image?
No description provided.