miniImagenet下載地址 :
- 百度雲鏈接: https://pan.baidu.com/s/1npRhZajLrLe6-KtSbJsa1A 密碼: ztp5
- 百度雲下載超級慢,翻牆用谷歌雲盤:https://drive.google.com/open?id=1HkgrkAwukzEZA0TpO7010PkAOREb2Nuk
- 需要csv文件從這裏獲取:https://github.com/vieozhu/MAML-TensorFlow-1
Omniglot數據集:https://blog.csdn.net/weixin_41803874/article/details/91896817
小樣本學習數據集
最近由於實驗室項目原因開始研究小樣本學習(few shot learning),看了一些論文,發現裏面常用的測試數據集主要有Omniglot和miniImagenet兩個,但是網上能查到的下載地址都在谷歌網盤上,而且miniImagenet中還缺少標註數據的csv文件,經過一番搜尋終於搞定兩個數據集,搬到國內網盤上,方便以後要用到。
開始主要是跑MAML算法測試,發現github上cbfinn提供的代碼https://github.com/cbfinn/maml.git中,處理數據的部分只適用於linux,在win下運行會出錯,將proc_images.py中os.system改爲對應的os操作即可。
直接貼修改後的代碼
from __future__ import print_function
import csv
import glob
import os
from PIL import Image
path_to_images = 'images/'
all_images = glob.glob(path_to_images + '*')
# Resize images
for i, image_file in enumerate(all_images):
im = Image.open(image_file)
im = im.resize((84, 84), resample=Image.LANCZOS)
im.save(image_file)
if i % 500 == 0:
print(i)
# Put in correct directory
for datatype in ['train', 'val', 'test']:
os.mkdir(datatype)
with open(datatype + '.csv', 'r') as f:
reader = csv.reader(f, delimiter=',')
last_label = ''
for i, row in enumerate(reader):
if i == 0: # skip the headers
continue
label = row[1]
image_name = row[0]
if label != last_label:
cur_dir = datatype + '/' + label + '/'
os.mkdir(cur_dir)
last_label = label
os.rename('images/' + image_name, cur_dir+image_name)
---------------------
作者:Learn2Learn
原文:https://blog.csdn.net/u014767662/article/details/81203134