From 5629db5b9fb94f53bb4ba37029a4159420599b38 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Tue, 14 Jan 2020 11:45:10 +0300 Subject: [PATCH 1/2] Added ability to match many model labels to one task labels --- .../model-runner-modal/model-runner-modal.tsx | 44 ++++++++----------- .../containers/file-manager/file-manager.tsx | 5 ++- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/cvat-ui/src/components/model-runner-modal/model-runner-modal.tsx b/cvat-ui/src/components/model-runner-modal/model-runner-modal.tsx index 7d2eacd39d1f..756ec4cd56d9 100644 --- a/cvat-ui/src/components/model-runner-modal/model-runner-modal.tsx +++ b/cvat-ui/src/components/model-runner-modal/model-runner-modal.tsx @@ -11,6 +11,7 @@ import { Select, Tooltip, Checkbox, + notification, } from 'antd'; import { Model } from '../../reducers/interfaces'; @@ -118,6 +119,12 @@ export default class ModelRunnerModalComponent extends React.PureComponent model.name === selectedModel)[0]; if (!selectedModelInstance.primary) { + if (!selectedModelInstance.labels.length) { + notification.warning({ + message: 'Selected models does not include any lables', + }); + } + let taskLabels: string[] = taskInstance.labels .map((label: any): string => label.name); const [defaultMapping, defaultColors]: StringObject[] = selectedModelInstance.labels @@ -304,37 +311,24 @@ export default class ModelRunnerModalComponent extends React.PureComponent _model.name === selectedModel)[0]; - const excludedLabels: { - model: string[]; - task: string[]; - } = { - model: [], - task: [], - }; - + const excludedModelLabels: string[] = Object.keys(mapping); const withMapping = model && !model.primary; - const tags = withMapping ? Object.keys(mapping) - .map((modelLabel: string) => { - const taskLabel = mapping[modelLabel]; - excludedLabels.model.push(modelLabel); - excludedLabels.task.push(taskLabel); - return this.renderMappingTag( - modelLabel, - mapping[modelLabel], - ); - }) : []; + const tags = withMapping ? excludedModelLabels + .map((modelLabel: string) => this.renderMappingTag( + modelLabel, + mapping[modelLabel], + )) : []; const availableModelLabels = model ? model.labels .filter( - (label: string) => !excludedLabels.model.includes(label), + (label: string) => !excludedModelLabels.includes(label), ) : []; - const availableTaskLabels = taskInstance.labels - .map( - (label: any) => label.name, - ).filter((label: string): boolean => !excludedLabels.task.includes(label)); + const taskLabels = taskInstance.labels.map( + (label: any) => label.name, + ); const mappingISAvailable = !!availableModelLabels.length - && !!availableTaskLabels.length; + && !!taskLabels.length; return (
@@ -342,7 +336,7 @@ export default class ModelRunnerModalComponent extends React.PureComponent { - const key = `${path}${item.name}/`; + const isLeaf = item.type !== 'DIR'; + const key = `${path}${item.name}${isLeaf ? '' : '/'}`; return { key, + isLeaf, title: item.name || 'root', - isLeaf: item.type !== 'DIR', children: convert(item.children, key), }; }); From de8618bde79f07d8959ea918fc3d2ddc83a8d9fb Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Tue, 14 Jan 2020 11:46:32 +0300 Subject: [PATCH 2/2] Fixed grammar --- .../src/components/model-runner-modal/model-runner-modal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cvat-ui/src/components/model-runner-modal/model-runner-modal.tsx b/cvat-ui/src/components/model-runner-modal/model-runner-modal.tsx index 756ec4cd56d9..2fec246ed191 100644 --- a/cvat-ui/src/components/model-runner-modal/model-runner-modal.tsx +++ b/cvat-ui/src/components/model-runner-modal/model-runner-modal.tsx @@ -121,7 +121,7 @@ export default class ModelRunnerModalComponent extends React.PureComponent