mirror of
https://github.com/graphdeco-inria/gaussian-splatting
synced 2024-11-22 00:08:02 +00:00
Nice fixed output
This commit is contained in:
parent
43e42bd20f
commit
45a9877ac4
@ -1 +1 @@
|
|||||||
Subproject commit f9b5d03bc86c8fabd8d7a26fabff91129618b4ce
|
Subproject commit 71ced0023fd0c0aaaa83bb1ab32bce1d4ed630c7
|
75
metrics.py
75
metrics.py
@ -30,51 +30,54 @@ def evaluate(model_paths):
|
|||||||
per_view_dict_polytopeonly = {}
|
per_view_dict_polytopeonly = {}
|
||||||
|
|
||||||
for scene_dir in model_paths:
|
for scene_dir in model_paths:
|
||||||
print("Scene:", scene_dir)
|
try:
|
||||||
full_dict[scene_dir] = {}
|
print("\nScene:", scene_dir)
|
||||||
per_view_dict[scene_dir] = {}
|
full_dict[scene_dir] = {}
|
||||||
full_dict_polytopeonly[scene_dir] = {}
|
per_view_dict[scene_dir] = {}
|
||||||
per_view_dict_polytopeonly[scene_dir] = {}
|
full_dict_polytopeonly[scene_dir] = {}
|
||||||
|
per_view_dict_polytopeonly[scene_dir] = {}
|
||||||
|
|
||||||
test_dir = Path(scene_dir) / "test"
|
test_dir = Path(scene_dir) / "test"
|
||||||
|
|
||||||
for method in os.listdir(test_dir):
|
for method in os.listdir(test_dir):
|
||||||
print("Method:", method)
|
print("Method:", method)
|
||||||
|
|
||||||
full_dict[scene_dir][method] = {}
|
full_dict[scene_dir][method] = {}
|
||||||
per_view_dict[scene_dir][method] = {}
|
per_view_dict[scene_dir][method] = {}
|
||||||
full_dict_polytopeonly[scene_dir][method] = {}
|
full_dict_polytopeonly[scene_dir][method] = {}
|
||||||
per_view_dict_polytopeonly[scene_dir][method] = {}
|
per_view_dict_polytopeonly[scene_dir][method] = {}
|
||||||
|
|
||||||
method_dir = test_dir / method
|
method_dir = test_dir / method
|
||||||
gt_dir = method_dir/ "gt"
|
gt_dir = method_dir/ "gt"
|
||||||
renders_dir = method_dir / "renders"
|
renders_dir = method_dir / "renders"
|
||||||
renders, gts, image_names = readImages(renders_dir, gt_dir)
|
renders, gts, image_names = readImages(renders_dir, gt_dir)
|
||||||
|
|
||||||
ssims = []
|
ssims = []
|
||||||
psnrs = []
|
psnrs = []
|
||||||
lpipss = []
|
lpipss = []
|
||||||
|
|
||||||
for idx in tqdm(range(len(renders)), desc="Metric evaluation progress"):
|
for idx in tqdm(range(len(renders)), desc="Metric evaluation progress"):
|
||||||
ssims.append(ssim(renders[idx], gts[idx]))
|
ssims.append(ssim(renders[idx], gts[idx]))
|
||||||
psnrs.append(psnr(renders[idx], gts[idx]))
|
psnrs.append(psnr(renders[idx], gts[idx]))
|
||||||
lpipss.append(lpips(renders[idx], gts[idx], net_type='vgg'))
|
lpipss.append(lpips(renders[idx], gts[idx], net_type='vgg'))
|
||||||
|
|
||||||
print("SSIM: {}".format(torch.tensor(ssims).mean()))
|
print(" SSIM : {:>12.7f}".format(torch.tensor(ssims).mean(), ".5"))
|
||||||
print("PSNR: {}".format(torch.tensor(psnrs).mean()))
|
print(" PSNR : {:>12.7f}".format(torch.tensor(psnrs).mean(), ".5"))
|
||||||
print("LPIPS: {}".format(torch.tensor(lpipss).mean()))
|
print(" LPIPS: {:>12.7f}".format(torch.tensor(lpipss).mean(), ".5"), "\n")
|
||||||
|
|
||||||
full_dict[scene_dir][method].update({"SSIM": torch.tensor(ssims).mean().item(),
|
full_dict[scene_dir][method].update({"SSIM": torch.tensor(ssims).mean().item(),
|
||||||
"PSNR": torch.tensor(psnrs).mean().item(),
|
"PSNR": torch.tensor(psnrs).mean().item(),
|
||||||
"LPIPS": torch.tensor(lpipss).mean().item()})
|
"LPIPS": torch.tensor(lpipss).mean().item()})
|
||||||
per_view_dict[scene_dir][method].update({"SSIM": {name: ssim for ssim, name in zip(torch.tensor(ssims).tolist(), image_names)},
|
per_view_dict[scene_dir][method].update({"SSIM": {name: ssim for ssim, name in zip(torch.tensor(ssims).tolist(), image_names)},
|
||||||
"PSNR": {name: psnr for psnr, name in zip(torch.tensor(psnrs).tolist(), image_names)},
|
"PSNR": {name: psnr for psnr, name in zip(torch.tensor(psnrs).tolist(), image_names)},
|
||||||
"LPIPS": {name: lp for lp, name in zip(torch.tensor(lpipss).tolist(), image_names)}})
|
"LPIPS": {name: lp for lp, name in zip(torch.tensor(lpipss).tolist(), image_names)}})
|
||||||
|
|
||||||
with open(scene_dir + "/results.json", 'w') as fp:
|
with open(scene_dir + "/results.json", 'w') as fp:
|
||||||
json.dump(full_dict[scene_dir], fp, indent=True)
|
json.dump(full_dict[scene_dir], fp, indent=True)
|
||||||
with open(scene_dir + "/per_view.json", 'w') as fp:
|
with open(scene_dir + "/per_view.json", 'w') as fp:
|
||||||
json.dump(per_view_dict[scene_dir], fp, indent=True)
|
json.dump(per_view_dict[scene_dir], fp, indent=True)
|
||||||
|
except:
|
||||||
|
print("Unable to compute metrics for model", scene_dir)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
device = torch.device("cuda:0")
|
device = torch.device("cuda:0")
|
||||||
|
Loading…
Reference in New Issue
Block a user