You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Downloads resource images with the specified terms
def __resourceDownloader(self, count=300):
for person in self.__persons:
print("--Downloading Resources for '{}'".format(person))
folder = "./tmp/downloaded_images/" + person
# Fetch links from Bing Images and download images
BingImages.download(BingImages(person + " face", count=count, person="portrait").get(), folder)
counter = 0
# Rename the files accordingly
for filename in os.listdir(folder):
filepath = folder + "/" + filename , file_extension = os.path.splitext(filepath)
# Remove files that are of wrong type or too small
if file_extension.lower() not in [".jpg", ".jpeg"] or os.path.getsize(filepath) < 1024*128: # File not jpeg smaller than 128kb
os.remove(filepath)
continue
tries = 0
# Rename all other files with fitting schema "img_X.jpg"
while(tries < 1000000):
try:
os.rename(filepath, folder + "/" + "image" + str(counter) + ".jpg")
break
# Catch error that a file may exist already with a certain name
except FileExistsError:
tries += 1
counter += 1
pass
counter += 1
im using this code which i believe you made but is not working for some reason is there any error?
The text was updated successfully, but these errors were encountered:
Downloads resource images with the specified terms
def __resourceDownloader(self, count=300):
for person in self.__persons:
print("--Downloading Resources for '{}'".format(person))
folder = "./tmp/downloaded_images/" + person
# Fetch links from Bing Images and download images
BingImages.download(BingImages(person + " face", count=count, person="portrait").get(), folder)
counter = 0
# Rename the files accordingly
for filename in os.listdir(folder):
filepath = folder + "/" + filename
, file_extension = os.path.splitext(filepath)
# Remove files that are of wrong type or too small
if file_extension.lower() not in [".jpg", ".jpeg"] or os.path.getsize(filepath) < 1024*128: # File not jpeg smaller than 128kb
os.remove(filepath)
continue
tries = 0
# Rename all other files with fitting schema "img_X.jpg"
while(tries < 1000000):
try:
os.rename(filepath, folder + "/" + "image" + str(counter) + ".jpg")
break
# Catch error that a file may exist already with a certain name
except FileExistsError:
tries += 1
counter += 1
pass
counter += 1
im using this code which i believe you made but is not working for some reason is there any error?
The text was updated successfully, but these errors were encountered: