BSD500数据集下载和处理
首先,用urllib获取数据,写个压缩包文件,把数据存进去,解压压缩包文件,形成带有数据的目录。from os.path import exists, basename, joinfrom os import makedirs, removefrom six.moves import urllibimport tarfileclass download_basd300(object):def __
·
首先,用urllib获取数据,写个压缩包文件,把数据存进去,解压压缩包文件,形成带有数据的目录。
from os.path import exists, basename, join
from os import makedirs, remove
from six.moves import urllib
import tarfile
class download_basd300(object):
def __init__(self, dest="dataset"):
self.output_image_dir = join(dest, 'BSD500/images')
if not exists(self.output_image_dir):
makedirs(self.output_image_dir)
url = "http://www2.eecs.berkeley.edu/Research/Projects/CS/vision/bsds/BSDS300-images.tgz"
print("download url", url)
data = urllib.request.urlopen(url)
file_path = join(dest, basename(url))
with open(file_path, 'wb') as f:
f.write(data.read())
print('Extracting data')
with tarfile.open(file_path) as tar:
for item in tar:
tar.extract(item, dest)
remove(file_path)
self.get()
def get(self):
return self.output_image_dir
dataset = download_basd300()
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)