Merge remote-tracking branch 'origin/develop' into dk/user-search
commit
8c2200356d
@ -0,0 +1,41 @@
|
|||||||
|
# Copyright (C) 2020 Intel Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import os.path as osp
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
|
import zipfile
|
||||||
|
from tempfile import TemporaryDirectory
|
||||||
|
|
||||||
|
from datumaro.components.project import Dataset
|
||||||
|
from cvat.apps.dataset_manager.bindings import CvatTaskDataExtractor, \
|
||||||
|
import_dm_annotations
|
||||||
|
from cvat.apps.dataset_manager.util import make_zip_archive
|
||||||
|
|
||||||
|
from .registry import dm_env, exporter, importer
|
||||||
|
|
||||||
|
|
||||||
|
@exporter(name='ImageNet', ext='ZIP', version='1.0')
|
||||||
|
def _export(dst_file, task_data, save_images=False):
|
||||||
|
extractor = CvatTaskDataExtractor(task_data, include_images=save_images)
|
||||||
|
extractor = Dataset.from_extractors(extractor) # apply lazy transform
|
||||||
|
with TemporaryDirectory() as temp_dir:
|
||||||
|
if save_images:
|
||||||
|
dm_env.converters.get('imagenet').convert(extractor,
|
||||||
|
save_dir=temp_dir, save_images=save_images)
|
||||||
|
else:
|
||||||
|
dm_env.converters.get('imagenet_txt').convert(extractor,
|
||||||
|
save_dir=temp_dir, save_images=save_images)
|
||||||
|
|
||||||
|
make_zip_archive(temp_dir, dst_file)
|
||||||
|
|
||||||
|
@importer(name='ImageNet', ext='ZIP', version='1.0')
|
||||||
|
def _import(src_file, task_data):
|
||||||
|
with TemporaryDirectory() as tmp_dir:
|
||||||
|
zipfile.ZipFile(src_file).extractall(tmp_dir)
|
||||||
|
if glob(osp.join(tmp_dir, '*.txt')):
|
||||||
|
dataset = dm_env.make_importer('imagenet_txt')(tmp_dir).make_dataset()
|
||||||
|
else:
|
||||||
|
dataset = dm_env.make_importer('imagenet')(tmp_dir).make_dataset()
|
||||||
|
import_dm_annotations(dataset, task_data)
|
||||||
Binary file not shown.
@ -0,0 +1,155 @@
|
|||||||
|
// Copyright (C) 2020 Intel Corporation
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
import { taskName } from '../../support/const';
|
||||||
|
|
||||||
|
context('Merge/split features', () => {
|
||||||
|
const caseId = '13';
|
||||||
|
const createRectangleShape2Points = {
|
||||||
|
points: 'By 2 Points',
|
||||||
|
type: 'Shape',
|
||||||
|
switchLabel: false,
|
||||||
|
firstX: 250,
|
||||||
|
firstY: 350,
|
||||||
|
secondX: 350,
|
||||||
|
secondY: 450,
|
||||||
|
};
|
||||||
|
const createRectangleShape2PointsSecond = {
|
||||||
|
points: 'By 2 Points',
|
||||||
|
type: 'Shape',
|
||||||
|
switchLabel: false,
|
||||||
|
firstX: createRectangleShape2Points.firstX + 300,
|
||||||
|
firstY: createRectangleShape2Points.firstY,
|
||||||
|
secondX: createRectangleShape2Points.secondX + 300,
|
||||||
|
secondY: createRectangleShape2Points.secondY,
|
||||||
|
};
|
||||||
|
const frameNum = 0;
|
||||||
|
// Check the 'X' coordinate. 'Y' coordinate is the same.
|
||||||
|
let xCoordinatesObjectFirstFrame = 0;
|
||||||
|
let xCoordinatesObjectThirdFrame = 0;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.openTaskJob(taskName);
|
||||||
|
});
|
||||||
|
|
||||||
|
function goCheckFrameNumber(frameNum) {
|
||||||
|
cy.get('.cvat-player-frame-selector').within(() => {
|
||||||
|
cy.get('input[role="spinbutton"]').clear().type(`${frameNum}{Enter}`).should('have.value', frameNum);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
describe(`Testing case "${caseId}"`, () => {
|
||||||
|
it('Create rectangle shape on first frame', () => {
|
||||||
|
goCheckFrameNumber(frameNum);
|
||||||
|
cy.createRectangle(createRectangleShape2Points);
|
||||||
|
cy.get('#cvat_canvas_shape_1')
|
||||||
|
.should('have.attr', 'x')
|
||||||
|
.then((xCoords) => {
|
||||||
|
xCoordinatesObjectFirstFrame = Math.floor(xCoords);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('Create rectangle shape on third frame with another position', () => {
|
||||||
|
goCheckFrameNumber(frameNum + 2);
|
||||||
|
cy.createRectangle(createRectangleShape2PointsSecond);
|
||||||
|
cy.get('#cvat_canvas_shape_2')
|
||||||
|
.should('have.attr', 'x')
|
||||||
|
.then((xCoords) => {
|
||||||
|
xCoordinatesObjectThirdFrame = Math.floor(xCoords);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('Merge the objects with "Merge button"', () => {
|
||||||
|
cy.get('.cvat-merge-control').click();
|
||||||
|
cy.get('#cvat_canvas_shape_2').click();
|
||||||
|
goCheckFrameNumber(frameNum);
|
||||||
|
cy.get('#cvat_canvas_shape_1').click();
|
||||||
|
cy.get('.cvat-merge-control').click();
|
||||||
|
});
|
||||||
|
it('Get a track with keyframes on first and third frame', () => {
|
||||||
|
cy.get('#cvat_canvas_shape_3').should('exist').and('be.visible');
|
||||||
|
cy.get('#cvat-objects-sidebar-state-item-3')
|
||||||
|
.should('contain', '3')
|
||||||
|
.and('contain', 'RECTANGLE TRACK')
|
||||||
|
.within(() => {
|
||||||
|
cy.get('.cvat-object-item-button-keyframe-enabled').should('exist');
|
||||||
|
});
|
||||||
|
goCheckFrameNumber(frameNum + 2);
|
||||||
|
cy.get('#cvat_canvas_shape_3').should('exist').and('be.visible');
|
||||||
|
cy.get('#cvat-objects-sidebar-state-item-3')
|
||||||
|
.should('contain', '3')
|
||||||
|
.and('contain', 'RECTANGLE TRACK')
|
||||||
|
.within(() => {
|
||||||
|
cy.get('.cvat-object-item-button-keyframe-enabled').should('exist');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('On the second frame and on the fourth frame the track is invisible', () => {
|
||||||
|
goCheckFrameNumber(frameNum + 1);
|
||||||
|
cy.get('#cvat_canvas_shape_3').should('exist').and('be.hidden');
|
||||||
|
goCheckFrameNumber(frameNum + 3);
|
||||||
|
cy.get('#cvat_canvas_shape_3').should('exist').and('be.hidden');
|
||||||
|
});
|
||||||
|
it('Go to the second frame and remove "outside" flag from the track. The track now visible.', () => {
|
||||||
|
goCheckFrameNumber(frameNum + 1);
|
||||||
|
cy.get('#cvat-objects-sidebar-state-item-3')
|
||||||
|
.should('contain', '3')
|
||||||
|
.and('contain', 'RECTANGLE TRACK')
|
||||||
|
.within(() => {
|
||||||
|
cy.get('.cvat-object-item-button-outside').click();
|
||||||
|
cy.get('.cvat-object-item-button-outside-enabled').should('not.exist');
|
||||||
|
});
|
||||||
|
cy.get('#cvat_canvas_shape_3').should('exist').and('be.visible');
|
||||||
|
});
|
||||||
|
it('Remove "keyframe" flag from the track. Track now interpolated between position on the first and the third frames.', () => {
|
||||||
|
cy.get('#cvat-objects-sidebar-state-item-3')
|
||||||
|
.should('contain', '3')
|
||||||
|
.and('contain', 'RECTANGLE TRACK')
|
||||||
|
.within(() => {
|
||||||
|
cy.get('.cvat-object-item-button-keyframe').click();
|
||||||
|
cy.get('.cvat-object-item-button-keyframe-enabled').should('not.exist');
|
||||||
|
});
|
||||||
|
cy.get('#cvat_canvas_shape_3')
|
||||||
|
.should('have.attr', 'x')
|
||||||
|
.then((xCoords) => {
|
||||||
|
// expected 9785 to be within 9642..9928
|
||||||
|
expect(Math.floor(xCoords)).to.be.within(
|
||||||
|
xCoordinatesObjectFirstFrame,
|
||||||
|
xCoordinatesObjectThirdFrame,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('On the fourth frame remove "keyframe" flag from the track. The track now visible and "outside" flag is disabled.', () => {
|
||||||
|
goCheckFrameNumber(frameNum + 3);
|
||||||
|
cy.get('#cvat-objects-sidebar-state-item-3')
|
||||||
|
.should('contain', '3')
|
||||||
|
.and('contain', 'RECTANGLE TRACK')
|
||||||
|
.within(() => {
|
||||||
|
cy.get('.cvat-object-item-button-keyframe').click();
|
||||||
|
cy.get('.cvat-object-item-button-keyframe-enabled').should('not.exist');
|
||||||
|
cy.get('.cvat-object-item-button-outside-enabled').should('not.exist');
|
||||||
|
});
|
||||||
|
cy.get('#cvat_canvas_shape_3').should('exist').and('be.visible');
|
||||||
|
});
|
||||||
|
it('Split a track with "split" button. Previous track became invisible (has "outside" flag). One more track and it is visible.', () => {
|
||||||
|
cy.get('.cvat-split-track-control').click();
|
||||||
|
// A single click does not reproduce the split a track scenario in cypress test.
|
||||||
|
cy.get('#cvat_canvas_shape_3').click().click();
|
||||||
|
cy.get('#cvat_canvas_shape_4').should('exist').and('be.hidden');
|
||||||
|
cy.get('#cvat-objects-sidebar-state-item-4')
|
||||||
|
.should('contain', '4')
|
||||||
|
.and('contain', 'RECTANGLE TRACK')
|
||||||
|
.within(() => {
|
||||||
|
cy.get('.cvat-object-item-button-outside-enabled').should('exist');
|
||||||
|
});
|
||||||
|
cy.get('#cvat_canvas_shape_5').should('exist').and('be.visible');
|
||||||
|
cy.get('#cvat-objects-sidebar-state-item-5')
|
||||||
|
.should('contain', '5')
|
||||||
|
.and('contain', 'RECTANGLE TRACK')
|
||||||
|
.within(() => {
|
||||||
|
cy.get('.cvat-object-item-button-outside-enabled').should('not.exist');
|
||||||
|
cy.get('.cvat-object-item-button-keyframe-enabled').should('exist');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue