Skip to content

Commit

Permalink
Tweaks to fetching script.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesse-r-s-hines committed Nov 13, 2019
1 parent bc82f8c commit 3a5fa66
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion fetchCOCO.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def fetchCategory(category, destination):
os.makedirs(destination)

for image_index, (image_id, anns) in enumerate(imageAnns.items()):
if (image_index % 1000 == 0):
if (image_index % 5000 == 0):
print(f"Processing image {image_index} of {len(images)}...")
# get all objects matching category out of the image and crop each of them to their bbox.
# Saved each to different image.
Expand Down
20 changes: 11 additions & 9 deletions fetchImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
import fetchPersonal as Personal
import fetchVisualGenome as VisualGenome

usage = "fetch.py category destination\n"
usage = "fetch.py destination categories...\n"

if __name__ == '__main__':
args = sys.argv[1:]

if (len(args) != 2):
if (len(args) < 2):
print(usage)
sys.exit()

category = args[0]
destination = args[1].rstrip("/")
destination = args[0].rstrip("/")
categories = args[1:]

COCO.fetchCategory(category, destination)
OpenImages.fetchCategory(category, destination)
Personal.fetchCategory(category, destination)
VisualGenome.fetchCategory(category, destination)
for category in categories:
COCO.fetchCategory(category, destination)
OpenImages.fetchCategory(category, destination)
Personal.fetchCategory(category, destination)
VisualGenome.fetchCategory(category, destination)
print("\n")

print(f"DONE! All images of {category} in all databases saved to {destination}")
print(f"DONE! All images of {', '.join(categories)} in all databases saved to {destination}")
2 changes: 1 addition & 1 deletion fetchOpenImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def fetchCategory(category, destination):
category = getCategories()[category.lower()]

for batchIndex, batch in enumerate( batchImagesForCategory(category, batchSize=8) ):
if (batchIndex % 5 == 0):
if (batchIndex % 10 == 0):
print(f"Processing batch {batchIndex}")
options = "--no-sign-request --only-show-errors"
command = [
Expand Down
2 changes: 1 addition & 1 deletion fetchVisualGenome.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def fetchCategory(category, destination):
# queryResults will be a map of imageId : region Containing the largest region in each image that matches category
# and is at least half targetDiminsions
for imageIndex, img in enumerate(imageObjects):
if (imageIndex % 1000 == 0):
if (imageIndex % 5000 == 0):
print(f"Processing image {imageIndex} of {len(imageObjects)}...")
largest = None
for obj in img['objects']:
Expand Down

0 comments on commit 3a5fa66

Please sign in to comment.