画像を読み込む関数(load_images())を作成して画像を読み込むと,
結果がarray([], dtype=float32)になってしまいます.
load_imagesの中に問題がありますでしょうか?
def load_images(inputpath,imagesize,type_color): imglist=[] exclude_prefixes=('__','.') for root,dirs,files in os.walk(inputpath): dirs[:]=[dir for dir in dirs if not dir.startswich(exclude_prefixes)] files[:]=[file for file in files if not file.startswith(exclude_prefixes)] for fn in sorted(files): bn,ext=os.path.splitext(fn) if ext not in[".bmp",".BMP",".jpg",".JPG",".jpeg","JPEG",".png",".PNG"]: continue filename=os.path.join(root,fn) if type_color=='Color': testimage=cv2.imread(filename,cv2.IMREAD_COLOR) height,width=testimage.shape[:2] testimage=cv2.resize(testimage,(imagesize,imagesize),interpolation=cv2.INTER_AREA) testimage=np.array(testimage,dtype=np.float64) testimage=testimage[:,:,::-1] elif type_color=='Gray': testimage=cv2.imread(filename,cv2.IMREAD_GRAYSCALE) height,width=testimage.shape[:2] testimage=resize(testimage,(imagesize,imagesize),interpolation=cv2.INTER_AREA) testimage=np.array([testimage],dtype=np.float64) testimage=np.asarray(testimage,dtype=np.float64).reshape((imagesize,imagesize,1)) imgslist.append(testimage) imgsdata=np.asarray(imglist,dtype=np.float32) return imgsdata,sorted(files)
image_train,image_train_filenames=
load_images("drive/My Drive/denoise/image/train",256,'Gray')
image_test,image_test_filenames=load_images("drive/My Drive/denoise/image/test",256,'Gray')
image_train ⇒array([], dtype=float32)
load_images("drive/My Drive/denoise/image/train",256,'Gray')
⇒(array([], dtype=float32),
['train1.jpg', 'train2.jpg', 'train3.jpg', 'train4.jpg'])
回答1件
あなたの回答
tips
プレビュー