How to identify images with no information?

How can I print the list of images that have no information/empty? I have the following images after data transformation. The last one seems to be empty. I suspect there are many like this in the data and probably affecting the dice scores.

For example, I use the following code to check manually with OpenCV. Is there anything similar in fastai to do this? I know there is a widget cleaner but I reckon it is not automatic.

import cv2 
image = cv2.imread("image.tff", 0)
if cv2.countNonZero(image) == 0:
    print "Image is bad"
else:
    print "image is good"
1 Like

Using some threshold-based algorithm for checking seems to be the best way to do this automatically.

Hi gbubs hope you are well!

Would making an image classifier as in lecture 1 "teddy bears"classifier, with two classes blank and “not blank” and passing your images through it work :question:

Just a thought.

Cheers mrfabulous1 :smiley::smiley:

Hey, my aim is to find the blank image at the initial steps and remove them.

You’re correct, the ImageCleaner widget that @lesscomfortable created can help but it requires manually scanning through images (a bunch at a time) and deleting the bad ones. (more here: Duplicate Widget)

There is also the verify_images function (doc, src) that can verify the image path, if the image file is readable or not and if it has specified no. of channels etc. It can delete an image that fails these tests, but perhaps you can modify it to simply print the filenames.

Hope this helps!

1 Like