Skip to content
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

Running detectors on the fly #2102

Merged
merged 34 commits into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7dc7d50
Draft version
bsekachev Aug 19, 2020
cc78167
Removed extra file
bsekachev Aug 19, 2020
2cab41f
Removed extra code
bsekachev Aug 19, 2020
199c264
Updated icon: magic wand
bsekachev Aug 19, 2020
c3132d1
Ctrl modifier, fixed some cases when interaction event isn't raised
bsekachev Aug 19, 2020
c9dab60
Added tooltip description of an interactor
bsekachev Aug 20, 2020
2ad4ae6
Locking UI while server fetching
bsekachev Aug 20, 2020
c9fd42e
Removing old code & refactoring
bsekachev Aug 20, 2020
e477092
Fixed couple of bugs
bsekachev Aug 20, 2020
6b17687
Updated CHANGELOG.md, updated versions
bsekachev Aug 20, 2020
39cb399
Merged develop
bsekachev Aug 20, 2020
61f7104
Update crosshair.ts
bsekachev Aug 20, 2020
7a3015c
Merge branch 'develop' into bs/canvas_interaction
bsekachev Aug 21, 2020
057f41a
Minor fixes
bsekachev Aug 21, 2020
e757383
Fixed eslint issues
bsekachev Aug 21, 2020
aff79eb
Prevent default action
bsekachev Aug 24, 2020
6ded57b
Added minNegVertices=0 by default, ignored negative points for dextr,…
bsekachev Aug 25, 2020
137a4dc
Merge branch 'develop' into bs/canvas_interaction
bsekachev Aug 27, 2020
ab54158
On the fly annotations draft
bsekachev Aug 27, 2020
25df34b
Initial version of FBRS interactive segmentation
Aug 27, 2020
7f81a9d
Merge remote-tracking branch 'origin/nm/fbrs_interactive_segmentation…
Aug 27, 2020
820e498
Fix fbrs model_handler
Aug 27, 2020
daeaf75
Fixed couple of minor bugs
bsekachev Aug 28, 2020
9e7ebcc
Added ability to interrupt interaction
bsekachev Aug 28, 2020
8aeda4a
Merge branch 'bs/canvas_interaction' into bs/on_the_fly_detection
bsekachev Aug 31, 2020
0b7f89c
Do not show reid on annotation view
bsekachev Aug 31, 2020
a15200b
Prettified UI
bsekachev Aug 31, 2020
ad9aba6
Updated changelog, increased version
bsekachev Aug 31, 2020
0aeb7cb
Merged develop
bsekachev Sep 1, 2020
efe8e50
Removed extra files
bsekachev Sep 1, 2020
3d6f13d
Removed extra code
bsekachev Sep 1, 2020
9b487ec
Merged develop
bsekachev Sep 1, 2020
d5e3da5
Fixed changelog
bsekachev Sep 1, 2020
6cf26e8
Merged develop
bsekachev Sep 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added password reset functionality (<https://github.com/opencv/cvat/pull/2058>)
- Ability to work with data on the fly (https://github.com/opencv/cvat/pull/2007)
- Annotation in process outline color wheel (<https://github.com/opencv/cvat/pull/2084>)
- On the fly annotation using DL detectors (<https://github.com/opencv/cvat/pull/2102>)
- [Datumaro] CLI command for dataset equality comparison (<https://github.com/opencv/cvat/pull/1989>)

### Changed
Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cvat-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-ui",
"version": "1.9.1",
"version": "1.9.2",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Select, { OptionProps } from 'antd/lib/select';
import Button from 'antd/lib/button';
import Modal from 'antd/lib/modal';
import Text from 'antd/lib/typography/Text';
import Tabs from 'antd/lib/tabs';
import { Row, Col } from 'antd/lib/grid';
import notification from 'antd/lib/notification';

Expand All @@ -23,8 +24,14 @@ import {
ObjectType,
ShapeType,
} from 'reducers/interfaces';
import { interactWithCanvas, fetchAnnotationsAsync, updateAnnotationsAsync } from 'actions/annotation-actions';
import {
interactWithCanvas,
fetchAnnotationsAsync,
updateAnnotationsAsync,
createAnnotationsAsync,
} from 'actions/annotation-actions';
import { InteractionResult } from 'cvat-canvas/src/typescript/canvas';
import DetectorRunner from 'components/model-runner-modal/detector-runner';

interface StateToProps {
canvasInstance: Canvas;
Expand All @@ -35,11 +42,13 @@ interface StateToProps {
isInteraction: boolean;
frame: number;
interactors: Model[];
detectors: Model[];
}

interface DispatchToProps {
onInteractionStart(activeInteractor: Model, activeLabelID: number): void;
updateAnnotations(statesToUpdate: any[]): void;
createAnnotations(sessionInstance: any, frame: number, statesToCreate: any[]): void;
fetchAnnotations(): void;
}

Expand All @@ -51,10 +60,11 @@ function mapStateToProps(state: CombinedState): StateToProps {
const { instance: jobInstance } = annotation.job;
const { instance: canvasInstance, activeControl } = annotation.canvas;
const { models } = state;
const { interactors } = models;
const { interactors, detectors } = models;

return {
interactors,
detectors,
isInteraction: activeControl === ActiveControl.INTERACTION,
activeLabelID: annotation.drawing.activeLabelID,
labels: annotation.job.labels,
Expand All @@ -65,19 +75,12 @@ function mapStateToProps(state: CombinedState): StateToProps {
};
}

function mapDispatchToProps(dispatch: any): DispatchToProps {
return {
onInteractionStart(activeInteractor: Model, activeLabelID: number): void {
dispatch(interactWithCanvas(activeInteractor, activeLabelID));
},
updateAnnotations(statesToUpdate: any[]): void {
dispatch(updateAnnotationsAsync(statesToUpdate));
},
fetchAnnotations(): void {
dispatch(fetchAnnotationsAsync());
},
};
}
const mapDispatchToProps = {
onInteractionStart: interactWithCanvas,
updateAnnotations: updateAnnotationsAsync,
fetchAnnotations: fetchAnnotationsAsync,
createAnnotations: createAnnotationsAsync,
};

function convertShapesForInteractor(shapes: InteractionResult[]): number[][] {
const reducer = (acc: number[][], _: number, index: number, array: number[]): number[][] => {
Expand Down Expand Up @@ -378,9 +381,10 @@ class ToolsControlComponent extends React.PureComponent<Props, State> {
</Select>
</Col>
</Row>
<Row type='flex' align='middle' justify='center'>
<Col offset={4} span={16}>
<Row type='flex' align='middle' justify='end'>
<Col>
<Button
type='primary'
loading={fetching}
className='cvat-tools-interact-button'
disabled={!activeInteractor || fetching}
Expand All @@ -405,6 +409,60 @@ class ToolsControlComponent extends React.PureComponent<Props, State> {
);
}

private renderDetectorBlock(): JSX.Element {
const {
jobInstance,
detectors,
frame,
fetchAnnotations,
} = this.props;

return (
<DetectorRunner
withCleanup={false}
models={detectors}
task={jobInstance.task}
runInference={async (task: any, model: Model, body: object) => {
try {
this.setState({ fetching: true });
const result = await core.lambda.call(task, model, {
...body,
frame,
});

const states = result
.map((data: any): any => (
new core.classes.ObjectState({
shapeType: data.type,
label: task.labels
.filter(
(label: any): boolean => label.name === data.label,
)[0],
points: data.points,
objectType: ObjectType.SHAPE,
frame,
occluded: false,
source: 'auto',
attributes: {},
zOrder: 0, // TODO: get current z order
})
));

await jobInstance.annotations.put(states);
fetchAnnotations();
} catch (error) {
notification.error({
description: error.toString(),
message: 'Detection error occured',
});
} finally {
this.setState({ fetching: false });
}
}}
/>
);
}

private renderPopoverContent(): JSX.Element {
return (
<div className='cvat-tools-control-popover-content'>
Expand All @@ -413,8 +471,15 @@ class ToolsControlComponent extends React.PureComponent<Props, State> {
<Text className='cvat-text-color' strong>AI Tools</Text>
</Col>
</Row>
{ this.renderLabelBlock() }
{ this.renderInteractorBlock() }
<Tabs>
<Tabs.TabPane key='interactors' tab='Interactors'>
{ this.renderLabelBlock() }
{ this.renderInteractorBlock() }
</Tabs.TabPane>
<Tabs.TabPane key='detectors' tab='Detectors'>
{ this.renderDetectorBlock() }
</Tabs.TabPane>
</Tabs>
</div>
);
}
Expand Down Expand Up @@ -443,7 +508,7 @@ class ToolsControlComponent extends React.PureComponent<Props, State> {
return (
<>
<Modal
title='Interaction request'
title='Making a server request'
zIndex={Number.MAX_SAFE_INTEGER}
visible={fetching}
closable={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@
}

.cvat-tools-control-popover-content {
width: 350px;
padding: 10px;
border-radius: 5px;
background: $background-color-2;
width: 270px;
}

.cvat-draw-shape-popover-content {
Expand Down
Loading