主页:http://www.robots.ox.ac.uk/~vgg/data/vgg_face/
下载地址:http://www.robots.ox.ac.uk/~vgg/data/vgg_face/vgg_face_dataset.tar.gz
import threading import urllib import os def download_and_save(url, savename): try: urlopen = urllib.URLopener() fp = urlopen.open(url) data = fp.read() fp.close() fid = open(savename, 'w+b') fid.write(data) #print "下载成功:" + url fid.close() except IOError: print "下载失败:" + url def get_all_iamge(filename): fid = open('files/'+filename) lines = fid.readlines() for line in lines: line_split = line.split(' ') name = filename[:-4] image_id = line_split[0] image_url = line_split[1] if False == os.path.exists('image/'+name): os.mkdir('image/'+name) savefile ='image/'+ name + '/' + image_id + '.jpg' while True: if (len(threading.enumerate()) < 10): break t = threading.Thread(target=download_and_save, args=(image_url, savefile,)) t.start() if __name__ == "__main__": file_list = os.listdir('files') for file in file_list: get_all_iamge(file)
图片人名列表:
下载的图片: