Skip to content

Commit

Permalink
refactor: rename detections
Browse files Browse the repository at this point in the history
  • Loading branch information
denniswittich committed Nov 8, 2024
1 parent 58b39ed commit 2361015
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions learning_loop_node/detector/outbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self) -> None:

def save(self,
image: bytes,
detections: Optional[ImageMetadata] = None,
image_metadata: Optional[ImageMetadata] = None,
tags: Optional[List[str]] = None,
source: Optional[str] = None,
creation_date: Optional[str] = None
Expand All @@ -66,25 +66,25 @@ def save(self,
self.log.error('Invalid jpg image')
return

if detections is None:
detections = ImageMetadata()
if image_metadata is None:
image_metadata = ImageMetadata()
if not tags:
tags = []
identifier = datetime.now().isoformat(sep='_', timespec='microseconds')
if os.path.exists(self.path + '/' + identifier):
self.log.error('Directory with identifier %s already exists', identifier)
return
tmp = f'{GLOBALS.data_folder}/tmp/{identifier}'
detections.tags = tags
image_metadata.tags = tags
if creation_date and self._is_valid_isoformat(creation_date):
detections.date = creation_date
image_metadata.date = creation_date
else:
detections.date = identifier
detections.source = source or 'unknown'
image_metadata.date = identifier
image_metadata.source = source or 'unknown'
os.makedirs(tmp, exist_ok=True)

with open(tmp + '/image.json', 'w') as f:
json.dump(jsonable_encoder(asdict(detections)), f)
json.dump(jsonable_encoder(asdict(image_metadata)), f)

with open(tmp + '/image.jpg', 'wb') as f:
f.write(image)
Expand Down

0 comments on commit 2361015

Please sign in to comment.