-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
detectnet/clustering.py incorrectly calculates bounding box height #557
Comments
Actually, as I look closer, the issue is move invasive. clustering.py assumes |
Is there a better venue for this discussion? I haven't received a response on nvidia's forums. |
hi @samsparks sorry for the delay. I'm trying this but I'd appreciate some sample/unit test to check that it works correctly |
Sure, @drnikolaev, I would be happy to provide example code. However, as this is an interface issue between clustering.py and opencv, I'm not sure what to provide beyond an inspection of the code. Lines 167-172 show the extraction of the top left and bottom right coordinates of each bounding box into candidate boxes
These coordinates are returned from
Finally (unless I am missing something), these values are passed without being converted properly to (x, y, width, height) in
This looks wrong based on the opencv documentation. Additionally, I rebuilt opencv to test the interface after posting this question on their forum. By adding debug statements to the implementation of Do you have an idea for what I can provide as example code? I am happy to do whatever I can to help. |
@samsparks please just give me example how exactly you execute |
Hi @drnikolaev - I have not forgotten about this. Unfortunately, I do not have a trained model I can provide, and DIGITS does not allow testing of pretrained models :-(. So I am going to have to train something from scratch. In the meantime, I have and example where I modified clustering.py to print out the input to group rectangles right before it is called, as follows: This output the following set of bounding boxes in clustering.py: And it returns: Passing the values in c++ return the following I expect these two to match, but they do not. I think the problem is in how clustering.py is calling groupRectangles() The full source of the example can be found here |
Hi @drnikolaev - I used the default DIGITS DetectNet (KITTI) model and KITTI images contained in data_object_image_2.zip. The two images 003716.png and 003719.png provide good examples for the problem.
I can reproduce this reliably in jetson-inference only by malforming the construction of I believe the current implementation of clustering.py works most of the time because See my fork of jetson-inference for the "broken" C++ code that replicates clustering.py. There is a define of Please note this will change the required values for epsilon. I plan on retraining my network after applying the following patch: index 380df4a..d5c0589 100644
--- a/python/caffe/layers/detectnet/clustering.py
+++ b/python/caffe/layers/detectnet/clustering.py
@@ -188,14 +188,14 @@ def vote_boxes(propose_boxes, propose_cvgs, mask, self):
# GROUP RECTANGLES Clustering
######################################################################
nboxes, weights = cv.groupRectangles(
- np.array(propose_boxes).tolist(),
+ [[e[0],e[1],e[2]-e[0],e[3]-e[1]] for e in np.array(propose_boxes).tolist()],
self.gridbox_rect_thresh,
self.gridbox_rect_eps)
if len(nboxes):
for rect, weight in zip(nboxes, weights):
- if (rect[3] - rect[1]) >= self.min_height:
+ if rect[3] >= self.min_height:
confidence = math.log(weight[0])
- detection = [rect[0], rect[1], rect[2], rect[3], confidence]
+ detection = [rect[0], rect[1], rect[0]+rect[2], rect[1]+rect[3], confidence]
detections_per_image.append(detection)
return detections_per_image |
Fixed in v0.17.3 |
vote_boxes()
in clustering.py calculates each detection height by subtracting each bounding box's index 1 from index 3.However, since a bounding box is a
cv::Rect
, index 3 is height and index 1 is y. The clustering algorithm should test bounding box height as follows:The text was updated successfully, but these errors were encountered: