zl程序教程

您现在的位置是:首页 >  其它

当前栏目

(三)Omniglot Dataset介绍

介绍 Dataset
2023-09-27 14:26:28 时间

欢迎访问个人网络日志🌹🌹知行空间🌹🌹


0.用来做什么

Omniglot Dataset数据集由于类别多(1623个类),每个类别包含的数据少(每类只有20个数据),所以区别于Lecun发布的MNIST数据集,Omniglot Dataset通常用于one-shot leanring(小样本学习)。

1.什么时候从哪来

Omniglot Dataset第一次使用在2015年纽约大学的一篇论文Human-level concept learning
through probabilistic
program induction
中,该数据集是在亚马逊人工智能兼职众包平台
Amazon's Mechanical Turk上由20个人完成的,得到了语言学网站omniglot.com的支持。

2.包含什么内容

Omniglot Dataset翻译过来就是全语言文字数据集,包含各种语言的不同字母表,如日语的平假名Japanese_(hiragana)52个日语的片假名(Japanese_(katakana)47个韩语的元音21个和辅音19个共40个,最常见的拉丁字母abcd26个等。Omniglot Dataset共包含50个不同语言的字母表,每个字母表中包含不同的字符,共1623种字符,每个字符有20个不同的人书写。也就是说Omniglot Dataset数据集包含1623个类,每个类有20个训练数据。每个图像的大小是105x105像素。

日语平假名(omniglot-master/python/images_background/Japanese_(hiragana))

在这里插入图片描述

3.如何下载使用

可以从Omniglot Datasetgithub仓库下载。下载仓库后分别提供了pythonmatlabapi,这里以python为例说,python下的文件目录为:

.
├── demo.py # 举例展示数据集的部分数据
├── images_background_small1.zip # images_background的一部分,用于`minimal`学习
├── images_background_small2.zip # mages_background的一部分,用于`minimal`学习
├── images_background.zip # 训练数据
├── images_evaluation.zip # 测试数据
├── strokes_background_small1.zip # 对应的笔画(x,y,t)
├── strokes_background_small2.zip # 对应的笔画(x,y,t)
├── strokes_background.zip # 对应的笔画(x,y,t)
└── strokes_evaluation.zip # 对应的笔画(x,y,t)

对上面的文件夹介绍,详见仓库READMEOmniglot Dataset被划分成了训练数据和测试数据两部分,images_background.zip训练数据包含30种不同语言字母表,images_evaluation.zip测试数据包含20种不同语言字母表。images_background_small1.zipimages_background_small2.zip是训练数据images_background.zip中选出来的5种语言字母表,一个成年人差不多也是熟悉5种字母表,通过这种small的划分,当作训练数据更好的模拟人类的学习过程,即学会学习。

解压images_background.zipimages_evaluation.zip,其目录结构为
images_background\${哪种语言的字母表}\${哪个字母}\图片.png

strokes_background.zip文件包含的是对应字符书写的笔画顺序,strokes是笔画的意思。每个images_background.zip中的图片对应strokes_background.zip中的一个txt文本文件,每个文件中除STARTBREAK外,其他行是笔尖的坐标和时间,格式为(X, Y, t),如

START
18.298419,-36.268473,0
19.13834,-36.268473,120
...
74.573123,-37.948315,2313
BREAK
68.693676,-36.268473,3240
...
BREAK

START即开始书写,BREAK即提起笔。

分享一段可视化指定字母表字母的代码:

import glob
from PIL import Image

def plot_image(alphabet):
    image_path = f'../omniglot/*/{alphabet}/*/'
    characters = glob.glob(image_path)
    image_files = []
    for character in characters:
        img = glob.glob(f"{character}*.png")[0]
        image_files.append(Image.open(img))

    W, H = 40, 40
    ROW, COL = 4, 13
    target = Image.new("RGB", (W * COL, H *ROW))
    for row in range(ROW):
        for col in range(COL):               
            target.paste(image_files[COL*row+col], (0 + W*col, 0 + H*row))
    target.save(f"{alphabet}_patchs.png", quality=80)

if __name__ == '__main__':
    plot_image("Japanese_(hiragana)")

参考资料


欢迎访问个人网络日志🌹🌹知行空间🌹🌹