Skip to content

Commit 59f3282

Browse files
authored
fix(frontend): update pre annotation column (#433)
1 parent 80ed39c commit 59f3282

File tree

8 files changed

+550
-51
lines changed

8 files changed

+550
-51
lines changed

apps/frontend/src/api/constant.ts

+1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ export const ErrorMessages = {
2020
[TASK_INIT_CODE + 1001]: '附近没找到',
2121
[TASK_INIT_CODE + 5000]: '参数错误:after,before,pageNo,只能选一个,pageNo 可以说是0',
2222
[TASK_INIT_CODE + 5001]: '没有此sample',
23+
[TASK_INIT_CODE + 5003]: '预标注中的sample_name在数据库中已存在',
2324
} as const;

apps/frontend/src/api/services/preAnnotations.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export async function getPreAnnotations({
2121
...params
2222
}: ListByApiV1TasksTaskIdSamplesGetParams & {
2323
sample_name?: string;
24-
}): Promise<PreAnnotationResponse> {
24+
}): Promise<{ data: PreAnnotationResponse }> {
2525
return await request.get(`/v1/tasks/${task_id}/pre_annotations`, {
2626
params: {
2727
...params,

apps/frontend/src/api/types.ts

+365-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { EnumerableAttribute, ILabel, TextAttribute } from '@labelu/interface';
2+
13
export interface AttachmentDeleteCommand {
24
/** Attachment Ids description: attachment file id */
35
attachment_ids: number[];
@@ -230,7 +232,7 @@ export interface PreAnnotationResponse {
230232
/** Id description: annotation id */
231233
id?: number;
232234
/** Data description: sample data, include filename, file url, or result */
233-
data?: any;
235+
data?: PreAnnotationType[];
234236
file: {
235237
id: string;
236238
url: string;
@@ -375,3 +377,365 @@ export interface ValidationError {
375377
/** Error Type */
376378
type: string;
377379
}
380+
381+
interface TextTool {
382+
/**
383+
* 唯一标识
384+
*/
385+
id?: string;
386+
/**
387+
* 文本类型: text(文本)
388+
*/
389+
type?: 'text';
390+
/**
391+
* 文本内容
392+
*/
393+
value?: Record<string, string>;
394+
}
395+
396+
interface TagTool {
397+
/**
398+
* 唯一标识
399+
*/
400+
id?: string;
401+
type?: 'tag';
402+
value?: Record<string, string[]>;
403+
}
404+
405+
export interface PreAnnotationType {
406+
/**
407+
* The name of the sample file.
408+
*/
409+
sample_name: string;
410+
config: {
411+
pointTool?: ILabel[];
412+
rectTool?: ILabel[];
413+
polygonTool?: ILabel[];
414+
lineTool?: ILabel[];
415+
cuboidTool?: ILabel[];
416+
videoSegmentTool?: ILabel[];
417+
videoFrameTool?: ILabel[];
418+
audioSegmentTool?: ILabel[];
419+
audioFrameTool?: ILabel[];
420+
textTool?: TextAttribute[];
421+
tagTool?: EnumerableAttribute[];
422+
};
423+
meta_data?: {
424+
width?: number;
425+
height?: number;
426+
rotate?: number;
427+
duration?: number;
428+
};
429+
annotations: {
430+
pointTool?: {
431+
toolName?: 'pointTool';
432+
result?: PointTool[];
433+
};
434+
rectTool?: {
435+
toolName?: 'rectTool';
436+
result?: RectTool[];
437+
};
438+
polygonTool?: {
439+
toolName?: 'polygonTool';
440+
result?: PolygonTool[];
441+
};
442+
lineTool?: {
443+
toolName?: 'lineTool';
444+
result?: GeneratedSchemaForRoot[];
445+
};
446+
cuboidTool?: {
447+
toolName?: 'cuboidTool';
448+
result?: CuboidTool[];
449+
};
450+
videoSegmentTool?: {
451+
toolName?: 'videoSegmentTool';
452+
result?: SegmentTool[];
453+
};
454+
videoFrameTool?: {
455+
toolName?: 'videoFrameTool';
456+
result?: FrameTool[];
457+
};
458+
audioSegmentTool?: {
459+
toolName?: 'audioSegmentTool';
460+
result?: SegmentTool[];
461+
};
462+
audioFrameTool?: {
463+
toolName?: 'audioFrameTool';
464+
result?: FrameTool[];
465+
};
466+
textTool?: {
467+
toolName?: 'textTool';
468+
result?: TextTool[];
469+
};
470+
tagTool?: {
471+
toolName?: 'tagTool';
472+
result?: TagTool[];
473+
};
474+
};
475+
}
476+
477+
interface PointTool {
478+
/**
479+
* 唯一标识
480+
*/
481+
id: string;
482+
/**
483+
* x坐标
484+
*/
485+
x: number;
486+
/**
487+
* y坐标
488+
*/
489+
y: number;
490+
/**
491+
* 是否可见
492+
*/
493+
visible?: boolean;
494+
attributes?: Attribute;
495+
/**
496+
* 标注顺序
497+
*/
498+
order: number;
499+
/**
500+
* 标注类别
501+
*/
502+
label: string;
503+
}
504+
/**
505+
* 类别属性,键值对
506+
*/
507+
export type Attribute = Record<string, string | string[]>;
508+
export interface RectTool {
509+
/**
510+
* 唯一标识
511+
*/
512+
id: string;
513+
/**
514+
* 拉框左上角x坐标
515+
*/
516+
x: number;
517+
/**
518+
* 拉框左上角y坐标
519+
*/
520+
y: number;
521+
/**
522+
* 拉框宽度
523+
*/
524+
width: number;
525+
/**
526+
* 拉框高度
527+
*/
528+
height: number;
529+
/**
530+
* 是否可见
531+
*/
532+
visible?: boolean;
533+
attributes?: Attribute;
534+
/**
535+
* 标注顺序
536+
*/
537+
order: number;
538+
/**
539+
* 标注类别
540+
*/
541+
label: string;
542+
}
543+
export interface PolygonTool {
544+
/**
545+
* 唯一标识
546+
*/
547+
id: string;
548+
/**
549+
* 线条类型: line(直线),spline(曲线)
550+
*/
551+
lineType: 'line' | 'spline';
552+
/**
553+
* 控制点列表
554+
*/
555+
controlPoints?: Point[];
556+
/**
557+
* 线条点列表
558+
*/
559+
points: Point[];
560+
/**
561+
* 是否可见
562+
*/
563+
visible?: boolean;
564+
attributes?: Attribute;
565+
/**
566+
* 标注顺序
567+
*/
568+
order: number;
569+
/**
570+
* 标注类别
571+
*/
572+
label: string;
573+
}
574+
export interface Point {
575+
/**
576+
* x坐标
577+
*/
578+
x: number;
579+
/**
580+
* y坐标
581+
*/
582+
y: number;
583+
}
584+
export interface GeneratedSchemaForRoot {
585+
/**
586+
* 唯一标识
587+
*/
588+
id: string;
589+
/**
590+
* 线条类型: line(直线),spline(曲线)
591+
*/
592+
lineType: 'line' | 'spline';
593+
/**
594+
* 控制点列表
595+
*/
596+
controlPoints?: Point[];
597+
/**
598+
* 线条点列表
599+
*/
600+
points: Point[];
601+
/**
602+
* 是否可见
603+
*/
604+
visible?: boolean;
605+
attributes?: Attribute;
606+
/**
607+
* 标注顺序
608+
*/
609+
order: number;
610+
/**
611+
* 标注类别
612+
*/
613+
label: string;
614+
}
615+
export interface CuboidTool {
616+
/**
617+
* 唯一标识
618+
*/
619+
id: string;
620+
/**
621+
* 正面方向: front(前面),back(后面),left(左侧面),right(右侧面)
622+
*/
623+
direction: string;
624+
/**
625+
* 正面四个点坐标
626+
*/
627+
front: {
628+
/**
629+
* 左上角坐标
630+
*/
631+
tl: {
632+
x: number;
633+
y: number;
634+
};
635+
/**
636+
* 右上角坐标
637+
*/
638+
tr: {
639+
x: number;
640+
y: number;
641+
};
642+
/**
643+
* 右下角坐标
644+
*/
645+
br: {
646+
x: number;
647+
y: number;
648+
};
649+
/**
650+
* 左下角坐标
651+
*/
652+
bl: {
653+
x: number;
654+
y: number;
655+
};
656+
};
657+
/**
658+
* 背面四个点坐标
659+
*/
660+
back: {
661+
/**
662+
* 左上角坐标
663+
*/
664+
tl: {
665+
x: number;
666+
y: number;
667+
};
668+
/**
669+
* 右上角坐标
670+
*/
671+
tr: {
672+
x: number;
673+
y: number;
674+
};
675+
/**
676+
* 右下角坐标
677+
*/
678+
br: {
679+
x: number;
680+
y: number;
681+
};
682+
/**
683+
* 左下角坐标
684+
*/
685+
bl: {
686+
x: number;
687+
y: number;
688+
};
689+
};
690+
/**
691+
* 是否可见
692+
*/
693+
visible?: boolean;
694+
attributes?: Attribute;
695+
/**
696+
* 标注顺序
697+
*/
698+
order: number;
699+
/**
700+
* 标注类别
701+
*/
702+
label: string;
703+
}
704+
export interface SegmentTool {
705+
/**
706+
* 唯一标识
707+
*/
708+
id: string;
709+
/**
710+
* 时间点
711+
*/
712+
time?: number;
713+
/**
714+
* 标注顺序
715+
*/
716+
order: number;
717+
/**
718+
* 标注类别
719+
*/
720+
label: string;
721+
attributes?: Attribute;
722+
}
723+
export interface FrameTool {
724+
/**
725+
* 唯一标识
726+
*/
727+
id: string;
728+
/**
729+
* 时间点
730+
*/
731+
time?: number;
732+
/**
733+
* 标注顺序
734+
*/
735+
order: number;
736+
/**
737+
* 标注类别
738+
*/
739+
label: string;
740+
attributes?: Attribute;
741+
}

0 commit comments

Comments
 (0)