我正在尝试加载文件夹中存在的所有图像,增加每个图像并将其保存在不同的存储库中
我可以通过硬编码路径和图像名称来增加一个但是,当我尝试存储所有图像的路径然后处理循环时,它不起作用并抛出标题中提到的错误(也:int () 参数必须是字符串、类似字节的对象或数字,而不是 'dict' )。在增强图像后的后面部分,我将输出存储在不同的文件夹中。代码也如下:
如果有人可以为这个问题提供解决方案,那将非常有帮助。
import imgaug as ia
from imgaug import augmenters as iaa
import numpy as np
import pandas as pd # data processing, CSV file I/O (e.g. d.read_csv)
import os
from glob import glob
import imageio
ia.seed(20)
#os.chdir('C:/Users/Madhav/Desktop/RIC/data/images_001/images')
img = {os.path.basename(x): x for x in glob(os.path.join('C:/Users/Madhav/Desktop/FinalSem/Data_Images/','images*','*', '*.png'))}
#img = imageio.imread("00000001_000.png") #read you image
images = np.array(
[img for _ in range(32)], dtype=np.uint8) # 32 means creat 32 enhanced images using following methods.
seq = iaa.Sequential(
[
iaa.Fliplr(0.5),
iaa.Crop(percent=(0, 0.1)),
iaa.Sometimes(0.5, iaa.GaussianBlur(sigma=(0, 0.5))),
iaa.ContrastNormalization((0.75, 1.5)),
iaa.AdditiveGaussianNoise(loc=0, scale=(0.0, 0.05 * 255), per_channel=0.5),
iaa.Multiply((0.8, 1.2), per_channel=0.2),
iaa.Affine(
scale={
"x": (0.8, 1.2),
"y": (0.8, 1.2)
},
translate_percent={
"x": (-0.2, 0.2),
"y": (-0.2, 0.2)
},
rotate=(-25, 25),
shear=(-8, 8))
],
random_order=True) # apply augmenters in random order
images_aug = seq.augment_images(images)
for i in range(32):
imageio.imwrite(str(i)+'C:/Users/Madhav/Desktop/FinalSem/Augmented_Generated/Aug.png', images_aug[i])
#write all changed images
TypeError
Traceback (most recent call last)
<ipython-input-11-9a5de30a5337> in <module>
18 #img = imageio.imread("00000001_000.png") #read you image
19 images = np.array(
---> 20 [img for _ in range(32)], dtype=np.uint8) # 32 means creat 32 enhanced images using following methods.
21
22 seq = iaa.Sequential(
TypeError: int() argument must be a string, a bytes-like object or a number, not 'dict'