Skip to content

Commit b217352

Browse files
committed
Fixed small issues and added image reading method
1 parent da42150 commit b217352

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

agml/io.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import random
1616
import inspect
1717

18+
import cv2
19+
1820
from agml.utils.io import (
1921
get_file_list as _get_file_list,
2022
get_dir_list as _get_dir_list,
@@ -112,5 +114,15 @@ def random_file(path, **kwargs):
112114
return random.choice(get_file_list(path, **kwargs))
113115

114116

117+
def read_image(path, **kwargs):
118+
"""Reads an image from a file.
119+
120+
Args:
121+
path (str): The path to the image file.
122+
**kwargs: Keyword arguments to pass to `cv2.imread`.
115123
124+
Returns:
125+
numpy.ndarray: The image.
126+
"""
127+
return cv2.imread(path, **kwargs)
116128

agml/models/segmentation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from agml.data.public import source
3333
from agml.utils.general import resolve_list_value
3434
from agml.utils.image import resolve_image_size
35-
from agml.viz.masks import show_image_with_overlaid_mask, show_image_and_mask
35+
from agml.viz.masks import show_image_and_overlaid_mask, show_image_and_mask
3636

3737
# This is last since `agml.models.base` will check for PyTorch Lightning,
3838
# and PyTorch Lightning automatically installed torchmetrics with it.
@@ -250,7 +250,7 @@ def show_prediction(self, image, overlay = False, **kwargs):
250250
image = self._expand_input_images(image)[0]
251251
mask = self.predict(image, **kwargs)
252252
if overlay:
253-
return show_image_with_overlaid_mask(image, mask, **kwargs)
253+
return show_image_and_overlaid_mask(image, mask, **kwargs)
254254
return show_image_and_mask(image, mask, **kwargs)
255255

256256
def load_benchmark(self, dataset):

agml/viz/boxes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ def annotate_object_detection(image,
110110
"either `bbox` or `bboxes` for bounding boxes.")
111111
if bbox_format is not None:
112112
bboxes = convert_bbox_format(bboxes, bbox_format)
113+
if labels is None:
114+
labels = [0] * len(bboxes)
113115

114116
# Run a few final checks in order to ensure data is formatted properly.
115117
image = format_image(image, mask = False)

0 commit comments

Comments
 (0)