forked from jbum/qd_mosaic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_bins.py
31 lines (25 loc) · 1.11 KB
/
get_bins.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# get_desired_bins
import os, subprocess, argparse
from mosaic_constants import bdata_path
parser = argparse.ArgumentParser(description='Fetch bin files from quickdraw repository')
parser.add_argument('-v', '--verbose', default=False, action='store_true', help='Verbose')
parser.add_argument('-vv', '--vverbose', default=False, action='store_true', help='Very Verbose')
parser.add_argument('-t', '--test', default=False, action='store_true', help='Test - no actual commands are run')
parser.add_argument('bins', nargs='+', help="Bin(s) to grab, example: bird")
args = parser.parse_args()
# browse available bins
# https://console.cloud.google.com/storage/browser/quickdraw_dataset/full/binary
def do_command(cmd):
if args.verbose:
print(cmd)
if not args.test:
subprocess.check_call(cmd, shell=True)
for dbin in args.bins:
if args.verbose:
print("Getting " + dbin)
ifilename = dbin.replace(' ','\\ ') + ".bin"
ofilename = bdata_path + '/' + dbin.replace(' ','_') + '.bin'
if os.path.exists(ofilename):
continue
cmd = 'gsutil -m cp gs://quickdraw_dataset/full/binary/%s %s' % (ifilename, ofilename)
do_command(cmd)