Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"editor.tabSize": 2
},
"python.formatting.blackPath": "black",
"python.formatting.provider": "none",
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing these lines below on here will mean that formatOnSave starts working better

"-l 120"
],
Expand Down
4 changes: 2 additions & 2 deletions darwin/exporter/formats/darwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ def build_image_annotation(annotation_file: dt.AnnotationFile) -> Dict[str, Any]
}
"""
annotations: List[Dict[str, Any]] = []
print(annotations)
for annotation in annotation_file.annotations:
payload = {
annotation.annotation_class.annotation_type: _build_annotation_data(annotation),
"name": annotation.annotation_class.name,
}

if (
annotation.annotation_class.annotation_type == "complex_polygon"
or annotation.annotation_class.annotation_type == "polygon"
annotation.annotation_class.annotation_type == "complex_polygon" or annotation.annotation_class.annotation_type == "polygon"
) and "bounding_box" in annotation.data:
payload["bounding_box"] = annotation.data["bounding_box"]

Expand Down
11 changes: 3 additions & 8 deletions darwin/exporter/formats/darwin_1_0.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from typing import Any, Dict, Iterable, List, Union
from typing import Iterable, List, Union

import orjson as json

Expand Down Expand Up @@ -34,14 +34,11 @@ def export(annotation_files: Iterable[AnnotationFile], output_dir: Path) -> None


def _export_file(annotation_file: AnnotationFile, _: int, output_dir: Path) -> None:

try:
filename = annotation_file.path.parts[-1]
output_file_path = (output_dir / filename).with_suffix(".json")
except Exception as e:
raise ExportException_CouldNotAssembleOutputPath(
f"Could not export file {annotation_file.path} to {output_dir}"
) from e
raise ExportException_CouldNotAssembleOutputPath(f"Could not export file {annotation_file.path} to {output_dir}") from e

try:
output: DictFreeForm = _build_json(annotation_file)
Expand All @@ -50,9 +47,7 @@ def _export_file(annotation_file: AnnotationFile, _: int, output_dir: Path) -> N

try:
with open(output_file_path, "w") as f:
op = json.dumps(output, option=json.OPT_INDENT_2 | json.OPT_SERIALIZE_NUMPY | json.OPT_NON_STR_KEYS).decode(
"utf-8"
)
op = json.dumps(output, option=json.OPT_INDENT_2 | json.OPT_SERIALIZE_NUMPY | json.OPT_NON_STR_KEYS).decode("utf-8")
f.write(op)
except Exception as e:
raise ExportException_CouldNotWriteFile(f"Could not write output for {annotation_file.path}") from e
Expand Down
Loading