Prevent image files to be open

This commit is contained in:
Jonas Kulhanek 2023-10-11 09:48:25 +02:00
parent 414b553ef1
commit 0955231a06
2 changed files with 9 additions and 2 deletions

View File

@ -31,6 +31,8 @@ def readImages(renders_dir, gt_dir):
renders.append(tf.to_tensor(render).unsqueeze(0)[:, :3, :, :].cuda())
gts.append(tf.to_tensor(gt).unsqueeze(0)[:, :3, :, :].cuda())
image_names.append(fname)
gt.close()
render.close()
return renders, gts, image_names
def evaluate(model_paths):

View File

@ -96,7 +96,9 @@ def readColmapCameras(cam_extrinsics, cam_intrinsics, images_folder):
image_path = os.path.join(images_folder, os.path.basename(extr.name))
image_name = os.path.basename(image_path).split(".")[0]
image = Image.open(image_path)
image_fs = Image.open(image_path)
image = image_fs.copy()
image_fs.close()
cam_info = CameraInfo(uid=uid, R=R, T=T, FovY=FovY, FovX=FovX, image=image,
image_path=image_path, image_name=image_name, width=width, height=height)
@ -199,6 +201,9 @@ def readCamerasFromTransforms(path, transformsfile, white_background, extension=
image_path = os.path.join(path, cam_name)
image_name = Path(cam_name).stem
image_fs = Image.open(image_path)
image = image_fs.copy()
image_fs.close()
image = Image.open(image_path)
im_data = np.array(image.convert("RGBA"))
@ -257,4 +262,4 @@ def readNerfSyntheticInfo(path, white_background, eval, extension=".png"):
sceneLoadTypeCallbacks = {
"Colmap": readColmapSceneInfo,
"Blender" : readNerfSyntheticInfo
}
}