-
Notifications
You must be signed in to change notification settings - Fork 346
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
IDTReeS - Clip boxes outside of image bounds #760
Conversation
The coordinate swap was already done in #683 |
@ashnair1 Thanks for pointing that out. Totally missed it. |
Created generic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code logic and docstrings seems to be sound. Did you check the image and box alignment? I'm not quite sure how to interpret the sample image you posted at #760 (comment), the colors look a bit weird 😅
Yes. I don't select the colors. torchvision's |
Just wanted to add some notes for everyone's clarity on the dataset.
{
'geometry': {'coordinates': [[(541886.6194198467, 4136580.9452913683),
(541886.6194198467, 4136588.0890556537),
(541891.3025542134, 4136588.0890556537),
(541891.3025542134, 4136580.9452913683),
(541886.6194198467, 4136580.9452913683)]],
'type': 'Polygon'},
'id': '0',
'properties': OrderedDict([('indvdID', 'MLBSE00048'),
('plotID', 'MLBS_1.tif')]),
'type': 'Feature'
}
{
'geometry': {'coordinates': [[(542071.1868343, 4134996.0734410095),
(542071.1868343, 4134999.0),
(542074.96994003, 4134999.0),
(542074.96994003, 4134996.0734410095),
(542071.1868343, 4134996.0734410095)]],
'type': 'Polygon'},
'id': '0',
'properties': OrderedDict([('id', 57), ('indvdID', 'MLBS01681')]),
'type': 'Feature'
} The image <-> geometry id mapping is inside "id","indvdID","rsFile"
57,"MLBS01681","MLBS_1.tif"
45,"MLBS01679","MLBS_1.tif"
49,"MLBS01674","MLBS_1.tif"
63,"MLBS01678","MLBS_1.tif"
... Note that the test set does not have any csv files only the train set. Because of this, the implementation for parsing the dataset can become quite verbose and requires different logic for the the train set, test set - task1, and test set - task2. Hopefully this clarifies some of the implementation decisions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I think I finally understand the code well enough to review this now!
So if I understand correctly, this PR only solves issue (3) in #684. Once this PR is merged, A) all bounding boxes will be clipped to the image bounds which will fix plotting, and B) bounding boxes won't be accidentally deleted from the testing set due to integer overlap.
My only change request is to replace the current id = len(features) + 1
logic with a counter i = 0, i += 1
so we aren't computing the length of a list in each iteration.
I've made the requested change. Also note that this PR doesn't just fix plotting but also allows a user to actually train on the dataset whereas before you would have issues dealing with boxes with negative values. |
* reverse idtrees coords * clip boxes to image bounds * undo coordinate reversal * add filter_boxes function * filter boxes outside of bounds in idtrees * format * Revert utils.py * flake8 fixes * fix mypy errors * fix bug overriding some labels * fix image size * Remove version added line * add function overloads * add comments for clarity * use id counter for test set
* reverse idtrees coords * clip boxes to image bounds * undo coordinate reversal * add filter_boxes function * filter boxes outside of bounds in idtrees * format * Revert utils.py * flake8 fixes * fix mypy errors * fix bug overriding some labels * fix image size * Remove version added line * add function overloads * add comments for clarity * use id counter for test set
This PR
Fixes part of #684
For
MLBS_5
the boxes beforeand after filtering
Visual result: