I have found this simple code below on some internet page, but I'm getting an error trying to execute it on my laptop. It should display an image with some bounding boxes on it.
The error occurs not in my code, but in ingaug.py, so inside of the package file. Is it some bug in the imgaug package?
I'm using MacOS, installed imgaug with condo from condo-forge channel.
Python code:
import imageio
import imgaug as ia
from imgaug.augmentables.bbs import BoundingBox, BoundingBoxesOnImage
%matplotlib inline
ia.seed(1)
image = imageio.imread("https://upload.wikimedia.org/wikipedia/commons/8/8e/Yellow-headed_caracara_%28Milvago_chimachima%29_on_capybara_%28Hydrochoeris_hydrochaeris%29.JPG")
image = ia.imresize_single_image(image, (298, 447))
bbs = BoundingBoxesOnImage([
BoundingBox(x1=0.2*447, x2=0.85*447, y1=0.3*298, y2=0.95*298),
BoundingBox(x1=0.4*447, x2=0.65*447, y1=0.1*298, y2=0.4*298)
], shape=image.shape)
ia.imshow(bbs.draw_on_image(image, size=2))
Error massage:
AttributeError Traceback (most recent call last)
Cell In[1], line 15
8 image = ia.imresize_single_image(image, (298, 447))
10 bbs = BoundingBoxesOnImage([
11 BoundingBox(x1=0.2*447, x2=0.85*447, y1=0.3*298, y2=0.95*298),
12 BoundingBox(x1=0.4*447, x2=0.65*447, y1=0.1*298, y2=0.4*298)
13 ], shape=image.shape)
---> 15 ia.imshow(bbs.draw_on_image(image, size=2))
File ~/miniconda3/envs/imgaug/lib/python3.11/site-packages/imgaug/imgaug.py:2120, in imshow(image, backend)
2117 w = max(w, 6)
2119 fig, ax = plt.subplots(figsize=(w, h), dpi=dpi)
-> 2120 fig.canvas.set_window_title("imgaug.imshow(%s)" % (image.shape,))
2121 # cmap=gray is automatically only activate for grayscale images
2122 ax.imshow(image, cmap="gray")
AttributeError: 'FigureCanvasAgg' object has no attribute 'set_window_title'