Skip to content

Commit

Permalink
Added threshold parameter to detector runner (#9011)
Browse files Browse the repository at this point in the history
Added an input field to detector runner UI with threshold parameter. Theparameter already supported by the server.
  • Loading branch information
klakhov authored Jan 31, 2025
1 parent 7484e4d commit 30e900b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
4 changes: 4 additions & 0 deletions changelog.d/20250129_140847_klakhov_add_detector_threshold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Added

- A `threshold` parameter to UI detector runner
(<https://github.com/cvat-ai/cvat/pull/9011>)
27 changes: 26 additions & 1 deletion cvat-ui/src/components/model-runner-modal/detector-runner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Button from 'antd/lib/button';
import Switch from 'antd/lib/switch';
import Tag from 'antd/lib/tag';
import notification from 'antd/lib/notification';
import { ArrowRightOutlined } from '@ant-design/icons';
import { ArrowRightOutlined, QuestionCircleOutlined } from '@ant-design/icons';

import CVATTooltip from 'components/common/cvat-tooltip';
import { clamp } from 'utils/math';
Expand Down Expand Up @@ -72,6 +72,7 @@ function DetectorRunner(props: Props): JSX.Element {
const [cleanup, setCleanup] = useState<boolean>(false);
const [mapping, setMapping] = useState<FullMapping>([]);
const [convertMasksToPolygons, setConvertMasksToPolygons] = useState<boolean>(false);
const [detectorThreshold, setDetectorThreshold] = useState<number | null>(null);
const [modelLabels, setModelLabels] = useState<LabelInterface[]>([]);
const [taskLabels, setTaskLabels] = useState<LabelInterface[]>([]);

Expand Down Expand Up @@ -179,6 +180,29 @@ function DetectorRunner(props: Props): JSX.Element {
<Text>Clean previous annotations</Text>
</div>
)}
{isDetector && (
<div className='cvat-detector-runner-threshold-wrapper'>
<Row align='middle' justify='start'>
<Col>
<InputNumber
min={0.01}
step={0.01}
max={1}
value={detectorThreshold}
onChange={(value: number | null) => {
setDetectorThreshold(value);
}}
/>
</Col>
<Col>
<Text>Threshold</Text>
<CVATTooltip title='Minimum confidence threshold for detections. Leave empty to use the default value specified in the model settings'>
<QuestionCircleOutlined className='cvat-info-circle-icon' />
</CVATTooltip>
</Col>
</Row>
</div>
)}
{isReId ? (
<div>
<Row align='middle' justify='start'>
Expand Down Expand Up @@ -236,6 +260,7 @@ function DetectorRunner(props: Props): JSX.Element {
mapping: serverMapping,
cleanup,
conv_mask_to_poly: convertMasksToPolygons,
...(detectorThreshold !== null ? { threshold: detectorThreshold } : {}),
});
} else if (model.kind === ModelKind.REID) {
runInference(model, { threshold, max_distance: distance });
Expand Down
11 changes: 9 additions & 2 deletions cvat-ui/src/components/model-runner-modal/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,15 @@
}

.cvat-detector-runner-clean-previous-annotations-wrapper,
.cvat-detector-runner-convert-masks-to-polygons-wrapper {
span {
.cvat-detector-runner-convert-masks-to-polygons-wrapper,
.cvat-detector-runner-threshold-wrapper {
.ant-typography {
margin-left: $grid-unit-size;
}
}

.cvat-detector-runner-threshold-wrapper {
.cvat-info-circle-icon {
margin-left: $grid-unit-size;
}
}

0 comments on commit 30e900b

Please sign in to comment.