Fixes #22747. Support [crop] configuration for DarkNet#24384
Fixes #22747. Support [crop] configuration for DarkNet#24384asmorkalov merged 2 commits intoopencv:4.xfrom
Conversation
|
It makes sense to add test to avoid regressions in the future
|
Yes sure @opencv-alalek. I will add the tests very soon. Can you please assign this issue to me. |
| int crop_width = getParam<int>(layer_params, "crop_width", 224); | ||
| int flip = getParam<int>(layer_params, "flip", 1); | ||
| int exposure = getParam<int>(layer_params, "exposure", 1); | ||
| int saturation = getParam<int>(layer_params, "saturation", 1); |
There was a problem hiding this comment.
Please use boolean parameters for true/false flags:
bool flip = getParam<bool>(layer_params, "flip", true);
There was a problem hiding this comment.
Yes. thankyou @dkurt. I will make the changes asap.
|
@dkurt @opencv-alalek Hi guys, I am trying to add the test layers. Its actually a lot of test layers and I am finding it hard to understand the parameters and add it accordingly. I added a couple until now idk if they are correct. Can you guys help me with any resources or tell me how can I go about this problem. It would be a great help. thanks :) (request for comments) |
|
@Dhanwanth1803, you can create a single layer network similar to models from https://github.com/opencv/opencv_extra/tree/4.x/testdata/dnn/darknet. Then, use a script generate_darknet_models.py to create test data files. As Crop layer has no weights, it's enough to write only a After that, add all the generated files to a new branch to opencv_extra with the same name: |
Thank you @dkurt. I will be working on it. |
|
@dkurt Like you said, i tried to generate test data files using generate_darknet_models.py . But it gave me the following error. |
|
@dkurt I have installed darknet and set the path using
This is happening for every function call trying to read a |
|
@Dhanwanth1803, Run the script from |
@dkurt I have put up PR in |
I have put up a PR again @dkurt . Please check it out. |
| fused_layer_names.push_back(last_layer); | ||
| } | ||
|
|
||
| void setCrop(int crop_height, int crop_width, int flip, int exposure, int saturation, int angle) |
There was a problem hiding this comment.
Unused arguments. How layer can work without them?
Okay. Will do. |
|
@Dhanwanth1803 Friendly reminder. |
have exams currently in my school right now. I continue on 8th November. Is that fine? |
@dkurt Should I add a test to
@dkurt I have made changes for addition of crop layer in |
|
@Dhanwanth1803 the PR still includes changes for single file. Looks like you forgot to add test changes to the commit. |
2a33772 to
4f209a0
Compare
|
Please remove an old branch https://github.com/Dhanwanth1803/opencv_extra/tree/feat-crop |
Yes Sir deleted just now/ |
|
@Dhanwanth1803, please make test pass locally. Build OpenCV with For now problem is not solved: |
| crop_param.set<int>("crop_height", crop_height); | ||
| crop_param.set<int>("crop_width", crop_width); | ||
| crop_param.name = "CropLayer-name"; | ||
| crop_param.type = "CropLayer"; |
There was a problem hiding this comment.
There is no "CropLayer" in OpenCV - just "Crop"
There was a problem hiding this comment.
Moreover, there is no crop_height and crop_width attributes for Crop. You need to utilize Slice with it's begin, end or size (https://github.com/opencv/opencv/blob/4.x/modules/dnn/src/layers/slice_layer.cpp):
std::vector<int> begin = {0, 0, 0, 0};
std::vector<int> sizes = {-1, -1, crop_height, crop_width};
crop_param.set("begin", DictValue::arrayInt(&begin[0], begin.size()));
crop_param.set("size", DictValue::arrayInt(&sizes[0], sizes.size()));
crop_param.type = "Slice";There was a problem hiding this comment.
if crop_height and crop_width are not attributes for crop. Why did we generate test data using those parameters in opencv_extra
There was a problem hiding this comment.
These are native Darknet names and this is ok for test data. Importer should remap this parameters to expected ones by OpenCV
There was a problem hiding this comment.
Okay. I will replace it with the code snippet you gave.
|
@Dhanwanth1803 Friendly reminder |
Yes sir still working on it @asmorkalov |
|
|
@asmorkalov, GitHub Actions CI ignores Merge with extra which points to a different branch name. Buildbot CI passes. |
|
@dkurt Extra CI options are handled by buildbot only. Please ignore Github actions for now. |
|
@dkurt Thank you for making the changes. I was not able to work for personal reasons I will continue to contribute soon. |
Fixes opencv#22747. Support [crop] configuration for DarkNet opencv#24384 Request for comments. This is my first PR. **Merge with extra**: opencv/opencv_extra#1112 resolves opencv#22747 - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake

Request for comments. This is my first PR.
Merge with extra: opencv/opencv_extra#1112
resolves #22747
Patch to opencv_extra has the same branch name.