Image Data collection for deep learning projects

In this article we will be looking at image data collection for deep learning projects.

Many image datasets can be found for free for deep learning projects. What if you want your own data for a Deep Learning task like Image classification? Manually downloading images one by one can be bothersome.

We can use Bing Image Downloader for the purpose of image data collection.
Bing Image Downloader is a Python library to download bulk images from Bing.com. This package uses async url, which makes it very fast while downloading.

Installation

!pip install bing-image-downloader

How to use

from bing_image_downloader import downloader

def get_images(query):
    
    """Download images and place them in a directory"""
    
    print(query)
    
    downloader.download(query, 
                    limit=30, 
                    output_dir='HarryPotterdata', 
                    adult_filter_off=False, 
                    force_replace=False, 
                    timeout=60)

query : String to be searched.
limit : (optional, default is 100) Number of images to download.
output_dir : (optional, default is ‘dataset’) Name of output dir.
adult_filter_off : (optional, default is True) Enable of disable adult filteration.
force_replace : (optional, default is False) Delete folder if present and start a fresh download.
timeout : (optional, default is 60) timeout for connection in seconds.

Here, I am downloading Harry Potter character images.

Characters =['Harry Potter','Ron Weasley','Hermione Granger','Dobby','Rubeus Hagrid',
             'Ginny Weasley','Molly Weasley','Minerva McGonagall','Neville Longbottom',
             'Delores Umbridge','Lucius Malfoy','Bellatrix Lestrange','Albus Dumbledore',
             'Luna Lovegood','Draco Malfoy','Sirius Black','Voldemort','Severus Snape']
for character in Characters:
    print('Fetching images of', character)
    get_images(character)
data collection

All images will be downloaded in the directory. You can check the images in the output directory to filter relevant images.

Bing image downloader

Similar Posts

Leave a Reply