Skip to content

Commit 46b45eb

Browse files
authored
Merge pull request #50 from SreeHarshaNelaturu/folder_annotations_fix
Added method to export tags
2 parents 730246b + 64abbb4 commit 46b45eb

4 files changed

Lines changed: 35 additions & 19 deletions

File tree

remo/api.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,25 +358,26 @@ def get_annotation_set(self, id):
358358
return self.get(url).json()
359359

360360
def export_annotations(
361-
self, annotation_set_id: int, annotation_format='json', export_coordinates='pixel', full_path='true'
361+
self, annotation_set_id: int, annotation_format='json', export_coordinates='pixel', full_path=True, export_tags: bool = True,
362362
) -> bytes:
363363
"""
364364
Exports annotations in given format
365365
366366
Args:
367367
annotation_set_id: annotation set id
368368
annotation_format: can be one of ['json', 'coco', 'csv'], default='json'
369-
full_path: uses full image path (e.g. local path), can be one of ['true', 'false'], default='false'
369+
full_path: uses full image path (e.g. local path), it can be one of [True, False], default=True
370370
export_coordinates: converts output values to percentage or pixels, can be one of ['pixel', 'percent'], default='pixel'
371-
371+
export_tags: exports the tags to a CSV file, it can be one of [True, False], default=True
372372
Returns:
373373
annotation file content
374374
"""
375375
url = self.url(
376376
backend.v1_export_annotations.format(annotation_set_id),
377377
annotation_format=annotation_format,
378378
export_coordinates=export_coordinates,
379-
full_path=full_path,
379+
full_path=str(full_path).lower(),
380+
export_tags=str(export_tags).lower()
380381
)
381382
return self.get(url).content
382383

remo/domain/annotation_set.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,16 @@ def add_image_annotation(self, image_id: int, annotation: Annotation):
115115
self.sdk.add_annotation(self.id, image_id, annotation)
116116

117117
def export_annotations(
118-
self, annotation_format: str = 'json', export_coordinates: str = 'pixel', full_path: str = 'true'
118+
self, annotation_format: str = 'json', export_coordinates: str = 'pixel', full_path: bool = True, export_tags: bool = True
119119
):
120120
"""
121121
Exports annotations in a given format
122122
123123
Args:
124124
annotation_format: choose format from this list ['json', 'coco', 'csv']
125-
full_path: uses full image path (e.g. local path), can be one of ['true', 'false'], default='false'
125+
full_path: uses full image path (e.g. local path), it can be one of [True, False], default=True
126126
export_coordinates: converts output values to percentage or pixels, can be one of ['pixel', 'percent'], default='pixel'
127-
127+
export_tags: exports the tags to a CSV file, it can be one of [True, False], default=True
128128
Returns:
129129
annotation file content
130130
"""
@@ -133,30 +133,34 @@ def export_annotations(
133133
annotation_format=annotation_format,
134134
export_coordinates=export_coordinates,
135135
full_path=full_path,
136+
export_tags=export_tags
136137
)
137138

138139
def export_annotations_to_file(
139140
self,
140141
output_file: str,
141142
annotation_format: str = 'json',
142143
export_coordinates: str = 'pixel',
143-
full_path: str = 'true',
144+
full_path: bool = True,
145+
export_tags: bool = True
144146
):
145147
"""
146148
Exports annotations in given format and save to output file
147149
148150
Args:
149151
output_file: output file to save
150152
annotation_format: can be one of ['json', 'coco', 'csv'], default='json'
151-
full_path: uses full image path (e.g. local path), can be one of ['true', 'false'], default='false'
153+
full_path: uses full image path (e.g. local path), it can be one of [True, False], default=True
152154
export_coordinates: converts output values to percentage or pixels, can be one of ['pixel', 'percent'], default='pixel'
155+
export_tags: exports the tags to a CSV file, it can be one of [True, False], default=True
153156
"""
154157
self.sdk.export_annotations_to_file(
155158
output_file,
156159
self.id,
157160
annotation_format=annotation_format,
158161
full_path=full_path,
159162
export_coordinates=export_coordinates,
163+
export_tags=export_tags
160164
)
161165

162166
def classes(self) -> List[str]:

remo/domain/dataset.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ def export_annotations(
240240
annotation_set_id: int = None,
241241
annotation_format: str = 'json',
242242
export_coordinates: str = 'pixel',
243-
full_path: str = 'true',
243+
full_path: bool = True,
244+
export_tags: bool = True
244245
) -> bytes:
245246
"""
246247
Export annotations for a given annotation set
@@ -249,8 +250,9 @@ def export_annotations(
249250
annotation_set_id: annotation set id, by default will be used default_annotation_set
250251
annotation_format: can be one of ['json', 'coco', 'csv'], default='json'
251252
export_coordinates: converts output values to percentage or pixels, can be one of ['pixel', 'percent'], default='pixel'
252-
full_path: uses full image path (e.g. local path), can be one of ['true', 'false'], default='false'
253-
253+
full_path: uses full image path (e.g. local path), it can be one of [True, False], default=True
254+
export_tags: exports the tags to a CSV file, it can be one of [True, False], default=True
255+
254256
Returns:
255257
annotation file content
256258
"""
@@ -260,6 +262,7 @@ def export_annotations(
260262
annotation_format=annotation_format,
261263
export_coordinates=export_coordinates,
262264
full_path=full_path,
265+
export_tags=export_tags
263266
)
264267

265268
print('ERROR: annotation set not defined')
@@ -270,7 +273,8 @@ def export_annotations_to_file(
270273
annotation_set_id: int = None,
271274
annotation_format: str = 'json',
272275
export_coordinates: str = 'pixel',
273-
full_path: str = 'true',
276+
full_path: bool = True,
277+
export_tags: bool = True
274278
):
275279
"""
276280
Exports annotations in given format and save to output file
@@ -279,8 +283,9 @@ def export_annotations_to_file(
279283
output_file: output file to save
280284
annotation_set_id: annotation set id
281285
annotation_format: can be one of ['json', 'coco', 'csv'], default='json'
282-
full_path: uses full image path (e.g. local path), can be one of ['true', 'false'], default='false'
286+
full_path: uses full image path (e.g. local path), it can be one of [True, False], default=True
283287
export_coordinates: converts output values to percentage or pixels, can be one of ['pixel', 'percent'], default='pixel'
288+
export_tags: exports the tags to a CSV file, it can be one of [True, False], default=True
284289
"""
285290
annotation_set = self.get_annotation_set(annotation_set_id)
286291
if annotation_set:
@@ -290,6 +295,7 @@ def export_annotations_to_file(
290295
annotation_format=annotation_format,
291296
full_path=full_path,
292297
export_coordinates=export_coordinates,
298+
export_tags=export_tags
293299
)
294300
else:
295301
print('ERROR: annotation set not defined')

remo/sdk.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,17 +394,18 @@ def export_annotations(
394394
annotation_set_id: int,
395395
annotation_format: str = 'json',
396396
export_coordinates: str = 'pixel',
397-
full_path: str = 'true',
397+
full_path: bool = True,
398+
export_tags : bool = True
398399
) -> bytes:
399400
"""
400401
Exports annotations in given format
401402
402403
Args:
403404
annotation_set_id: annotation set id
404405
annotation_format: can be one of ['json', 'coco', 'csv'], default='json'
405-
full_path: uses full image path (e.g. local path), can be one of ['true', 'false'], default='false'
406+
full_path: uses full image path (e.g. local path), it can be one of [True, False], default=True
406407
export_coordinates: converts output values to percentage or pixels, can be one of ['pixel', 'percent'], default='pixel'
407-
408+
export_tags: exports the tags to a CSV file, it can be one of [True, False], default=True
408409
Returns:
409410
annotation file content
410411
"""
@@ -413,6 +414,7 @@ def export_annotations(
413414
annotation_format=annotation_format,
414415
export_coordinates=export_coordinates,
415416
full_path=full_path,
417+
export_tags=export_tags
416418
)
417419

418420
def export_annotations_to_file(
@@ -421,7 +423,8 @@ def export_annotations_to_file(
421423
annotation_set_id: int,
422424
annotation_format: str = 'json',
423425
export_coordinates: str = 'pixel',
424-
full_path: str = 'true',
426+
full_path: bool = True,
427+
export_tags: bool = True
425428
):
426429
"""
427430
Exports annotations in given format
@@ -430,14 +433,16 @@ def export_annotations_to_file(
430433
output_file: output file to save
431434
annotation_set_id: annotation set id
432435
annotation_format: can be one of ['json', 'coco', 'csv'], default='json'
433-
full_path: uses full image path (e.g. local path), can be one of ['true', 'false'], default='false'
436+
full_path: uses full image path (e.g. local path), it can be one of [True, False], default=True
434437
export_coordinates: converts output values to percentage or pixels, can be one of ['pixel', 'percent'], default='pixel'
438+
export_tags: exports the tags to a CSV file, it can be one of [True, False], default=True
435439
"""
436440
content = self.export_annotations(
437441
annotation_set_id,
438442
annotation_format=annotation_format,
439443
export_coordinates=export_coordinates,
440444
full_path=full_path,
445+
export_tags=export_tags
441446
)
442447
self._save_to_file(content, output_file)
443448

0 commit comments

Comments
 (0)