Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'FigureCanvasAgg' object has no attribute 'set_window_title' #830

Open
devxor opened this issue Feb 21, 2023 · 2 comments
Open

Comments

@devxor
Copy link

devxor commented Feb 21, 2023

Hi all,

executing below simple code I'm getting an error. The error is in imgaug.py, not in the code below. Anybody any feedback? Is it a bug? I'm expecting an image with bounding boxes be displayed.

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 message:

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'
@cire333
Copy link

cire333 commented Jun 14, 2023

I also get a similar error running the example posted on my mac.

   # points
    image = np.zeros((64, 64, 3), dtype=np.uint8)
    kps = [ia.Keypoint(x=10.5, y=20.5), ia.Keypoint(x=60.5, y=60.5)]
    kpsoi = ia.KeypointsOnImage(kps, shape=image.shape)
    image_with_kps = kpsoi.draw_on_image(image, size=7, color=(0, 0, 255))
    ia.imshow(image_with_kps)

I get the error message:

File "/Users/macbook/Projects/PythonML/mlkit/lib/python3.9/site-packages/imgaug/imgaug.py", line 2120, in imshow
    fig.canvas.set_window_title("imgaug.imshow(%s)" % (image.shape,))
AttributeError: 'FigureCanvasMac' object has no attribute 'set_window_title'

My error seems to thrown from the same function, but the error seems slightly different on the Mac.

@cire333
Copy link

cire333 commented Jun 15, 2023

This worked for me:

Open "imgaug.py" file, change line 2120 to:
fig.canvas.manager.set_window_title("imgaug.imshow(%s)" % (image.shape,))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants