使用带有对象检测的数据增强生成的图像数量 [英] Number of images generated using data augmentation with object detection

查看:62
本文介绍了使用带有对象检测的数据增强生成的图像数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在文档、代码和这里搜索答案,但我没有运气.我想知道使用 Tensorflow 中的对象检测 API 进行数据增强生成的图像的最终数量是多少.为了清楚起见,我举了一个例子:假设我有一个包含 2 个类的数据集,每个类最初都有 50 张图像.然后我应用这个配置:

I've tried to search the answer in the documentation, the code and here but I had no luck. I'd like to know what is the final number of images that are generated by the data augmentation using the object detection API in Tensorflow. For the sake of clarity I'd put an example: let's say that I have a dataset with 2 classes, each one of then with 50 images originally. Then I apply this config:

  data_augmentation_options {
    ssd_random_crop {
    }
  }

  data_augmentation_options {
    random_rgb_to_gray {
    }
  }

  data_augmentation_options {
    random_distort_color {
    }
  }

  data_augmentation_options {
    ssd_random_crop_pad_fixed_aspect_ratio {
    }
  }

我如何知道为训练我的模型而生成的最终图像数量?(如果有办法).顺便说一句,我正在使用 model_main.py 来训练我的模型.

How can I know the final number of images generated to train my model? (if there is a way). BTW, I'm using model_main.py to train my model.

提前致谢.

推荐答案

在文件 inputs.py,在augment_input_fn函数中可以看出,所有的数据增强选项都传递给了preprocessor.preprocess方法.详细信息都在文件 preprocessor.py,特别是函数preprocess:

In file inputs.py, it can be seen in function augment_input_fn that all data augmentation options are passed to preprocessor.preprocess method. The details are all in file preprocessor.py, specifically in function preprocess:

for option in preprocess_options:
  func, params = option
  if func not in func_arg_map:
    raise ValueError('The function %s does not exist in func_arg_map' %
                   (func.__name__))
  arg_names = func_arg_map[func]
  for a in arg_names:
    if a is not None and a not in tensor_dict:
      raise ValueError('The function %s requires argument %s' %
                     (func.__name__, a))

  def get_arg(key):
    return tensor_dict[key] if key is not None else None

  args = [get_arg(a) for a in arg_names]
  if (preprocess_vars_cache is not None and
      'preprocess_vars_cache' in inspect.getargspec(func).args):
    params['preprocess_vars_cache'] = preprocess_vars_cache
  results = func(*args, **params)
  if not isinstance(results, (list, tuple)):
    results = (results,)
  # Removes None args since the return values will not contain those.
  arg_names = [arg_name for arg_name in arg_names if arg_name is not None]
  for res, arg_name in zip(results, arg_names):
    tensor_dict[arg_name] = res

请注意,在上面的代码中,arg_names 包含所有原始图像名称,这意味着每个增强选项只会在原始图像上执行(而不是在先前增强选项后获得的图像上执行).

Note that in the above code, arg_names contain all the original image names, that means each augmentation option will only be performed on the original images (not on those obtained after previous augmentation options).

也在 preprocessor.py,我们可以看到每个增强选项只会产生与原始图像形状相同的图像.

Also in preprocessor.py, we can see each augmentation option will produce only an image of the same shape as the original image.

因此,在您的情况下,四个选项和 100 张原始图像、400 张增强图像将添加到 tensor_dict.

So as a result, in your case, four options and 100 original images, 400 augmented images will be added to tensor_dict.

这篇关于使用带有对象检测的数据增强生成的图像数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆