Skip to content

Commit

Permalink
Merge pull request #116 from IDEA-Research/bugfix/start_by_configfile
Browse files Browse the repository at this point in the history
Bugfix/start by configfile
  • Loading branch information
imhuwq authored Jan 2, 2024
2 parents 6112526 + 8868903 commit a19f6e9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
Empty file modified build_doc.sh
100644 → 100755
Empty file.
8 changes: 6 additions & 2 deletions deepdataspace/model/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def _add_annotation(self,
keypoint_colors: List[int] = None,
keypoint_skeleton: List[int] = None,
keypoint_names: List[str] = None,
caption: str = None,
confirm_type: int = 0,
):
if bbox:
Expand All @@ -341,7 +342,7 @@ def _add_annotation(self,
keypoint_skeleton,
keypoint_names)
anno_obj = Object(label_name=label, label_type=label_type, label_id=label_obj.id,
category_name=category, category_id=category_obj.id,
category_name=category, category_id=category_obj.id, caption=caption,
bounding_box=bounding_box, segmentation=segmentation, alpha=alpha_uri,
points=points, lines=lines, point_colors=colors, point_names=names,
conf=conf, is_group=is_group, confirm_type=confirm_type)
Expand All @@ -361,6 +362,7 @@ def add_annotation(self,
keypoint_colors: List[int] = None,
keypoint_skeleton: List[int] = None,
keypoint_names: List[str] = None,
caption: str = None,
confirm_type: int = 0,
):
"""
Expand All @@ -380,13 +382,14 @@ def add_annotation(self,
:param keypoint_names: the key point names, ["nose", "left_eye", ...].
:param keypoint_colors: the key point colors, [255, 0, 0, ...].
:param keypoint_skeleton: the key point skeleton, [0, 1, 2, ...].
:param caption: the caption of the annotation.
:param confirm_type: the confirm_type of the annotation, 0 = not confirmed, 1 = gt may be fn, 2 = pred may be fp
"""

self._add_annotation(category, label, label_type, conf,
is_group, bbox, segmentation, alpha_uri,
keypoints, keypoint_colors, keypoint_skeleton, keypoint_names,
confirm_type)
caption, confirm_type)

self.save()
self._update_dataset(bbox, segmentation, alpha_uri, keypoints)
Expand Down Expand Up @@ -434,6 +437,7 @@ def batch_add_annotation(self,
:param keypoint_names: the key point names, ["nose", "left_eye", ...].
:param keypoint_colors: the key point colors, [255, 0, 0, ...].
:param keypoint_skeleton: the key point skeleton, [0, 1, 2, ...].
:param caption: the caption of the annotation.
:param confirm_type: the confirm_type of the annotation, 0 = not confirmed, 1 = gt may be fn, 2 = pred may be fp
:return: None
"""
Expand Down
6 changes: 5 additions & 1 deletion deepdataspace/plugins/coco2017/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import Dict
from typing import List
from typing import Tuple
import traceback

from deepdataspace.constants import DatasetFileType
from deepdataspace.constants import DatasetType
Expand Down Expand Up @@ -94,8 +95,11 @@ def parse_meta(meta_path: str):
try:
info = COCO2017Importer._parse_meta(meta_path)
except Exception as err:
logger.error(traceback.format_exc())
logger.error(f"Failed to parse meta file {meta_path}: {err}")
return None

logger.info(f"Successfully parsed meta file {meta_path}: {info}")
return info

def load_ground_truth(self):
Expand All @@ -118,7 +122,7 @@ def load_ground_truth(self):

def load_predictions(self):
for file_tag, file_path in self.dataset.files.items():
if not file_tag.startswith("PRED/"):
if not file_tag.startswith(f"{DatasetFileType.Prediction}/"):
continue

pred_name = file_tag.split("/", 1)[-1]
Expand Down
10 changes: 5 additions & 5 deletions deepdataspace/services/dds.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self,

home_dir = os.path.expanduser("~")
runtime_dir = os.path.join(home_dir, ".deepdataspace")
self.runtime_dir = self.argument_or_config("runtime_dir", runtime_dir, None)
self.runtime_dir = self.argument_or_config("runtime_dir", None, runtime_dir)

self.configfile = configfile
self.from_cmdline = from_cmdline
Expand All @@ -97,11 +97,11 @@ def __init__(self,
self.dl_prefix = "https://deepdataspace.oss-accelerate.aliyuncs.com/install_files"
self.distro = PLATFORM if PLATFORM != Platforms.Linux else f"ubuntu{get_ubuntu_version()}"

def argument_or_config(self, key, value, default):
if value is not None:
return value
def argument_or_config(self, config_key, arg_value, default):
if arg_value is not None:
return arg_value
else:
return self.config_data.get(key, default)
return self.config_data.get(config_key, default)

def exit_or_raise(self, msg: str):
if self.from_cmdline is True:
Expand Down

0 comments on commit a19f6e9

Please sign in to comment.