mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-07 00:09:14 +08:00
Stage 3 of Pandora
This commit is contained in:
1 parent
783613d0dc
commit
54d5bff351
3 files changed
+62
-10
No files matched your search
@@ -0,0 +1,47 @@
|
|||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
from tqdm import tqdm
|
||||||
|
from pathlib import Path
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
def load_from_json(filename: Path):
|
||||||
|
"""Load a dictionary from a JSON filename.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
filename: The filename to load from.
|
||||||
|
"""
|
||||||
|
assert filename.suffix == ".json"
|
||||||
|
with open(filename, encoding="UTF-8") as file:
|
||||||
|
return json.load(file)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('--input_json', type=str)
|
||||||
|
parser.add_argument('--output_json', type=str)
|
||||||
|
parser.add_argument('--img_addr', type=str)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
assert os.path.isfile(args.input_json), 'The input JSON file is missing!'
|
||||||
|
|
||||||
|
old_json_data = load_from_json( Path(args.input_json) )
|
||||||
|
new_json_data = {}
|
||||||
|
all_keys = old_json_data.keys() - {'frames'}
|
||||||
|
for key in all_keys:
|
||||||
|
new_json_data[key] = old_json_data[key]
|
||||||
|
frames = []
|
||||||
|
for frame in tqdm(old_json_data['frames']):
|
||||||
|
base = str(Path(frame["file_path"]).stem)
|
||||||
|
if Path(args.img_addr + '/' + base + '.exr').is_file():
|
||||||
|
new_frame = {
|
||||||
|
"file_path": frame["file_path"],
|
||||||
|
"transform_matrix": frame["transform_matrix"],
|
||||||
|
}
|
||||||
|
frames.append(new_frame)
|
||||||
|
new_json_data['frames'] = frames
|
||||||
|
|
||||||
|
with open(args.output_json, "w") as outfile:
|
||||||
|
json.dump(new_json_data, outfile)
|
||||||
|
|
||||||
|
print("All done!")
|
||||||
@@ -320,13 +320,14 @@ class LanternModel(NerfactoModel):
|
|||||||
gt_image=image,
|
gt_image=image,
|
||||||
)
|
)
|
||||||
|
|
||||||
# MSE loss for mask with weights
|
if "mask" in batch:
|
||||||
mask_in_float = batch['mask'].type(torch.float).to(self.device)
|
# MSE loss for mask with weights
|
||||||
negative_mask_in_float = torch.ones(mask_in_float.shape).to(self.device) - mask_in_float
|
mask_in_float = batch['mask'].type(torch.float).to(self.device)
|
||||||
loss_mask_fast_expo = (mask1_w * (( negative_mask_in_float - torch.unsqueeze(outputs["validity_f"], 1)) ** 2)).mean()
|
negative_mask_in_float = torch.ones(mask_in_float.shape).to(self.device) - mask_in_float
|
||||||
loss_mask_well_expo = (mask2_w * (( mask_in_float - torch.unsqueeze(outputs["validity_w"], 1)) ** 2)).mean()
|
loss_mask_fast_expo = (mask1_w * (( negative_mask_in_float - torch.unsqueeze(outputs["validity_f"], 1)) ** 2)).mean()
|
||||||
loss_dict["validity_loss_well_exposed"] = loss_mask_well_expo
|
loss_mask_well_expo = (mask2_w * (( mask_in_float - torch.unsqueeze(outputs["validity_w"], 1)) ** 2)).mean()
|
||||||
loss_dict["validity_loss_fast_exposure"] = loss_mask_fast_expo
|
loss_dict["validity_loss_well_exposed"] = loss_mask_well_expo
|
||||||
|
loss_dict["validity_loss_fast_exposure"] = loss_mask_fast_expo
|
||||||
|
|
||||||
if weights_for_RGB_loss is not None:
|
if weights_for_RGB_loss is not None:
|
||||||
loss_dict["rgb_loss"] = (weights_for_RGB_loss * ((gt_rgb - pred_rgb) ** 2)).mean()
|
loss_dict["rgb_loss"] = (weights_for_RGB_loss * ((gt_rgb - pred_rgb) ** 2)).mean()
|
||||||
|
|||||||
@@ -549,16 +549,20 @@ class RenderInterpolated(BaseRender):
|
|||||||
|
|
||||||
install_checks.check_ffmpeg_installed()
|
install_checks.check_ffmpeg_installed()
|
||||||
|
|
||||||
|
output_names = []
|
||||||
if self.pose_source == "eval":
|
if self.pose_source == "eval":
|
||||||
assert pipeline.datamanager.eval_dataset is not None
|
assert pipeline.datamanager.eval_dataset is not None
|
||||||
cameras = pipeline.datamanager.eval_dataset.cameras
|
cameras = pipeline.datamanager.eval_dataset.cameras
|
||||||
|
for file_name in pipeline.datamanager.eval_dataset.image_filenames:
|
||||||
|
output_names.append(file_name.stem)
|
||||||
else:
|
else:
|
||||||
assert pipeline.datamanager.train_dataset is not None
|
assert pipeline.datamanager.train_dataset is not None
|
||||||
cameras = pipeline.datamanager.train_dataset.cameras
|
cameras = pipeline.datamanager.train_dataset.cameras
|
||||||
|
for file_name in pipeline.datamanager.train_dataset.image_filenames:
|
||||||
|
output_names.append(file_name.stem)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
output_names = []
|
|
||||||
for file_name in pipeline.datamanager.train_dataset.image_filenames:
|
|
||||||
output_names.append(file_name.stem)
|
|
||||||
seconds = self.interpolation_steps * len(cameras) / self.frame_rate
|
seconds = self.interpolation_steps * len(cameras) / self.frame_rate
|
||||||
camera_path = get_interpolated_camera_path(
|
camera_path = get_interpolated_camera_path(
|
||||||
cameras=cameras,
|
cameras=cameras,
|
||||||
|
|||||||
Reference in new issue
Block a user