'AxesImage' object has no property 'unique'

I’m trying to the code below for the bear classifier:

bears = bears.new(item_tfms=RandomResizedCrop(128, min_scale=0.3))
dls = bears.dataloaders(path)
dls.train.show_batch(max_n=4, nrows=1, unique=True)

But I’m getting an error ‘AxesImage’ object has no property ‘unique’. I did a git pull and all that before running the notebook, and I’m not finding exactly this error on the forum.

I tried running it without unique=True, and it ran just fine, but of course it didn’t display different versions of the same images, as expected by the book. Is this an error on my end, or did something change recently in the library?

Thanks for your insight!

Can you please post the full stack trace of the error? :slight_smile:

1 Like

Oh, of course. Thanks!

The unique parameter has ben added very recently.

commit ea96736533bfc5a046022c51028f2012fa2aca98
Author: Lucas Vazquez <lucasgouvaz@gmail.com>
Date:   Tue Mar 31 13:47:47 2020 -0300

    adds unique option to show_batch (#223)

    * adds unique option to show_batch

    * only changes get_idxs if necessary

If you want to be able to use it, you need to live with the bleeding edge:

!pip install git+https://github.com/fastai/fastai2 
!pip install git+https://github.com/fastai/fastcore
1 Like

Okay, thanks. Since this is the code that the notebook comes with, more people might run into this issue.


I ran into this issue just now, and blew a lot of time on it.

I think we need to add a note in the course notebooks for this.

Removing unique = True will fix it for those that don’t want to do the installs, but defeats the purpose in allowing you to see the various image transformations.

NOTE for any beginners who run into this:

Python caches imports, so even if you run those pip install statements in your notebook, you will still have to restart the kernel if you want to get this working.


Hi, I’m trying to figure out how to make this work, with the course notebook 02_production the code

dls.valid.show_batch(max_n=4, rows=1)

runs into this error so theres no unique=True to delete. I’m also running this on a clean build in Paperspace so I cannot git pull.

Hey buddy on my phone so forgive typos.

fast AI version 2 is under constant development and is going to be officially released alongside of the book.

Because of this the book is always up to date with the dev branch of the GitHub repo.

You need to install from the repo on your machine.

I can’t remember the exact syntax because I’m on my phone but I use a pip install command that points straight at a git repo. I will send that command to you later.

TLDR your fastai2 needs to be updated.

Ah that makes sense. This means the paperspace.com distribution needs to be updated.

BTW, I have no idea how technical you are in your background, so please forgive me if the next statement is obvious to you:

Paperspace, just like all Jupyter sessions, has the terminal option. I find this to be a convenient way to pull down git repos and run pip commands, etc.

Just stating this in case you are a less technical student, because as a professional software engineer, I really value the aspects of democratization in this class, and really hate when people assume knowledge among the students.



1 Like

Oh nice. Which commands are you running? Just ‘git pull fastai2’?

Check out Jeremy’s post on returning to work on Paperspace for the commands and more info: https://forums.fast.ai/t/platform-paperspace-free-paid-options/65515?u=go_go_gadget :slight_smile:

Oh thanks! I thought I was only for advanced users haha.

1 Like

For reference, looks like there is also a guide for returning to gradient


1 Like

I’m running into all sorts of issues with these dev notebooks too and while I get it that fastai2 is under constant development, I think that when a major release comes out, the whole stack of notebooks for the course should be tested to make sure they are consistent against that release… surely there is a way to automate that?

They always are. Each time a PR is submitted each nb is tested (in the whole repo). Can you be more specific on your issues?

What’s your environment? What notebook?

Oh! well that sounds sensible then, so I wonder what is going on … (I’m not the only one to run into these issues) …
I was messing about with notebook ‘lesson2-download.ipynb’ in the latest fastai/dev_nbs folder …

First problem I ran into was trying to download a bunch of image URLs from my Google Images search - the book says to run the following code in the js console:

urls = Array.from(document.querySelectorAll('.rg_di .rg_meta')).map(el=>JSON.parse(el.textContent).ou);
window.open('data:text/csv;charset=utf-8,' + escape(urls.join('\n')));

which didn’t work … I inspected the images in the js debugger and noted there were no ‘.rg_di’ selectors … so Google must have changed things since that was written - luckily I found some code in this forum that fixed it (would make a good errata for the book)

Second problem I ran into was with the lines:

for c in classes:
    verify_images(path/c, delete=True, max_size=500)

TypeError: verify_images() got an unexpected keyword argument ‘delete’
I looked in the source code and sure enough there is no longer a function with that signature…

Third problem I ran into was with the lines:

dls.show_batch(rows=3, figsize=(7,8))

AttributeError: ‘AxesImage’ object has no property ‘rows’

Here’s what I have installed in my python 3.7 virtual env:

(tf2.py3.7.0) [aaron@gpu data]$ pip list installed | grep fast
fastai                                     2.0.13
fastbook                                   0.0.11
fastcache                                  1.1.0
fastcore                                   1.0.11
fastdtw                                    0.3.4
fastjsonschema                             2.14.4
fastprogress                               0.2.6
fastscript                                 1.0.0
nbdev                                      1.0.19              /home/aaron/ai-files/fast.ai/nbdev

It’s actually illegal? Or frowned upon? To do it this way now. which is why we use bing in the recent course. (can’t remember the exact reason OOTOMH, but there was a pretty big reason for the migration)

Yes it now returns the list of filenames for you to unlink yourself (this has been posted on the forums before)

It’s n_rows I believe (also could have shown up on a forum search, I know I’ve seen that)

So it sounds like the code is out of step with the course notebooks no? Surely I shouldn’t have to go hunting around the forum to run these things? Or am I looking at the wrong notebooks?

Yes. Considering it’s last years notebooks, they’re not kept up to date as the library progresses as much (just look at the course-v3 repo) as there are other priorities. PR’s with fixes are more than welcome though :smiley: (eventually they will be gotten to otherwise, just I can’t give you a solid ETA as I’m not even a maintainer myself)