Git Product home page Git Product logo

syntext's Introduction

项目概述

这个项目用于生成训练过程中的样本。

参考

此项目参考了以下的开源项目:

设计思路

样本生成主要需要做一下工作:

  • 加载资源,如(字体、背景图)
  • 支持多进程,提高效率
  • 各种策略来生成文字
  • 各种策略来增强生成的图片

所以,实现的大抵思路也是如此:

1、先加载字体、背景、字符集、字库

2、生成一个串文本

3、画文本到背景上,并确定bbox

4、使用开源项目imgaug做增强

5、保存图片、标签、和bbox

两种生成方式

目前,项目实现了两种样本的生成:

1、仅生成图片和对应的文字标签

2、生成图片和对应的文字标签,还要包含每个字的bbox信息

生成识别样本(仅有字符标注)

这种标注,对每个文件,仅提供其对应的字符串,不靠谱中文中的全角半角,需要程序自己进行转换。

标注文件只有一个,如train.txt。文件分为2列:文件路径、对应文字。

样例:

data/train/abc.jpg 你好,世界
data/train/bcd.jpg 毁灭吧,世界!累了~
......

生成带位置信息的识别样本

这种样本,是标注了每个字符的轮廓的,每个字的轮廓采用4点标注。 第一行是样本对应的字符串,第2行至最后一行,是每个汉字的4点标注,和对应的汉字。

样例:

所有样例存放在一个文件夹里,每张图片有唯一的名字,而标注的文件名字一样,只是后缀为.txt。

图像文件名:abc.jpg

标注文件名:abc.txt

标注文件样例:

你好,世界                      <---- 第1行,标注结果
11,12,21,22,31,32,41,42 你     <---- 第2行-最后一行,标注每个文字的框
11,12,21,22,31,32,41,42 好
11,12,21,22,31,32,41,42 ,
11,12,21,22,31,32,41,42 世
11,12,21,22,31,32,41,42 界

使用

运行bin/run.sh可以生成图像,格式如下:

bin/run.sh --dir output_dir --num number <--debug>

例子:run.sh data/output/ 1000 --debug
  • dir:样本生成目录
  • num:生成多个张
  • debug:是否显示更多的运行信息

其他的运行细节,需要配置config.yml

COMMON:
    WORKER : 3                  # 多少个进程同时生成图片
    TEXT_GENERATOR : random     # 随机生成:random, 语料生成:corpus
    SAVER : contour             # 保存轮廓的:contour, 只保存标签: text

核心配置如上。

运行前,需要先下载背景(各类白纸)和字体资源

百度云盘下载 提取码: [f42h]

并放置到 data/目录下。

syntext's People

Contributors

piginzoo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.