|
5 | 5 | import datetime as dt |
6 | 6 | import json |
7 | 7 | import logging |
8 | | -from typing import Any, Dict, Sequence |
| 8 | +from typing import Any, Dict |
9 | 9 |
|
10 | | -from labelbox.exceptions import UnknownFormatError |
11 | 10 | from PIL import Image |
12 | 11 | import requests |
13 | 12 | from shapely import wkt |
14 | 13 | from shapely.geometry import Polygon |
15 | 14 |
|
| 15 | +from labelbox.exceptions import UnknownFormatError |
| 16 | + |
16 | 17 |
|
17 | 18 | def from_json(labeled_data, coco_output, label_format='WKT'): |
18 | 19 | "Writes labelbox JSON export into MS COCO format." |
@@ -48,29 +49,25 @@ def make_coco_metadata(project_name: str, created_by: str) -> Dict[str, Any]: |
48 | 49 | Returns: |
49 | 50 | The COCO export represented as a dictionary. |
50 | 51 | """ |
51 | | - coco = { |
52 | | - 'info': None, |
| 52 | + return { |
| 53 | + 'info': { |
| 54 | + 'year': dt.datetime.now(dt.timezone.utc).year, |
| 55 | + 'version': None, |
| 56 | + 'description': project_name, |
| 57 | + 'contributor': created_by, |
| 58 | + 'url': 'labelbox.com', |
| 59 | + 'date_created': dt.datetime.now(dt.timezone.utc).isoformat() |
| 60 | + }, |
53 | 61 | 'images': [], |
54 | 62 | 'annotations': [], |
55 | 63 | 'licenses': [], |
56 | 64 | 'categories': [] |
57 | 65 | } |
58 | 66 |
|
59 | | - coco['info'] = { |
60 | | - 'year': dt.datetime.now(dt.timezone.utc).year, |
61 | | - 'version': None, |
62 | | - 'description': project_name, |
63 | | - 'contributor': created_by, |
64 | | - 'url': 'labelbox.com', |
65 | | - 'date_created': dt.datetime.now(dt.timezone.utc).isoformat() |
66 | | - } |
67 | | - |
68 | | - return coco |
69 | | - |
70 | 67 |
|
71 | 68 | def add_label( |
72 | 69 | coco: Dict[str, Any], label_id: str, image_url: str, |
73 | | - labels: Sequence[Any], label_format: str): |
| 70 | + labels: Dict[str, Any], label_format: str): |
74 | 71 | """Incrementally updates COCO export data structure with a new label. |
75 | 72 |
|
76 | 73 | Args: |
|
0 commit comments