简体   繁体   English

自动制作用于cnn训练的合成图像

[英]Automatically make a composite image for cnn training

i would like to train a CNN for detection and classification of any kind of signs (mainly laboratory and safety markers) using tensorflow. 我想训练一个CNN,以使用Tensorflow进行任何类型的标志(主要是实验室标志和安全标记)的检测和分类。 While I can gather enough training data for the classification training set, using eg The Bing API, I'm struggeling to think about a solution to get enough images for the object detection training set. 尽管我可以使用例如Bing API收集分类训练集的足够训练数据,但我仍在努力寻找一种解决方案,以为目标检测训练集获取足够的图像。 Since these markers are mostly not public available, I thought I could make a composite of a natrual scene image with the image of the marker itself, to get a training set. 由于这些标记大多数是不公开的,因此我认为我可以将自然场景图像与标记本身的图像进行合成,以获得训练集。 Is there any way to do that automatically? 有什么办法可以自动做到这一点? I looked at tensorflow data augmentation class, but it seems it only provides functionality for simpler data augmentation tasks. 我看过tensorflow数据增强类,但似乎它仅提供用于更简单的数据增强任务的功能。

You can do it with OpenCV as preprocessing. 您可以使用OpenCV作为预处理。

The algorithm follows: 该算法如下:

  1. Choose a combination of a natural scene image and a sign image randomly. 随机选择自然场景图像和标志图像的组合。
  2. Sample random position in the natural scene image where the sign image is pasted. 在自然场景图像中将标志图像粘贴到的随机位置进行采样。
  3. Paste the sign image at the position. 将标志图像粘贴到该位置。
  4. Obtain the pasted image and the position as a part of training data. 获取粘贴的图像和位置作为训练数据的一部分。

Step1 and 2 is done with python standard random module or numpy . 步骤1和2是使用python标准random模块或numpy

Step3 is done with opencv-python. 第3步使用opencv-python完成。 See overlay a smaller image on a larger image python OpenCv . 请参见在较大的图像python OpenCv上覆盖较小的图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM