Skip to content

Instantly share code, notes, and snippets.

@ndubey
Created December 25, 2019 14:53
Show Gist options
  • Save ndubey/163b424df6e63454f6e5ac6d2a4c0a8d to your computer and use it in GitHub Desktop.
Save ndubey/163b424df6e63454f6e5ac6d2a4c0a8d to your computer and use it in GitHub Desktop.
Data Collection from Google
from pathlib import Path
from send2trash import send2trash
from google_images_download import google_images_download
def downloadImages(keyword):
response = google_images_download.googleimagesdownload()
arguments = { "keywords":keyword, "limit":50, "format":'jpg', "size":"medium", "print_urls": False,
"image_directory":'./'+keyword.lower()+'/'}
response.download(arguments)
#also download png format images
arguments['format'] = "png"
response.download(arguments)
return
keywordList = [
{
"name": "chair"
},
{
"name": "bed"
},
{
"name": "table"
},
{
"name": "cupboard"
},
{
"name": "bench"
},
{
"name": "crib"
}
]
for item in keywordList:
keyword = item["name"]
downloadImages(keyword)
#You can do some post processing
#cropAndFilterImages(keyword, 'downloads/'+keyword.lower()+'/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment