如何通过进行扩充以使该文件夹中的图像数量等于其他文件夹中的图像数量,来平衡文件夹中的图像? [英] How to balance images in folder by doing augmentation such that number of images in this folder are equal to number of images in other folder?

查看:55
本文介绍了如何通过进行扩充以使该文件夹中的图像数量等于其他文件夹中的图像数量,来平衡文件夹中的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有5个名为 class_i 的文件夹,每个文件夹都有 i 类图像.图像采用.jpg格式.如何进行扩充以使每个文件夹中的图像数量等于该文件夹中图像数量最多的图像数量,从而平衡每个文件夹中的图像?另外,请您帮忙绘制一条曲线,以显示平衡前后每个文件夹中的图像数量?

I have 5 folders named as class_i each folder has the i class images. the images are with .jpg format. How can I balance the images in each folder by doing augmentation such that number of images in this folder will be equal to the number of images in the folder with highest number of images? Also, could you please help in plotting a curve shows number of images in each folder before and after balancing?

推荐答案

只需扩展使用算法的我的其他答案正是您想要在这个问题上.算法位于我的答案的最后.

Just extended my other answer with algorithm that does exactly what you want in this question. Algorithm is located at the very end of my answer.

它接受两个文件夹-一个用于输入,一个用于输出.每个文件夹包含以整数标签命名的子文件夹,每个子文件夹包含该标签的图像.

It accepts two folders - one for input, one for output. Each folder contains subfolders named with integer labels, each subfolder contains images of that label.

首先运行代码时,它会进行扩增,然后绘制输入文件夹(未修改)的图像计数,并且在关闭窗口后,它会绘制第二个窗口以显示扩展(输出)图像的计数.

When code is run first it does augmentation, then plots images counts for input folder (unmodified) and after window is closed it plots second window with counts for augmented (output) images.

在输出文件夹中,每个图像都用源图像名称加上后缀表示扩展方法来命名,该方法用于生成输出PNG图像.每个图像可以有多个增强滤镜,每个滤镜产生一个PNG输出.

Inside output folders each image is named with source image name plus suffix signifying augmentation method used to produce output PNG image. There can be several augmentation filters per image, each filter produces one PNG output.

这篇关于如何通过进行扩充以使该文件夹中的图像数量等于其他文件夹中的图像数量,来平衡文件夹中的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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