Bears.new - 02_production

Hi guys, I have a confusion:

I know that in chapter 02_production, bears is a Datablock in this code:

image

Ok my confusion is what does bears.news do? in this line of code:

image

I see that it modifies item_tfms by adding ResizeMethod.Squish , but does it modify the rest of the content in the bears DataBlock lile blocks, get_items, splitter? or it just updated item_tfms without affecting the rest?

It creates a new DataBlock based on the old one by adjusting anything inside of it (similar to DataLoader.new)

2 Likes

@muellerzr thank you very much! I appreciate it.

Hey @muellerzr, I had a doubt regarding the ImageCleaner class.
I have modified the Bears dataset and am using my own Classification dataset. I have downloaded the images, but there are some unwanted images in the dataset. So I was using Fastai2 ImageCleaner class like this
fns = get_image_files(path)
w = ImagesCleaner(max_n=150)
w.set_fns(fns)
w

As given in the documentation. Then the widgets come to keep or delete the images. After selecting images to keep and delete, how to create a new DataLoader class with the required information about the new selection of images?
Also after I write w.delete(), the images I chose to delete aren’t actually getting deleted.
Can anyone guide me with this?

Thanks in advance

Hi @avenio, maybe this could help:

So, for instance, to delete ( unlink ) all images selected for deletion, we would run:

for idx in cleaner.delete(): cleaner.fns[idx].unlink()

To move images for which we’ve selected a different category, we would run:

for idx,cat in cleaner.change(): shutil.move(str(cleaner.fns[idx]), path/cat)
1 Like

Thanks a lot @ricardocalleja. It really helped a lot.

1 Like