diff --git a/metrics.py b/metrics.py index f7393a4..6d3de14 100644 --- a/metrics.py +++ b/metrics.py @@ -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): diff --git a/scene/dataset_readers.py b/scene/dataset_readers.py index 2a6f904..6718123 100644 --- a/scene/dataset_readers.py +++ b/scene/dataset_readers.py @@ -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 -} \ No newline at end of file +}