Skip to content

Commit 902d1a7

Browse files
committed
Mypy fixes
1 parent d8a608d commit 902d1a7

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

labelbox/exporters/coco_exporter.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
import datetime as dt
66
import json
77
import logging
8-
from typing import Any, Dict, Sequence
8+
from typing import Any, Dict
99

10-
from labelbox.exceptions import UnknownFormatError
1110
from PIL import Image
1211
import requests
1312
from shapely import wkt
1413
from shapely.geometry import Polygon
1514

15+
from labelbox.exceptions import UnknownFormatError
16+
1617

1718
def from_json(labeled_data, coco_output, label_format='WKT'):
1819
"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]:
4849
Returns:
4950
The COCO export represented as a dictionary.
5051
"""
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+
},
5361
'images': [],
5462
'annotations': [],
5563
'licenses': [],
5664
'categories': []
5765
}
5866

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-
7067

7168
def add_label(
7269
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):
7471
"""Incrementally updates COCO export data structure with a new label.
7572
7673
Args:

labelbox/exporters/voc_exporter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import json
66
import logging
77
import os
8-
from typing import Any, Sequence
8+
from typing import Any, Dict
99

1010
from PIL import Image
1111
import requests
@@ -63,7 +63,7 @@ def from_json(labeled_data, annotations_output_dir, images_output_dir,
6363

6464

6565
def write_label( # pylint: disable-msg=too-many-arguments
66-
label_id: str, image_url: str, labels: Sequence[Any], label_format: str,
66+
label_id: str, image_url: str, labels: Dict[str, Any], label_format: str,
6767
images_output_dir: str, annotations_output_dir: str):
6868
"""Writes a single Pascal VOC formatted image and label pair to disk.
6969

0 commit comments

Comments
 (0)