'-v', action='store_true', help='Enable verbose log') args = p.parse_args() if args.wnid_list is not None: with open(args.wnid_list) as f: args.wnid = [wnid.strip() for wnid in f] if args.wnid is None: print('No wnid') sys.exit() logging.basicConfig(level=logging.DEBUG, format='%(message)s') downloader = imagedownloader.ImageNetDownloader() username = None accessKey = None userInfo = pref_utils.readUserInfo() if not userInfo is None: username = userInfo[0] accessKey = userInfo[1] def kernel_getWnid(iid, imgAcat, ret): ilist = downloader.getImageURLsOfWnid(iid) ilist = filterSafeDomainOnly(ilist) msg = "{:15s} {:6d} urls".format(iid, len(ilist)) if len(ilist) >= imgAcat: msg = msg + " *" logging.debug(msg) ret.append([iid, len(ilist)]) def thread_getWnid(wnid, imgAcat): max_ths = args.max_threads ret = []
p.add_argument('--downloadImages', help='Should download images', action='store_true', default=False) p.add_argument('--downloadOriginalImages', help='Should download original images', action='store_true', default=False) p.add_argument('--downloadBoundingBox', help='Should download bouding box annotation files', action='store_true', default=False) # p.add_argument('--jobs', '-j', type=int, default=1, help='Number of parallel threads to download') # p.add_argument('--timeout', '-t', type=int, default=10, help='Timeout per image in seconds') # p.add_argument('--retry', '-r', type=int, default=10, help='Max count of retry for each image') p.add_argument('--verbose', '-v', action='store_true', help='Enable verbose log') args = p.parse_args() if args.wnid is None: print 'No wnid' sys.exit() downloader = imagedownloader.ImageNetDownloader() username = None accessKey = None userInfo = pref_utils.readUserInfo() if not userInfo is None: username = userInfo[0] accessKey = userInfo[1] if args.downloadImages is True: for id in args.wnid: list = downloader.getImageURLsOfWnid(id) downloader.downloadImagesByURLs(id, list) if args.downloadBoundingBox is True: for id in args.wnid: # Download annotation files downloader.downloadBBox(id) if args.downloadOriginalImages is True: