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

React UI: ReID algorithm #1406

Merged
merged 13 commits into from
Apr 17, 2020
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.0.0-beta.2] - Unreleased
### Added
-
- Re-Identification algorithm to merging bounding boxes automatically to the new UI (https://github.com/opencv/cvat/pull/1406)
- Methods ``import`` and ``export`` to import/export raw annotations for Job and Task in ``cvat-core`` (https://github.com/opencv/cvat/pull/1406)

### Changed
-
Expand Down Expand Up @@ -34,7 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Ability to create one tracked point (https://github.com/opencv/cvat/pull/1383)
- Ability to draw/edit polygons and polylines with automatic bordering feature (https://github.com/opencv/cvat/pull/1394)
- Tutorial: instructions for CVAT over HTTPS
- Added deep extreme cut (semi-automatic segmentation) to the new UI (https://github.com/opencv/cvat/pull/1398)
- Deep extreme cut (semi-automatic segmentation) to the new UI (https://github.com/opencv/cvat/pull/1398)

### Changed
- Increase preview size of a task till 256, 256 on the server
Expand Down
28 changes: 28 additions & 0 deletions cvat-core/src/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,32 @@
return result;
}

function importAnnotations(session, data) {
const sessionType = session instanceof Task ? 'task' : 'job';
const cache = getCache(sessionType);

if (cache.has(session)) {
return cache.get(session).collection.import(data);
}

throw new DataError(
'Collection has not been initialized yet. Call annotations.get() or annotations.clear(true) before',
);
}

function exportAnnotations(session) {
const sessionType = session instanceof Task ? 'task' : 'job';
const cache = getCache(sessionType);

if (cache.has(session)) {
return cache.get(session).collection.export();
}

throw new DataError(
'Collection has not been initialized yet. Call annotations.get() or annotations.clear(true) before',
);
}

async function exportDataset(session, format) {
if (!(format instanceof String || typeof format === 'string')) {
throw new ArgumentError(
Expand Down Expand Up @@ -332,6 +358,8 @@
selectObject,
uploadAnnotations,
dumpAnnotations,
importAnnotations,
exportAnnotations,
exportDataset,
undoActions,
redoActions,
Expand Down
60 changes: 60 additions & 0 deletions cvat-core/src/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@
return result;
},

async import(data) {
const result = await PluginRegistry
.apiWrapper.call(this, prototype.annotations.import, data);
return result;
},

async export() {
const result = await PluginRegistry
.apiWrapper.call(this, prototype.annotations.export);
return result;
},

async exportDataset(format) {
const result = await PluginRegistry
.apiWrapper.call(this, prototype.annotations.exportDataset, format);
Expand Down Expand Up @@ -391,6 +403,28 @@
* @throws {module:API.cvat.exceptions.PluginError}
* @instance
*/
/**
*
* Import raw data in a collection
* @method import
* @memberof Session.annotations
* @param {Object} data
* @throws {module:API.cvat.exceptions.PluginError}
* @throws {module:API.cvat.exceptions.ArgumentError}
* @instance
* @async
*/
/**
*
* Export a collection as a row data
* @method export
* @memberof Session.annotations
* @returns {Object} data
* @throws {module:API.cvat.exceptions.PluginError}
* @throws {module:API.cvat.exceptions.ArgumentError}
* @instance
* @async
*/
/**
* Export as a dataset.
* Method builds a dataset in the specified format.
Expand Down Expand Up @@ -695,6 +729,8 @@
search: Object.getPrototypeOf(this).annotations.search.bind(this),
upload: Object.getPrototypeOf(this).annotations.upload.bind(this),
select: Object.getPrototypeOf(this).annotations.select.bind(this),
import: Object.getPrototypeOf(this).annotations.import.bind(this),
export: Object.getPrototypeOf(this).annotations.export.bind(this),
statistics: Object.getPrototypeOf(this).annotations.statistics.bind(this),
hasUnsavedChanges: Object.getPrototypeOf(this)
.annotations.hasUnsavedChanges.bind(this),
Expand Down Expand Up @@ -1245,6 +1281,8 @@
search: Object.getPrototypeOf(this).annotations.search.bind(this),
upload: Object.getPrototypeOf(this).annotations.upload.bind(this),
select: Object.getPrototypeOf(this).annotations.select.bind(this),
import: Object.getPrototypeOf(this).annotations.import.bind(this),
export: Object.getPrototypeOf(this).annotations.export.bind(this),
statistics: Object.getPrototypeOf(this).annotations.statistics.bind(this),
hasUnsavedChanges: Object.getPrototypeOf(this)
.annotations.hasUnsavedChanges.bind(this),
Expand Down Expand Up @@ -1326,6 +1364,8 @@
annotationsStatistics,
uploadAnnotations,
dumpAnnotations,
importAnnotations,
exportAnnotations,
exportDataset,
undoActions,
redoActions,
Expand Down Expand Up @@ -1490,6 +1530,16 @@
return result;
};

Job.prototype.annotations.import.implementation = function (data) {
const result = importAnnotations(this, data);
return result;
};

Job.prototype.annotations.export.implementation = function () {
const result = exportAnnotations(this);
return result;
};

Job.prototype.annotations.dump.implementation = async function (name, dumper) {
const result = await dumpAnnotations(this, name, dumper);
return result;
Expand Down Expand Up @@ -1739,6 +1789,16 @@
return result;
};

Task.prototype.annotations.import.implementation = function (data) {
const result = importAnnotations(this, data);
return result;
};

Task.prototype.annotations.export.implementation = function () {
const result = exportAnnotations(this);
return result;
};

Task.prototype.annotations.exportDataset.implementation = async function (format) {
const result = await exportDataset(this, format);
return result;
Expand Down
6 changes: 4 additions & 2 deletions cvat-ui/src/actions/plugins-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function checkPluginsAsync(): ThunkAction {
GIT_INTEGRATION: false,
TF_ANNOTATION: false,
TF_SEGMENTATION: false,
REID: false,
DEXTR_SEGMENTATION: false,
};

Expand All @@ -43,11 +44,12 @@ export function checkPluginsAsync(): ThunkAction {
PluginChecker.check(SupportedPlugins.TF_ANNOTATION),
PluginChecker.check(SupportedPlugins.TF_SEGMENTATION),
PluginChecker.check(SupportedPlugins.DEXTR_SEGMENTATION),
PluginChecker.check(SupportedPlugins.REID),
];

const values = await Promise.all(promises);
[plugins.ANALYTICS, plugins.AUTO_ANNOTATION, plugins.GIT_INTEGRATION,
plugins.TF_ANNOTATION, plugins.TF_SEGMENTATION, plugins.DEXTR_SEGMENTATION] = values;
[plugins.ANALYTICS, plugins.AUTO_ANNOTATION, plugins.GIT_INTEGRATION, plugins.TF_ANNOTATION,
plugins.TF_SEGMENTATION, plugins.DEXTR_SEGMENTATION, plugins.REID] = values;
dispatch(pluginActions.checkedAllPlugins(plugins));
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Modal from 'antd/lib/modal';
import DumpSubmenu from 'components/actions-menu/dump-submenu';
import LoadSubmenu from 'components/actions-menu/load-submenu';
import ExportSubmenu from 'components/actions-menu/export-submenu';
import ReIDPlugin from './reid-plugin';

interface Props {
taskMode: string;
Expand All @@ -18,6 +19,7 @@ interface Props {
loadActivity: string | null;
dumpActivities: string[] | null;
exportActivities: string[] | null;
installedReID: boolean;
onClickMenu(params: ClickParam, file?: File): void;
}

Expand All @@ -39,6 +41,7 @@ export default function AnnotationMenuComponent(props: Props): JSX.Element {
loadActivity,
dumpActivities,
exportActivities,
installedReID,
} = props;

let latestParams: ClickParam | null = null;
Expand Down Expand Up @@ -120,6 +123,7 @@ export default function AnnotationMenuComponent(props: Props): JSX.Element {
<Menu.Item key={Actions.OPEN_TASK}>
Open the task
</Menu.Item>
{ installedReID && <ReIDPlugin /> }
</Menu>
);
}
Loading