Skip to content

Commit

Permalink
Updated page with allocation report (#8558)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev authored Oct 21, 2024
1 parent 0abe52f commit e3e8d99
Show file tree
Hide file tree
Showing 15 changed files with 290 additions and 271 deletions.
5 changes: 3 additions & 2 deletions cvat-core/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import QualityReport from './quality-report';
import QualityConflict from './quality-conflict';
import QualitySettings from './quality-settings';
import AnalyticsReport from './analytics-report';
import ValidationLayout from './validation-layout';
import { JobValidationLayout, TaskValidationLayout } from './validation-layout';
import { Request } from './request';

import * as enums from './enums';
Expand Down Expand Up @@ -427,7 +427,8 @@ function build(): CVATCore {
QualityReport,
Request,
FramesMetaData,
ValidationLayout,
JobValidationLayout,
TaskValidationLayout,
},
utils: {
mask2Rle,
Expand Down
5 changes: 3 additions & 2 deletions cvat-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import QualityConflict from './quality-conflict';
import QualitySettings from './quality-settings';
import AnalyticsReport from './analytics-report';
import AnnotationGuide from './guide';
import ValidationLayout from './validation-layout';
import { JobValidationLayout, TaskValidationLayout } from './validation-layout';
import { Request } from './request';
import BaseSingleFrameAction, { listActions, registerAction, runActions } from './annotations-actions';
import {
Expand Down Expand Up @@ -216,7 +216,8 @@ export default interface CVATCore {
AnalyticsReport: typeof AnalyticsReport;
Request: typeof Request;
FramesMetaData: typeof FramesMetaData;
ValidationLayout: typeof ValidationLayout;
JobValidationLayout: typeof JobValidationLayout;
TaskValidationLayout: typeof TaskValidationLayout;
};
utils: {
mask2Rle: typeof mask2Rle;
Expand Down
4 changes: 2 additions & 2 deletions cvat-core/src/server-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
SerializedInvitationData, SerializedCloudStorage, SerializedFramesMetaData, SerializedCollection,
SerializedQualitySettingsData, APIQualitySettingsFilter, SerializedQualityConflictData, APIQualityConflictsFilter,
SerializedQualityReportData, APIQualityReportsFilter, SerializedAnalyticsReport, APIAnalyticsReportFilter,
SerializedRequest, SerializedValidationLayout,
SerializedRequest, SerializedJobValidationLayout, SerializedTaskValidationLayout,
} from './server-response-types';
import { PaginatedResource } from './core-types';
import { Request } from './request';
Expand Down Expand Up @@ -1384,7 +1384,7 @@ async function deleteJob(jobID: number): Promise<void> {

const validationLayout = (instance: 'tasks' | 'jobs') => async (
id: number,
): Promise<SerializedValidationLayout | null> => {
): Promise<SerializedJobValidationLayout | SerializedTaskValidationLayout> => {
const { backendAPI } = config;

try {
Expand Down
8 changes: 7 additions & 1 deletion cvat-core/src/server-response-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,14 @@ export interface SerializedRequest {
owner?: any;
}

export interface SerializedValidationLayout {
export interface SerializedJobValidationLayout {
honeypot_count?: number;
honeypot_frames?: number[];
honeypot_real_frames?: number[];
}

export interface SerializedTaskValidationLayout extends SerializedJobValidationLayout {
mode: 'gt' | 'gt_pool' | null;
validation_frames?: number[];
disabled_frames?: number[];
}
15 changes: 9 additions & 6 deletions cvat-core/src/session-implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ import {
decodePreview,
} from './frames';
import Issue from './issue';
import { SerializedLabel, SerializedTask, SerializedValidationLayout } from './server-response-types';
import {
SerializedLabel, SerializedTask, SerializedJobValidationLayout,
SerializedTaskValidationLayout,
} from './server-response-types';
import { checkInEnum, checkObjectType } from './common';
import {
getCollection, getSaver, clearAnnotations, getAnnotations,
Expand All @@ -37,7 +40,7 @@ import AnnotationGuide from './guide';
import requestsManager from './requests-manager';
import { Request } from './request';
import User from './user';
import ValidationLayout from './validation-layout';
import { JobValidationLayout, TaskValidationLayout } from './validation-layout';

// must be called with task/job context
async function deleteFrameWrapper(jobID, frame): Promise<void> {
Expand Down Expand Up @@ -171,7 +174,7 @@ export function implementJob(Job: typeof JobClass): typeof JobClass {
): ReturnType<typeof JobClass.prototype.validationLayout> {
const result = await serverProxy.jobs.validationLayout(this.id);
if (Object.keys(result).length) {
return new ValidationLayout(result as Required<SerializedValidationLayout>);
return new JobValidationLayout(result as SerializedJobValidationLayout);
}

return null;
Expand Down Expand Up @@ -641,9 +644,9 @@ export function implementTask(Task: typeof TaskClass): typeof TaskClass {
value: async function validationLayoutImplementation(
this: TaskClass,
): ReturnType<typeof TaskClass.prototype.validationLayout> {
const result = await serverProxy.tasks.validationLayout(this.id);
if (Object.keys(result).length) {
return new ValidationLayout(result as Required<SerializedValidationLayout>);
const result = await serverProxy.tasks.validationLayout(this.id) as SerializedTaskValidationLayout;
if (result.mode !== null) {
return new TaskValidationLayout(result);
}

return null;
Expand Down
6 changes: 3 additions & 3 deletions cvat-core/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { Request } from './request';
import logger from './logger';
import Issue from './issue';
import ObjectState from './object-state';
import ValidationLayout from './validation-layout';
import { JobValidationLayout, TaskValidationLayout } from './validation-layout';

function buildDuplicatedAPI(prototype) {
Object.defineProperties(prototype, {
Expand Down Expand Up @@ -686,7 +686,7 @@ export class Job extends Session {
return result;
}

async validationLayout(): Promise<ValidationLayout | null> {
async validationLayout(): Promise<JobValidationLayout | null> {
const result = await PluginRegistry.apiWrapper.call(this, Job.prototype.validationLayout);
return result;
}
Expand Down Expand Up @@ -1186,7 +1186,7 @@ export class Task extends Session {
return result;
}

async validationLayout(): Promise<ValidationLayout | null> {
async validationLayout(): Promise<TaskValidationLayout | null> {
const result = await PluginRegistry.apiWrapper.call(this, Task.prototype.validationLayout);
return result;
}
Expand Down
55 changes: 43 additions & 12 deletions cvat-core/src/validation-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,43 @@
//
// SPDX-License-Identifier: MIT

import { SerializedValidationLayout } from 'server-response-types';
import { SerializedJobValidationLayout, SerializedTaskValidationLayout } from 'server-response-types';
import PluginRegistry from './plugins';

export default class ValidationLayout {
#honeypotFrames: number[];
#honeypotRealFrames: number[];
export class JobValidationLayout {
#honeypotCount: JobValidationLayout['honeypotCount'];
#honeypotFrames: JobValidationLayout['honeypotFrames'];
#honeypotRealFrames: JobValidationLayout['honeypotRealFrames'];

public constructor(data: Required<SerializedValidationLayout>) {
this.#honeypotFrames = [...data.honeypot_frames];
this.#honeypotRealFrames = [...data.honeypot_real_frames];
public constructor(data: SerializedJobValidationLayout) {
this.#honeypotCount = data.honeypot_count ?? 0;
this.#honeypotFrames = [...(data.honeypot_frames ?? [])];
this.#honeypotRealFrames = [...(data.honeypot_real_frames ?? [])];
}

public get honeypotFrames() {
public get honeypotCount(): number {
return this.#honeypotCount;
}

public get honeypotFrames(): number[] {
return [...this.#honeypotFrames];
}

public get honeypotRealFrames() {
public get honeypotRealFrames(): number[] {
return [...this.#honeypotRealFrames];
}

async getRealFrame(frame: number): Promise<number | null> {
const result = await PluginRegistry.apiWrapper.call(this, ValidationLayout.prototype.getRealFrame, frame);
const result = await PluginRegistry.apiWrapper.call(this, JobValidationLayout.prototype.getRealFrame, frame);
return result;
}
}

Object.defineProperties(ValidationLayout.prototype.getRealFrame, {
Object.defineProperties(JobValidationLayout.prototype.getRealFrame, {
implementation: {
writable: false,
enumerable: false,
value: function implementation(this: ValidationLayout, frame: number): number | null {
value: function implementation(this: JobValidationLayout, frame: number): number | null {
const index = this.honeypotFrames.indexOf(frame);
if (index !== -1) {
return this.honeypotRealFrames[index];
Expand All @@ -42,3 +48,28 @@ Object.defineProperties(ValidationLayout.prototype.getRealFrame, {
},
},
});

export class TaskValidationLayout extends JobValidationLayout {
#mode: TaskValidationLayout['mode'];
#validationFrames: TaskValidationLayout['validationFrames'];
#disabledFrames: TaskValidationLayout['disabledFrames'];

public constructor(data: SerializedTaskValidationLayout) {
super(data);
this.#mode = data.mode;
this.#validationFrames = [...(data.validation_frames ?? [])];
this.#disabledFrames = [...(data.disabled_frames ?? [])];
}

public get mode(): NonNullable<SerializedTaskValidationLayout['mode']> {
return this.#mode;
}

public get validationFrames(): number[] {
return [...this.#validationFrames];
}

public get disabledFrames(): number[] {
return [...this.#disabledFrames];
}
}
4 changes: 2 additions & 2 deletions cvat-ui/src/actions/annotation-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from 'cvat-canvas-wrapper';
import {
getCore, MLModel, JobType, Job, QualityConflict,
ObjectState, JobState, ValidationLayout,
ObjectState, JobState, JobValidationLayout,
} from 'cvat-core-wrapper';
import logger, { EventScope } from 'cvat-logger';
import { getCVATStore } from 'cvat-store';
Expand All @@ -38,7 +38,7 @@ interface AnnotationsParameters {
showGroundTruth: boolean;
jobInstance: Job;
groundTruthInstance: Job | null;
validationLayout: ValidationLayout | null;
validationLayout: JobValidationLayout | null;
}

const cvat = getCore();
Expand Down
Loading

0 comments on commit e3e8d99

Please sign in to comment.