-
Notifications
You must be signed in to change notification settings - Fork 11
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
To tile coords #939
To tile coords #939
Conversation
Codecov Report
@@ Coverage Diff @@
## master #939 +/- ##
==========================================
+ Coverage 95.82% 95.88% +0.05%
==========================================
Files 26 26
Lines 3211 3233 +22
==========================================
+ Hits 3077 3100 +23
+ Misses 134 133 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Great work @XinyueLi1012! I timed both the old and new versions of The output from both implementations usually matches, so I think the new implementation is at least nearly right. (Possibly it is perfect and the old implementation is slightly off.) But I'm reluctant to merge until they match exactly or until we're really confident that the new version is correct. Please see my trial below. The difference may have to do with how these two implementations handle negative locations. Should we be filtering sources with out-of-bounds locations (either too high or too low) as part of our data augmentation procedure?
|
Also, would you add a test to verify that if we rotate a catalog by 90 degrees and next by 270 degree, then we get back the original catalog? (Or do we already have a test like that?) |
Thanks for the testing results. I didn't do much testing for the new implementation so I'm also a little worry about some special cases. I'll add some tests for the new implementation and data augmentation. |
@jeff-regier I added some filtering for the negative "locs" in the |
Thanks @XinyueLi1012. Before we merge, can you also verify that our performance on DC2 stays the same with this PR? |
_, aug_full270 = aug_rotate270(origin_full, aug_input_images) | ||
|
||
_, aug_full90180 = aug_rotate180(aug_full90, aug_image90) | ||
_, aug_full90270 = aug_rotate270(aug_full90, aug_image90) |
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.
This is a good test to have, but I realize it doesn't quite test what I thought it would, because there's no conversion btw tile and full catalogs happening.
Would you add an additional test that converts from a tile catalog to a full catalog and then back again to a tile catalog? (And that the first and last tile catalogs are equal?)
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.
Yes make sense
bliss/catalog.py
Outdated
x0_mask = (plocs_ii[:, 0] > 0) & (plocs_ii[:, 0] < self.height) | ||
x1_mask = (plocs_ii[:, 1] > 0) & (plocs_ii[:, 1] < self.width) | ||
x_mask = x0_mask * x1_mask | ||
n_filter_sources = x_mask.sum() |
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.
I think it'd be better to do the filtering only on demand: better to give users an error if they try to convert catalog formats without first removing out-of-bounds locations. Would you a new method called something like filter_out_of_bounds
? And then call that method following data augmentation?
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.
That would be tricky. Let me have a try first.
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.
Here's an alternative that may be less tricky: add a keyword argument to to_tile_coords
called filter_oob
which is false by default. Only if it's true will we filter light sources that are out of bounds (either too negative or too large).
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.
that's clever
bliss/catalog.py
Outdated
@@ -504,7 +510,9 @@ def to_tile_params( | |||
mask_sources = mask_sources.scatter_(1, top_indices, 1) & source_mask | |||
|
|||
# get n_sources for each tile | |||
tile_n_sources[ii] = mask_sources.reshape(n_tiles_h, n_tiles_w, n_sources).sum(-1) | |||
tile_n_sources[ii] = mask_sources.reshape(n_tiles_h, n_tiles_w, n_filter_sources).sum( | |||
-1 |
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.
Please shorten a variable name here or somehow rewrite this assignment so there isn't a stray -1
alone on a line.
Some times when I run new |
avoid for loop over tiles
-- use sort(), it would be slow when the image is big (eg. 4000* 4000)