@@ -4,7 +4,7 @@ import { fetch, FormData } from 'undici';
44import { Blob } from 'node:buffer' ;
55import { Config , EdgeImpulseConfig } from './config' ;
66import encodeLabel from '../shared/encoding' ;
7- import { ExportBoundingBoxesFileV1 , ExportInputBoundingBox , ExportStructuredLabelsFileV1 ,
7+ import { ExportBoundingBoxesFileV1 , ExportInputBoundingBox , ExportLabelMapFileV1 , ExportStructuredLabelsFileV1 ,
88 ExportUploaderInfoFileCategory , ExportUploaderInfoFileLabel } from '../shared/bounding-box-file-types' ;
99
1010export const EXTENSION_MAPPING : { [ k : string ] : string } = {
@@ -81,6 +81,9 @@ export async function upload(opts: {
8181 else if ( opts . label . type === 'multi-label' ) {
8282 // gets set with a separate file, see below
8383 }
84+ else if ( opts . label . type === 'keyvalue-labels' ) {
85+ // gets set with a separate file, see below
86+ }
8487
8588 if ( ! opts . allowDuplicates ) {
8689 headers [ 'x-disallow-duplicates' ] = '1' ;
@@ -122,6 +125,18 @@ export async function upload(opts: {
122125 type : 'application/json' ,
123126 } ) , 'bounding_boxes.labels' ) ;
124127 }
128+ if ( opts . label . type === 'keyvalue-labels' ) {
129+ const labelMapFile : ExportLabelMapFileV1 = {
130+ version : 1 ,
131+ type : 'label-map-labels' ,
132+ labels : {
133+ [ opts . filename ] : opts . label . labels ,
134+ } ,
135+ } ;
136+ form . append ( 'data' , new Blob ( [ JSON . stringify ( labelMapFile ) ] , {
137+ type : 'application/json' ,
138+ } ) , 'label_map.labels' ) ;
139+ }
125140
126141 let res = await fetch ( opts . config . endpoints . internal . ingestion + '/api/' + category + '/files' , {
127142 method : 'POST' ,
0 commit comments