VGG Download: Use all images, timeout URL requests.

This commit is contained in:
Brandon Amos 2016-03-02 10:40:43 -05:00
parent f9b8a28f8c
commit 1b4057da55
1 changed files with 5 additions and 4 deletions

View File

@ -64,7 +64,7 @@ for person in os.listdir(args.txt):
for line in contents: for line in contents:
id, uid, url, l, t, r, b, pose, detection, curation = line.split() id, uid, url, l, t, r, b, pose, detection, curation = line.split()
l, t, r, b = [int(float(x)) for x in [l, t, r, b]] l, t, r, b = [int(float(x)) for x in [l, t, r, b]]
if int(curation) == 1: # if int(curation) == 1:
jobs.append((person[:-4], url, (l, t, r, b))) jobs.append((person[:-4], url, (l, t, r, b)))
@ -80,7 +80,7 @@ def download(person, url, bb):
mkdirP(alignedPersonPath) mkdirP(alignedPersonPath)
if not os.path.isfile(rawImgPath): if not os.path.isfile(rawImgPath):
urlF = urllib2.urlopen(url) urlF = urllib2.urlopen(url, timeout=5)
with open(rawImgPath, 'wb') as f: with open(rawImgPath, 'wb') as f:
f.write(urlF.read()) f.write(urlF.read())
@ -104,7 +104,8 @@ def download(person, url, bb):
def download_packed(args): def download_packed(args):
try: try:
download(*args) download(*args)
except: except Exception as e:
print("\n".join((str(args), str(e))))
pass pass
pool = Pool(16) pool = Pool(16)