-
Notifications
You must be signed in to change notification settings - Fork 0
/
figures.py
32 lines (22 loc) · 991 Bytes
/
figures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from tqdm import tqdm
from PIL import Image
import numpy as np
import os
os.makedirs("figures", exist_ok=True)
models = ["NeRF", "TinyNeRF", "MicroNeRF", "NanoNeRF"]
models += [f"Distill{model}" for model in models]
blender = "dataset/blender"
scenes = sorted([s for s in os.listdir(blender) if os.path.isdir(os.path.join(blender, s))])
for scene in tqdm(scenes):
irm = os.path.join("res", "DistillNeRF", scene, "DistillNeRF.irm.png")
irm = Image.open(irm).convert("RGB")
renders = [os.path.join("res", model, scene, f"{model}.png") for model in models]
renders = [np.array(Image.open(render)) for render in renders]
renders = [render[render.shape[0] // 3:, :, :] for render in renders]
renders = np.hstack(renders)
a = renders.shape[1] / irm.size[0]
w = renders.shape[1]
h = int(a * irm.size[1])
irm = np.array(irm.resize((w, h)))
img = np.vstack([irm, renders])
Image.fromarray(img).save(f"figures/{scene}.figure.png")