Start a category mask where the photograph can bear it
Clicking "architecture" made a layer whose mask was gone. Every category layer began at STRICTNESS_DEFAULT, and that constant was fitted on the synthetic sky the refine tests build — its own note warns that a real photograph's noise "moves every crossing down together", which turns out to be a considerable understatement. Measured over seven ordinary frames, half scale removes 76% to 99.5% of `architecture`, 36% to 93% of `ground` and 18% to 91% of `vegetation`. Only sky, the category the number was calibrated against, survives it. An empty mask is indistinguishable from a broken one: the layer is listed, the adjustment moves, and no pixel changes. So what this looks like from outside is that the segmentation does not make masks at all. No smaller constant fixes it either, because a nat of evidence means different things over a smooth sky and over a stone facade — the useful position is above 5 on one frame and below 1 on the next. So the frame is asked instead: `Refinement::gentle` walks down from half scale and takes the first rung whose gate removes no more than a sixth of the category's weight, and the model's own outline when none of them does. One `apply` on a friendly photograph and four on an unfriendly one, paid when a layer is made rather than for eight categories nobody masked. The slider's reset went to 4 as well, so taking the control back to its "default" emptied the mask. It goes to zero now, which is the one position documented to mean something: exactly what the model weighted.
This commit is contained in:
@@ -201,6 +201,28 @@ impl Segmentation {
|
||||
.is_some_and(|c| c.refinement.is_some())
|
||||
}
|
||||
|
||||
/// Where this category's refine control should start on *this*
|
||||
/// photograph.
|
||||
///
|
||||
/// [`dr_segment::STRICTNESS_OFF`] where nothing was fitted, and otherwise
|
||||
/// whatever [`dr_segment::Refinement::gentle`] finds the frame will bear —
|
||||
/// see there for why a constant could not do it and what a constant cost.
|
||||
///
|
||||
/// Costs one to four `apply` passes, tens of milliseconds each. That is
|
||||
/// why it is asked here, when a layer is made, rather than for every
|
||||
/// category during the precompute: eight categories nobody masked would be
|
||||
/// seconds added to a wait, and the answer is only wanted for the one that
|
||||
/// was clicked.
|
||||
pub fn category_default_refine(&self, name: &str) -> f32 {
|
||||
self.categories
|
||||
.iter()
|
||||
.find(|c| &*c.name == name)
|
||||
.and_then(|c| Some((c.refinement.as_ref()?, &c.mask)))
|
||||
.map_or(dr_segment::STRICTNESS_OFF, |(refinement, mask)| {
|
||||
refinement.gentle(mask)
|
||||
})
|
||||
}
|
||||
|
||||
/// Replace one instance in place, keeping every other index and the
|
||||
/// signature unchanged.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user