Created
December 25, 2019 14:53
-
-
Save ndubey/163b424df6e63454f6e5ac6d2a4c0a8d to your computer and use it in GitHub Desktop.
Data Collection from Google
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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