-
Notifications
You must be signed in to change notification settings - Fork 84
Fix hang on using IGNORE with --sample-masks option #98
Conversation
//random candidates | ||
for _ in 0..m_rand { | ||
let rand_map = (rng.gen_range(0, example_maps.len())) as u32; | ||
let mut rand_map = (rng.gen_range(0, example_maps.len())) as u32; |
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.
The problem was if we chose a map which was ignored, we'd keep looping forever here
loop { |
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'm wondering if it may be better to change this whole method to sample from a list of valid locations across images rather than the current draw / check loops. I think in the case of large images with tiny valid sample masks the current method could take a while to find a valid pixel. But I'm not sure how common that type of case is and this is the smaller code change.
It might also be possible to maybe just filter out the ignore images at the beginning of the main_resolve_loop or even in lib.
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, I think filtering out the ignore images once at the beginning of the resolve loop makes the most sense.
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.
👍
//random candidates | ||
for _ in 0..m_rand { | ||
let rand_map = (rng.gen_range(0, example_maps.len())) as u32; | ||
let mut rand_map = (rng.gen_range(0, example_maps.len())) as u32; |
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, I think filtering out the ignore images once at the beginning of the resolve loop makes the most sense.
Checklist
Description of Changes
Resolves the hang issue in the discussion of #86. I will add also add sample mask tests tomorrow.
The hang can be reproduced by running
cargo run --release -- --sample-masks ALL IGNORE -o imgs/out.png generate imgs/1.jpg imgs/1.jpg
on current master