Feature: Filter k most confident masks (#720)

* add filter to things that return confidences need to add ui elements to select between the two methods

* add ui elements for controlling method

* forgot to remove this

* fix incorrect early exit

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: pop mask only top k params

* fix: filter confidences

* refactor: change to one public function

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dowon <ks2515@naver.com>
This commit is contained in:
Collin Avidano
2024-09-25 07:12:28 -04:00
committed by GitHub
parent 03ec9d004a
commit 9ceb58685a
7 changed files with 56 additions and 11 deletions

View File

@@ -294,14 +294,21 @@ def detection(w: Widgets, n: int, is_img2img: bool):
visible=True,
elem_id=eid("ad_confidence"),
)
w.ad_mask_k_largest = gr.Slider(
label="Mask only the top k largest (0 to disable)" + suffix(n),
w.ad_mask_filter_method = gr.Radio(
choices=["Area", "Confidence"],
value="Area",
label="Method to filter top k masks by (confidence or area)",
visible=True,
elem_id=eid("ad_mask_filter_method"),
)
w.ad_mask_k = gr.Slider(
label="Mask only the top k (0 to disable)" + suffix(n),
minimum=0,
maximum=10,
step=1,
value=0,
visible=True,
elem_id=eid("ad_mask_k_largest"),
elem_id=eid("ad_mask_k"),
)
with gr.Column(variant="compact"):