FashionGen数据集下载
数据集下载
FashionGen数据集是一个公开数据集,经常用来做图文融合。但是去官网下载的话只是填了一个问卷,接着就没有下文了。
经过很长时间的寻找,我最终找到了一个可以在Google Drive上进行下载的FashionGen训练集和验证集,我下载下来后将其存在百度网盘中,供大家下载使用。
由于百度网盘上传文件大小限制,这里将训练集分卷压缩后上传,使用者下载下来后,将训练集的几个压缩文件放在一个目录下,全选中,右键解压即可。
链接:https://pan.baidu.com/s/1amJvPYeRXYP-uKv8Cl1fyQ
提取码:pz7a
数据集解析并保存所需信息到csv,以及保存图片
import h5py
import csv
from PIL import Image
csvfile_path = './fashiongen_train'
path_behind = 0
headline = ['index','description','category']
file_h5 = h5py.File('fashiongen_256_256_train.h5', 'r')
for i in range(0,len(file_h5['index'])-1):
print(i)
index = file_h5['index'][i][0]
try:
category = str(file_h5['input_category'][i][0],'UTF-8')
description = str(file_h5['input_description'][i][0],'UTF-8')
except Exception as e:
continue
img = Image.fromarray(file_h5['input_image'][i])
img.save('./image/' + str(index) + '.jpg')
if index % 50000 == 0:
path_behind += 1
csvfile = open(csvfile_path + str(path_behind) + '.csv', 'w', newline='')
writer = csv.DictWriter(csvfile, fieldnames=headline)
writer.writeheader()
newData = {'index': str(index), 'description': description, 'category': category}
writer.writerow(newData)
csvfile.close()
效果展示