Skip to content

Commit

Permalink
Check if image_shapes was initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
Wiebke committed Mar 6, 2024
1 parent 88afca2 commit 6193c53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions utils/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class Annotations:
def __init__(self, annotation_store, global_store):
def __init__(self, annotation_store, image_shape):
if annotation_store:
slices = []
for annotation_class in annotation_store:
Expand Down Expand Up @@ -49,7 +49,7 @@ def __init__(self, annotation_store, global_store):
self.annotation_classes = annotation_classes
self.annotations = annotations
self.annotations_hash = self.get_annotations_hash()
self.image_shape = global_store["image_shapes"][0]
self.image_shape = image_shape

def get_annotations(self):
return self.annotations
Expand Down
13 changes: 12 additions & 1 deletion utils/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,18 @@ def save_annotations_data(self, global_store, all_annotations, project_name):
"""
Transforms annotations data to a pixelated mask and outputs to the Tiled server
"""
annotations = Annotations(all_annotations, global_store)
if "image_shapes" in global_store:
image_shape = global_store["image_shapes"][0]
else:
print("Global store was not filled.")
data_shape = (
tiled_datasets.get_data_shape_by_name(project_name)
if project_name
else None
)
image_shape = (data_shape[1], data_shape[2])

annotations = Annotations(all_annotations, image_shape)
# TODO: Check sparse status, it may be worthwhile to store the mask as a sparse array
# if our machine learning models can handle sparse arrays
annotations.create_annotation_mask(sparse=False)
Expand Down

0 comments on commit 6193c53

Please sign in to comment.