Skip to content

Commit 0955231

Browse files
committed
Prevent image files to be open
1 parent 414b553 commit 0955231

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

metrics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def readImages(renders_dir, gt_dir):
3131
renders.append(tf.to_tensor(render).unsqueeze(0)[:, :3, :, :].cuda())
3232
gts.append(tf.to_tensor(gt).unsqueeze(0)[:, :3, :, :].cuda())
3333
image_names.append(fname)
34+
gt.close()
35+
render.close()
3436
return renders, gts, image_names
3537

3638
def evaluate(model_paths):

scene/dataset_readers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ def readColmapCameras(cam_extrinsics, cam_intrinsics, images_folder):
9696

9797
image_path = os.path.join(images_folder, os.path.basename(extr.name))
9898
image_name = os.path.basename(image_path).split(".")[0]
99-
image = Image.open(image_path)
99+
image_fs = Image.open(image_path)
100+
image = image_fs.copy()
101+
image_fs.close()
100102

101103
cam_info = CameraInfo(uid=uid, R=R, T=T, FovY=FovY, FovX=FovX, image=image,
102104
image_path=image_path, image_name=image_name, width=width, height=height)
@@ -199,6 +201,9 @@ def readCamerasFromTransforms(path, transformsfile, white_background, extension=
199201

200202
image_path = os.path.join(path, cam_name)
201203
image_name = Path(cam_name).stem
204+
image_fs = Image.open(image_path)
205+
image = image_fs.copy()
206+
image_fs.close()
202207
image = Image.open(image_path)
203208

204209
im_data = np.array(image.convert("RGBA"))
@@ -257,4 +262,4 @@ def readNerfSyntheticInfo(path, white_background, eval, extension=".png"):
257262
sceneLoadTypeCallbacks = {
258263
"Colmap": readColmapSceneInfo,
259264
"Blender" : readNerfSyntheticInfo
260-
}
265+
}

0 commit comments

Comments
 (0)