xizaoqu commited on
Commit ·
63a4fd0
1
Parent(s): ec0ae7c
update
Browse files- datasets/video/base_video_dataset.py +3 -1
- evaluate.sh +1 -0
- main.py +5 -0
- utils/logging_utils.py +12 -9
datasets/video/base_video_dataset.py
CHANGED
|
@@ -51,7 +51,9 @@ class BaseVideoDataset(torch.utils.data.Dataset, ABC):
|
|
| 51 |
self.transform = transforms.Resize((self.resolution, self.resolution), antialias=True)
|
| 52 |
|
| 53 |
# shuffle but keep the same order for each epoch, so validation sample is diverse yet deterministic
|
| 54 |
-
|
|
|
|
|
|
|
| 55 |
self.idx_remap = list(range(self.__len__()))
|
| 56 |
random.shuffle(self.idx_remap)
|
| 57 |
|
|
|
|
| 51 |
self.transform = transforms.Resize((self.resolution, self.resolution), antialias=True)
|
| 52 |
|
| 53 |
# shuffle but keep the same order for each epoch, so validation sample is diverse yet deterministic
|
| 54 |
+
# Use seed from config if provided, otherwise default to 0
|
| 55 |
+
shuffle_seed = cfg.get("seed", 0)
|
| 56 |
+
random.seed(shuffle_seed)
|
| 57 |
self.idx_remap = list(range(self.__len__()))
|
| 58 |
random.shuffle(self.idx_remap)
|
| 59 |
|
evaluate.sh
CHANGED
|
@@ -3,6 +3,7 @@ wandb offline
|
|
| 3 |
python -m main +name=infer \
|
| 4 |
experiment.tasks=[test] \
|
| 5 |
dataset.validation_multiplier=1 \
|
|
|
|
| 6 |
+diffusion_model_path=zeqixiao/worldmem_checkpoints/diffusion_only.ckpt \
|
| 7 |
+vae_path=zeqixiao/worldmem_checkpoints/vae_only.ckpt \
|
| 8 |
+customized_load=true \
|
|
|
|
| 3 |
python -m main +name=infer \
|
| 4 |
experiment.tasks=[test] \
|
| 5 |
dataset.validation_multiplier=1 \
|
| 6 |
+
+dataset.seed=42 \
|
| 7 |
+diffusion_model_path=zeqixiao/worldmem_checkpoints/diffusion_only.ckpt \
|
| 8 |
+vae_path=zeqixiao/worldmem_checkpoints/vae_only.ckpt \
|
| 9 |
+customized_load=true \
|
main.py
CHANGED
|
@@ -33,6 +33,11 @@ def run_local(cfg: DictConfig):
|
|
| 33 |
# delay some imports in case they are not needed in non-local envs for submission
|
| 34 |
from experiments import build_experiment
|
| 35 |
from utils.wandb_utils import OfflineWandbLogger, SpaceEfficientWandbLogger
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# Get yaml names
|
| 38 |
hydra_cfg = hydra.core.hydra_config.HydraConfig.get()
|
|
|
|
| 33 |
# delay some imports in case they are not needed in non-local envs for submission
|
| 34 |
from experiments import build_experiment
|
| 35 |
from utils.wandb_utils import OfflineWandbLogger, SpaceEfficientWandbLogger
|
| 36 |
+
import lightning.pytorch as pl
|
| 37 |
+
|
| 38 |
+
# Set global seed for reproducibility
|
| 39 |
+
if cfg.get("seed", None) is not None:
|
| 40 |
+
pl.seed_everything(cfg.seed, workers=True)
|
| 41 |
|
| 42 |
# Get yaml names
|
| 43 |
hydra_cfg = hydra.core.hydra_config.HydraConfig.get()
|
utils/logging_utils.py
CHANGED
|
@@ -218,19 +218,22 @@ def get_validation_metrics_for_videos(
|
|
| 218 |
observation_hat_clipped = torch.clamp(observation_hat, 0.0, 1.0)
|
| 219 |
observation_gt_clipped = torch.clamp(observation_gt, 0.0, 1.0)
|
| 220 |
|
| 221 |
-
# Compute
|
| 222 |
-
|
| 223 |
-
for
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
observation_hat_clipped = observation_hat_clipped.view(-1, channel, height, width)
|
| 229 |
observation_gt_clipped = observation_gt_clipped.view(-1, channel, height, width)
|
| 230 |
|
| 231 |
-
# Compute MSE
|
| 232 |
output_dict["mse"] = mean_squared_error(observation_hat_clipped, observation_gt_clipped)
|
| 233 |
-
output_dict["psnr"] = peak_signal_noise_ratio(observation_hat_clipped, observation_gt_clipped, data_range=1.0)
|
| 234 |
# output_dict["ssim"] = structural_similarity_index_measure(observation_hat_clipped, observation_gt_clipped, data_range=1.0)
|
| 235 |
# output_dict["uiqi"] = universal_image_quality_index(observation_hat_clipped, observation_gt_clipped)
|
| 236 |
|
|
|
|
| 218 |
observation_hat_clipped = torch.clamp(observation_hat, 0.0, 1.0)
|
| 219 |
observation_gt_clipped = torch.clamp(observation_gt, 0.0, 1.0)
|
| 220 |
|
| 221 |
+
# Compute video-wise PSNR: frame-wise average per video, then average across videos
|
| 222 |
+
video_psnr_list = []
|
| 223 |
+
for b in range(batch):
|
| 224 |
+
frame_psnr_for_video = []
|
| 225 |
+
for f in range(frame):
|
| 226 |
+
frame_psnr = peak_signal_noise_ratio(observation_hat_clipped[f, b], observation_gt_clipped[f, b], data_range=1.0)
|
| 227 |
+
frame_psnr_for_video.append(frame_psnr)
|
| 228 |
+
video_psnr = torch.stack(frame_psnr_for_video).mean()
|
| 229 |
+
video_psnr_list.append(video_psnr)
|
| 230 |
+
output_dict["psnr"] = torch.stack(video_psnr_list).mean()
|
| 231 |
+
|
| 232 |
observation_hat_clipped = observation_hat_clipped.view(-1, channel, height, width)
|
| 233 |
observation_gt_clipped = observation_gt_clipped.view(-1, channel, height, width)
|
| 234 |
|
| 235 |
+
# Compute MSE on clipped data
|
| 236 |
output_dict["mse"] = mean_squared_error(observation_hat_clipped, observation_gt_clipped)
|
|
|
|
| 237 |
# output_dict["ssim"] = structural_similarity_index_measure(observation_hat_clipped, observation_gt_clipped, data_range=1.0)
|
| 238 |
# output_dict["uiqi"] = universal_image_quality_index(observation_hat_clipped, observation_gt_clipped)
|
| 239 |
|