Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- dataset/phase1_noise_20260906/code/.gitignore +22 -0
- dataset/phase1_noise_20260906/code/ddp_nccl_sanity.py +67 -0
- dataset/phase1_noise_20260906/code/make_clean_pools.py +32 -0
- dataset/phase1_noise_20260906/code/probe_global_knob.py +186 -0
- dataset/phase1_noise_20260906/code/probe_tone_oracle.py +109 -0
- dataset/phase1_noise_20260906/code/probe_v7_taps.py +176 -0
- dataset/phase1_noise_20260906/code/relocate_manifest.py +64 -0
- dataset/phase1_noise_20260906/code/run_phase1_v5f.sh +56 -0
- dataset/phase1_noise_20260906/code/run_uformer_v9a.sh +94 -0
- dataset/phase1_noise_20260906/code/run_uformer_v9a15k.sh +114 -0
- dataset/phase1_noise_20260906/code/sweep_v7_dose.py +99 -0
- dataset/phase1_noise_20260906/code/visualize_phase1_tsne.py +251 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/.gitattributes +17 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/.gitignore +47 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/ChangeLog.txt +2 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_bicycle_8_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_bicycle_8_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_desk_4_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_desk_5_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_desk_5_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_desk_7_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_reciever_2_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_reciever_2_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_reciever_4_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_reciever_4_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_200_3200_toy_1_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_200_3200_toy_1_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_200_3200_toy_3_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon600D_3-5_125_1600_waterhouse_10_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon600D_3-5_125_1600_waterhouse_11_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon600D_3-5_125_1600_waterhouse_12_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon600D_4-5_125_1600_toy_13_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon600D_4-5_125_1600_toy_16_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon600D_4-5_125_1600_toy_3_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon80D_8_8_12800_printer_11_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon80D_8_8_3200_ball_2_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon80D_8_8_3200_ball_6_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon80D_8_8_800_GO_11_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_11_160_3200_classroom_15_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_11_160_3200_classroom_4_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_4-5_160_1800_classroom_15_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_4-5_160_1800_classroom_5_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_4-5_160_1800_classroom_9_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_5-6_160_6400_wall_2_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_5-6_160_6400_wall_2_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_5-6_160_6400_wall_9_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_5_100_4000_flower_15_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_5_100_4000_flower_2_mean.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_5_125_6400_stair_7_real.JPG +0 -0
- dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_6-3_125_5000_plant_1_real.JPG +0 -0
dataset/phase1_noise_20260906/code/.gitignore
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Python
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.pyc
|
| 4 |
+
*.pyo
|
| 5 |
+
.pytest_cache/
|
| 6 |
+
.ruff_cache/
|
| 7 |
+
|
| 8 |
+
# Large model checkpoints / caches
|
| 9 |
+
*.pt
|
| 10 |
+
*.pth
|
| 11 |
+
*.ckpt
|
| 12 |
+
|
| 13 |
+
# OS
|
| 14 |
+
.DS_Store
|
| 15 |
+
|
| 16 |
+
# tool state and run artifacts
|
| 17 |
+
.omc/
|
| 18 |
+
.omo/
|
| 19 |
+
outputs/
|
| 20 |
+
*.log
|
| 21 |
+
__pycache__/
|
| 22 |
+
*.pt
|
dataset/phase1_noise_20260906/code/ddp_nccl_sanity.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""30-second NCCL/DDP platform sanity check for the dual-3090 box.
|
| 3 |
+
|
| 4 |
+
Reproduces the exact collective interleave of the v4 training loop —
|
| 5 |
+
explicit scalar all_reduce, DDP bucket all-reduce from backward, grad-norm
|
| 6 |
+
clip, second scalar all_reduce — on a toy model. If THIS hangs, the platform
|
| 7 |
+
NCCL transport is at fault; if it passes, the bug is in the training runtime.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
from __future__ import annotations
|
| 11 |
+
|
| 12 |
+
import os
|
| 13 |
+
import time
|
| 14 |
+
|
| 15 |
+
import torch
|
| 16 |
+
import torch.distributed as dist
|
| 17 |
+
from torch.nn.parallel import DistributedDataParallel
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def log(rank: int, message: str) -> None:
|
| 21 |
+
print("[rank %d] %s" % (rank, message), flush=True)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def main() -> None:
|
| 25 |
+
dist.init_process_group(backend="nccl", init_method="env://")
|
| 26 |
+
rank = dist.get_rank()
|
| 27 |
+
local_rank = int(os.environ.get("LOCAL_RANK", "0"))
|
| 28 |
+
torch.cuda.set_device(local_rank)
|
| 29 |
+
device = torch.device("cuda", local_rank)
|
| 30 |
+
|
| 31 |
+
model = torch.nn.Sequential(
|
| 32 |
+
torch.nn.Conv2d(3, 32, 3, padding=1),
|
| 33 |
+
torch.nn.GELU(),
|
| 34 |
+
torch.nn.Conv2d(32, 3, 3, padding=1),
|
| 35 |
+
).to(device)
|
| 36 |
+
model = DistributedDataParallel(
|
| 37 |
+
model, device_ids=[local_rank], output_device=local_rank,
|
| 38 |
+
broadcast_buffers=False, find_unused_parameters=False,
|
| 39 |
+
)
|
| 40 |
+
scaler = torch.cuda.amp.GradScaler(enabled=True)
|
| 41 |
+
optimizer = torch.optim.AdamW(model.parameters(), lr=1e-4)
|
| 42 |
+
|
| 43 |
+
start = time.time()
|
| 44 |
+
for iteration in range(50):
|
| 45 |
+
data = torch.randn(8, 3, 64, 64, device=device)
|
| 46 |
+
with torch.cuda.amp.autocast(enabled=True):
|
| 47 |
+
loss = (model(data) - data).square().mean()
|
| 48 |
+
finite = torch.isfinite(loss.detach()).all().to(dtype=torch.int32)
|
| 49 |
+
dist.all_reduce(finite, op=dist.ReduceOp.MIN)
|
| 50 |
+
assert bool(finite.item())
|
| 51 |
+
scaler.scale(loss).backward()
|
| 52 |
+
scaler.unscale_(optimizer)
|
| 53 |
+
grad_norm = torch.nn.utils.clip_grad_norm_(model.parameters(), 1.0)
|
| 54 |
+
finite = torch.isfinite(grad_norm.detach()).all().to(dtype=torch.int32)
|
| 55 |
+
dist.all_reduce(finite, op=dist.ReduceOp.MIN)
|
| 56 |
+
assert bool(finite.item())
|
| 57 |
+
scaler.step(optimizer)
|
| 58 |
+
scaler.update()
|
| 59 |
+
optimizer.zero_grad(set_to_none=True)
|
| 60 |
+
if iteration % 10 == 0:
|
| 61 |
+
log(rank, "iteration %d ok (%.1fs)" % (iteration, time.time() - start))
|
| 62 |
+
log(rank, "SANITY PASS in %.1fs" % (time.time() - start))
|
| 63 |
+
dist.destroy_process_group()
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
if __name__ == "__main__":
|
| 67 |
+
main()
|
dataset/phase1_noise_20260906/code/make_clean_pools.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Build the identity-pair clean pools as symlink folders from the TRAIN
|
| 3 |
+
split only (SIDD GT of the 121 train pairs, LOL GT of the 689 train pairs),
|
| 4 |
+
so no validation / locked-test clean image ever enters training."""
|
| 5 |
+
|
| 6 |
+
import os
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
import train_graph_encoder_v2 as p1
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def main() -> None:
|
| 13 |
+
args = p1.build_parser().parse_args([])
|
| 14 |
+
splits = p1.build_data_splits(args)
|
| 15 |
+
pools = {
|
| 16 |
+
"sidd_train_gt": sorted({str(r.clean) for r in splits.train if r.degradation == "noise"}),
|
| 17 |
+
"lol_train_gt": sorted({str(r.clean) for r in splits.train if r.degradation == "lowlight"}),
|
| 18 |
+
}
|
| 19 |
+
held = {str(r.clean) for r in list(splits.val) + list(splits.locked_test)}
|
| 20 |
+
for name, files in pools.items():
|
| 21 |
+
assert not (set(files) & held), name
|
| 22 |
+
root = Path("outputs/clean_pools") / name
|
| 23 |
+
root.mkdir(parents=True, exist_ok=True)
|
| 24 |
+
for index, source in enumerate(files):
|
| 25 |
+
target = root / ("%05d_%s" % (index, Path(source).name))
|
| 26 |
+
if not target.exists():
|
| 27 |
+
os.symlink(source, target)
|
| 28 |
+
print(name, len(files), "files")
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
if __name__ == "__main__":
|
| 32 |
+
main()
|
dataset/phase1_noise_20260906/code/probe_global_knob.py
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Is the per-image global photometric correction PREDICTABLE from the input?
|
| 3 |
+
|
| 4 |
+
probe_color_space.py measured an oracle ceiling: fitting a global intensity
|
| 5 |
+
affine (2 params) and a global HV-plane affine (6 params) on the Phase-2
|
| 6 |
+
output against GT recovers up to +7 dB (lowlight). Here we ask how much of
|
| 7 |
+
that a Phase-1-style predictor could deliver: ridge-regress the oracle
|
| 8 |
+
coefficients from blind input features (photometric14 + hvi13 of the crop and
|
| 9 |
+
of the whole frame), 5-fold, then apply the PREDICTED coefficients and measure
|
| 10 |
+
PSNR. Reports raw / predicted-knob / oracle-knob per domain, and R^2 per
|
| 11 |
+
coefficient.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
from __future__ import annotations
|
| 15 |
+
|
| 16 |
+
import argparse
|
| 17 |
+
import json
|
| 18 |
+
from pathlib import Path
|
| 19 |
+
from typing import Dict, List
|
| 20 |
+
|
| 21 |
+
import numpy as np
|
| 22 |
+
import torch
|
| 23 |
+
|
| 24 |
+
import eval_pipeline_external as ext
|
| 25 |
+
import train_graph_encoder_v2 as p1
|
| 26 |
+
import train_phase2_graph_resshift_v4 as v4
|
| 27 |
+
from eval_v7_external import V7Pipeline
|
| 28 |
+
from src.data.phase2_v4 import Phase2PairDataset, load_train_val_manifest
|
| 29 |
+
from src.models.graph_encoder.encoder import photometric_stats
|
| 30 |
+
from src.models.graph_encoder.hvi import hvi_colour_stats, hvi_to_rgb, rgb_to_hvi
|
| 31 |
+
|
| 32 |
+
DOMAINS = ("rain", "noise", "haze", "lowlight")
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def _lstsq(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:
|
| 36 |
+
ata = a.T @ a + 1e-6 * torch.eye(a.shape[1], device=a.device, dtype=a.dtype)
|
| 37 |
+
return torch.linalg.solve(ata, a.T @ b)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
@torch.no_grad()
|
| 41 |
+
def oracle_coefficients(restored: torch.Tensor, clean: torch.Tensor, k: float):
|
| 42 |
+
"""Per image: I affine (a, b) and HV affine (2x3) fitted to GT."""
|
| 43 |
+
hr, hc = rgb_to_hvi(restored, k).double(), rgb_to_hvi(clean, k).double()
|
| 44 |
+
coef_i, coef_hv = [], []
|
| 45 |
+
for i in range(restored.shape[0]):
|
| 46 |
+
ones = torch.ones_like(hr[i, 2].flatten())
|
| 47 |
+
a_i = torch.stack((hr[i, 2].flatten(), ones), 1)
|
| 48 |
+
coef_i.append(_lstsq(a_i, hc[i, 2].flatten()[:, None]).flatten())
|
| 49 |
+
a_hv = torch.stack((hr[i, 0].flatten(), hr[i, 1].flatten(), ones), 1)
|
| 50 |
+
coef_hv.append(_lstsq(a_hv, torch.stack((hc[i, 0].flatten(), hc[i, 1].flatten()), 1)).flatten())
|
| 51 |
+
return torch.stack(coef_i).float(), torch.stack(coef_hv).float()
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
@torch.no_grad()
|
| 55 |
+
def apply_knobs(restored: torch.Tensor, coef_i: torch.Tensor, coef_hv: torch.Tensor, k: float,
|
| 56 |
+
use_i: bool, use_hv: bool) -> torch.Tensor:
|
| 57 |
+
hvi = rgb_to_hvi(restored, k)
|
| 58 |
+
h, v, inten = hvi[:, 0], hvi[:, 1], hvi[:, 2]
|
| 59 |
+
if use_i:
|
| 60 |
+
inten = (inten * coef_i[:, 0, None, None] + coef_i[:, 1, None, None]).clamp(0, 1)
|
| 61 |
+
if use_hv:
|
| 62 |
+
m = coef_hv.view(-1, 3, 2) # rows: [h, v, 1] -> columns [h', v']
|
| 63 |
+
h_new = h * m[:, 0, 0, None, None] + v * m[:, 1, 0, None, None] + m[:, 2, 0, None, None]
|
| 64 |
+
v_new = h * m[:, 0, 1, None, None] + v * m[:, 1, 1, None, None] + m[:, 2, 1, None, None]
|
| 65 |
+
h, v = h_new, v_new
|
| 66 |
+
return hvi_to_rgb(torch.stack((h, v, inten), 1), k)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def ridge_cv(x: np.ndarray, y: np.ndarray, folds: int = 5, alpha: float = 1.0, seed: int = 0) -> np.ndarray:
|
| 70 |
+
"""Return out-of-fold predictions of y from x (standardised ridge)."""
|
| 71 |
+
rng = np.random.RandomState(seed)
|
| 72 |
+
order = rng.permutation(len(x))
|
| 73 |
+
pred = np.zeros_like(y)
|
| 74 |
+
for f, te in enumerate(np.array_split(order, folds)):
|
| 75 |
+
tr = np.setdiff1d(order, te)
|
| 76 |
+
mu, sd = x[tr].mean(0), x[tr].std(0) + 1e-6
|
| 77 |
+
xtr, xte = (x[tr] - mu) / sd, (x[te] - mu) / sd
|
| 78 |
+
xtr = np.concatenate([xtr, np.ones((len(xtr), 1))], 1)
|
| 79 |
+
xte = np.concatenate([xte, np.ones((len(xte), 1))], 1)
|
| 80 |
+
reg = alpha * np.eye(xtr.shape[1]); reg[-1, -1] = 0.0
|
| 81 |
+
w = np.linalg.solve(xtr.T @ xtr + reg, xtr.T @ y[tr])
|
| 82 |
+
pred[te] = xte @ w
|
| 83 |
+
return pred
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def r2(y: np.ndarray, p: np.ndarray) -> float:
|
| 87 |
+
ss_res = ((y - p) ** 2).sum(0)
|
| 88 |
+
ss_tot = ((y - y.mean(0)) ** 2).sum(0) + 1e-12
|
| 89 |
+
return float(np.mean(1.0 - ss_res / ss_tot))
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
def main() -> None:
|
| 93 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 94 |
+
parser.add_argument("--run-dir", type=Path, default=Path("outputs/phase2_v7/uformer_p5_8k_seed42"))
|
| 95 |
+
parser.add_argument("--manifest", type=Path, default=Path("outputs/phase2_graph_resshift_v4/train_val_manifest_v1.json"))
|
| 96 |
+
parser.add_argument("--output", type=Path, default=Path("outputs/global_knob_probe.json"))
|
| 97 |
+
parser.add_argument("--k", type=float, default=0.2)
|
| 98 |
+
parser.add_argument("--alpha", type=float, default=3.0)
|
| 99 |
+
args = parser.parse_args()
|
| 100 |
+
device = torch.device("cuda")
|
| 101 |
+
|
| 102 |
+
splits = load_train_val_manifest(args.manifest)
|
| 103 |
+
dataset = Phase2PairDataset(splits.val, crop_size=256, training=False, upscale_small=True)
|
| 104 |
+
groups = {}
|
| 105 |
+
for d in DOMAINS:
|
| 106 |
+
idx = [i for i, r in enumerate(splits.val) if r.degradation == d]
|
| 107 |
+
items = [dataset[i] for i in idx]
|
| 108 |
+
groups[d] = (torch.stack([it["degraded"] for it in items]), torch.stack([it["clean"] for it in items]),
|
| 109 |
+
[it["record_id"] for it in items], torch.stack([it["full_degraded"] for it in items]))
|
| 110 |
+
p1_args = p1.build_parser().parse_args([])
|
| 111 |
+
s8 = [r for r in p1.build_data_splits(p1_args).locked_test if r.degradation == "noise"]
|
| 112 |
+
ds8 = ext.PairCropDataset(s8)
|
| 113 |
+
it8 = [ds8[i] for i in range(len(s8))]
|
| 114 |
+
groups["scene008"] = (torch.stack([it["degraded"] for it in it8]), torch.stack([it["clean"] for it in it8]),
|
| 115 |
+
[it["record_id"] for it in it8], torch.stack([it["full_degraded"] for it in it8]))
|
| 116 |
+
|
| 117 |
+
pipe = V7Pipeline(args.run_dir, device)
|
| 118 |
+
report: Dict[str, object] = {"run_dir": str(args.run_dir), "k": args.k, "alpha": args.alpha}
|
| 119 |
+
# pooled regression across domains too (a single predictor, as Phase-1 would be)
|
| 120 |
+
pooled: Dict[str, List[np.ndarray]] = {"x": [], "ci": [], "chv": [], "domain": []}
|
| 121 |
+
per_group: Dict[str, Dict[str, torch.Tensor]] = {}
|
| 122 |
+
for name, (deg, cln, ids, full) in groups.items():
|
| 123 |
+
rest, feats, ci, chv = [], [], [], []
|
| 124 |
+
for s in range(0, deg.shape[0], 8):
|
| 125 |
+
sl = slice(s, s + 8)
|
| 126 |
+
r = pipe.restore(deg[sl].to(device), record_ids=ids[sl], full_degraded=full[sl].to(device))["restored"].float().clamp(0, 1)
|
| 127 |
+
a, b = oracle_coefficients(r, cln[sl].to(device), args.k)
|
| 128 |
+
x_crop = torch.cat((photometric_stats(deg[sl].to(device)), hvi_colour_stats(deg[sl].to(device), args.k)), 1)
|
| 129 |
+
x_full = torch.cat((photometric_stats(full[sl].to(device)), hvi_colour_stats(full[sl].to(device), args.k)), 1)
|
| 130 |
+
rest.append(r.cpu()); feats.append(torch.cat((x_crop, x_full), 1).cpu()); ci.append(a.cpu()); chv.append(b.cpu())
|
| 131 |
+
per_group[name] = {"restored": torch.cat(rest), "clean": cln, "x": torch.cat(feats),
|
| 132 |
+
"ci": torch.cat(ci), "chv": torch.cat(chv)}
|
| 133 |
+
pooled["x"].append(per_group[name]["x"].numpy()); pooled["ci"].append(per_group[name]["ci"].numpy())
|
| 134 |
+
pooled["chv"].append(per_group[name]["chv"].numpy()); pooled["domain"].append(np.full(deg.shape[0], name))
|
| 135 |
+
|
| 136 |
+
X = np.concatenate(pooled["x"]); CI = np.concatenate(pooled["ci"]); CHV = np.concatenate(pooled["chv"])
|
| 137 |
+
DOM = np.concatenate(pooled["domain"])
|
| 138 |
+
pred_ci_pooled = ridge_cv(X, CI, alpha=args.alpha)
|
| 139 |
+
pred_chv_pooled = ridge_cv(X, CHV, alpha=args.alpha)
|
| 140 |
+
report["pooled_r2"] = {"I_affine": r2(CI, pred_ci_pooled), "HV_affine": r2(CHV, pred_chv_pooled)}
|
| 141 |
+
print("pooled R2 I-affine %.3f HV-affine %.3f" % (report["pooled_r2"]["I_affine"], report["pooled_r2"]["HV_affine"]))
|
| 142 |
+
|
| 143 |
+
results = {}
|
| 144 |
+
for name, g in per_group.items():
|
| 145 |
+
mask = DOM == name
|
| 146 |
+
x, ci, chv = g["x"].numpy(), g["ci"].numpy(), g["chv"].numpy()
|
| 147 |
+
pred_ci_own = ridge_cv(x, ci, alpha=args.alpha) if len(x) >= 10 else ci * 0 + ci.mean(0)
|
| 148 |
+
pred_chv_own = ridge_cv(x, chv, alpha=args.alpha) if len(x) >= 10 else chv * 0 + chv.mean(0)
|
| 149 |
+
variants = {
|
| 150 |
+
"raw": (None, None),
|
| 151 |
+
"oracle_I": (g["ci"], None), "oracle_both": (g["ci"], g["chv"]),
|
| 152 |
+
"pred_pooled_I": (torch.tensor(pred_ci_pooled[mask]), None),
|
| 153 |
+
"pred_pooled_both": (torch.tensor(pred_ci_pooled[mask]), torch.tensor(pred_chv_pooled[mask])),
|
| 154 |
+
"pred_own_I": (torch.tensor(pred_ci_own), None),
|
| 155 |
+
"pred_own_both": (torch.tensor(pred_ci_own), torch.tensor(pred_chv_own)),
|
| 156 |
+
"domain_mean_I": (torch.tensor(np.broadcast_to(ci.mean(0), ci.shape).copy()), None),
|
| 157 |
+
}
|
| 158 |
+
row = {"n": int(len(x)), "r2_own_I": r2(ci, pred_ci_own), "r2_own_HV": r2(chv, pred_chv_own),
|
| 159 |
+
"r2_pooled_I": r2(ci, pred_ci_pooled[mask]), "r2_pooled_HV": r2(chv, pred_chv_pooled[mask]),
|
| 160 |
+
"oracle_gain_mean": float(ci[:, 0].mean()), "oracle_gain_std": float(ci[:, 0].std()),
|
| 161 |
+
"oracle_bias_mean": float(ci[:, 1].mean()), "oracle_bias_std": float(ci[:, 1].std())}
|
| 162 |
+
for label, (a, b) in variants.items():
|
| 163 |
+
psnrs = []
|
| 164 |
+
for s in range(0, len(x), 16):
|
| 165 |
+
sl = slice(s, s + 16)
|
| 166 |
+
r = g["restored"][sl].to(device)
|
| 167 |
+
if a is None:
|
| 168 |
+
out = r
|
| 169 |
+
else:
|
| 170 |
+
out = apply_knobs(r, a[sl].to(device).float(), (b[sl].to(device).float() if b is not None else None),
|
| 171 |
+
args.k, use_i=True, use_hv=b is not None)
|
| 172 |
+
psnrs.append(v4.rgb_psnr_per_image(out.clamp(0, 1), g["clean"][sl].to(device)).cpu())
|
| 173 |
+
row["psnr_" + label] = float(torch.cat(psnrs).mean())
|
| 174 |
+
results[name] = row
|
| 175 |
+
print("%-9s n=%3d raw %.2f | oracle I %.2f both %.2f | pred(pooled) I %.2f both %.2f | pred(own) I %.2f both %.2f | domain-mean I %.2f | R2 own I %.2f HV %.2f pooled I %.2f HV %.2f | gain %.2f±%.2f bias %.3f±%.3f" % (
|
| 176 |
+
name, row["n"], row["psnr_raw"], row["psnr_oracle_I"], row["psnr_oracle_both"], row["psnr_pred_pooled_I"],
|
| 177 |
+
row["psnr_pred_pooled_both"], row["psnr_pred_own_I"], row["psnr_pred_own_both"], row["psnr_domain_mean_I"],
|
| 178 |
+
row["r2_own_I"], row["r2_own_HV"], row["r2_pooled_I"], row["r2_pooled_HV"],
|
| 179 |
+
row["oracle_gain_mean"], row["oracle_gain_std"], row["oracle_bias_mean"], row["oracle_bias_std"]))
|
| 180 |
+
report["groups"] = results
|
| 181 |
+
args.output.write_text(json.dumps(report, indent=2))
|
| 182 |
+
print("WROTE", args.output)
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
if __name__ == "__main__":
|
| 186 |
+
main()
|
dataset/phase1_noise_20260906/code/probe_tone_oracle.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Oracle ceilings of global colour/tone controls on a run's outputs.
|
| 3 |
+
|
| 4 |
+
For each image of a group (whole-image restoration), fit per image against
|
| 5 |
+
the GT and report the PSNR after each transform family:
|
| 6 |
+
raw model output
|
| 7 |
+
affine_I I' = a*I + b on intensity I = max(RGB), chroma ratios kept
|
| 8 |
+
gamma_I I' = a*I^g + b (the CIDNet C_k-style power on intensity)
|
| 9 |
+
matrix 3x3 colour matrix + bias on RGB (white balance / colour cast)
|
| 10 |
+
gamma+matrix both
|
| 11 |
+
The fits are least squares on the image itself (oracle), so the numbers are
|
| 12 |
+
ceilings, not predictions; compare with probe_global_knob.py (affine on RGB).
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
from __future__ import annotations
|
| 16 |
+
|
| 17 |
+
import argparse
|
| 18 |
+
import json
|
| 19 |
+
from pathlib import Path
|
| 20 |
+
|
| 21 |
+
import torch
|
| 22 |
+
|
| 23 |
+
import eval_full_frame as ff
|
| 24 |
+
import train_phase2_graph_resshift_v4 as v4
|
| 25 |
+
from eval_v7_external import V7Pipeline
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def psnr(a, b):
|
| 29 |
+
return float(-10 * torch.log10(((a - b) ** 2).mean().clamp_min(1e-12)))
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def intensity(x):
|
| 33 |
+
return x.max(dim=1, keepdim=True).values.clamp_min(1e-6)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def fit_affine(i_out, i_gt):
|
| 37 |
+
x = torch.stack((i_out.flatten(), torch.ones_like(i_out.flatten())), 1)
|
| 38 |
+
sol = torch.linalg.lstsq(x, i_gt.flatten().unsqueeze(1)).solution.flatten()
|
| 39 |
+
return float(sol[0]), float(sol[1])
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def apply_intensity(x, new_i):
|
| 43 |
+
return (x * (new_i / intensity(x))).clamp(0, 1)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
def best_gamma(x, gt):
|
| 47 |
+
best = (psnr(x, gt), 1.0, 1.0, 0.0)
|
| 48 |
+
i_out, i_gt = intensity(x), intensity(gt)
|
| 49 |
+
for g in [0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.25, 1.5, 1.75, 2.0]:
|
| 50 |
+
a, b = fit_affine(i_out ** g, i_gt)
|
| 51 |
+
cand = apply_intensity(x, (a * i_out ** g + b).clamp_min(1e-6))
|
| 52 |
+
p = psnr(cand, gt)
|
| 53 |
+
if p > best[0]:
|
| 54 |
+
best = (p, g, a, b)
|
| 55 |
+
return best
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def fit_matrix(x, gt):
|
| 59 |
+
px = x.flatten(2)[0].t() # [N,3]
|
| 60 |
+
py = gt.flatten(2)[0].t()
|
| 61 |
+
xa = torch.cat((px, torch.ones(px.shape[0], 1, device=px.device)), 1)
|
| 62 |
+
sol = torch.linalg.lstsq(xa, py).solution # [4,3]
|
| 63 |
+
out = (xa @ sol).t().reshape(1, 3, *x.shape[-2:]).clamp(0, 1)
|
| 64 |
+
return out
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def main():
|
| 68 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 69 |
+
parser.add_argument("--run-dir", type=Path, required=True)
|
| 70 |
+
parser.add_argument("--checkpoint", default="last.pt")
|
| 71 |
+
parser.add_argument("--group", default="lowlight_lolv2_test")
|
| 72 |
+
parser.add_argument("--limit", type=int, default=100)
|
| 73 |
+
parser.add_argument("--output", type=Path, default=None)
|
| 74 |
+
args = parser.parse_args()
|
| 75 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 76 |
+
pipe = V7Pipeline(args.run_dir, device, checkpoint=args.checkpoint)
|
| 77 |
+
seed = int(pipe.args.eval_seed)
|
| 78 |
+
records = ff.external_groups(300)[args.group][: args.limit]
|
| 79 |
+
ds = ff.FullFrameDataset(records)
|
| 80 |
+
acc = {k: [] for k in ("raw", "affine_I", "gamma_I", "matrix", "gamma+matrix")}
|
| 81 |
+
gammas = []
|
| 82 |
+
with torch.no_grad():
|
| 83 |
+
for i in range(len(ds)):
|
| 84 |
+
it = ds[i]
|
| 85 |
+
x = it["degraded"].unsqueeze(0).to(device)
|
| 86 |
+
gt = it["clean"].unsqueeze(0).to(device)
|
| 87 |
+
full = it["full_degraded"].unsqueeze(0).to(device)
|
| 88 |
+
out = ff.restore_full_frame(
|
| 89 |
+
lambda t, ids, f: pipe.restore(t, record_ids=list(ids), seed=seed, full_degraded=f)["restored"],
|
| 90 |
+
x, it["record_id"], tta=1, full_frame=full, whole_max_pixels=1200000).float()
|
| 91 |
+
acc["raw"].append(psnr(out, gt))
|
| 92 |
+
a, b = fit_affine(intensity(out), intensity(gt))
|
| 93 |
+
acc["affine_I"].append(psnr(apply_intensity(out, (a * intensity(out) + b).clamp_min(1e-6)), gt))
|
| 94 |
+
p, g, a2, b2 = best_gamma(out, gt)
|
| 95 |
+
acc["gamma_I"].append(p); gammas.append(g)
|
| 96 |
+
m = fit_matrix(out, gt)
|
| 97 |
+
acc["matrix"].append(psnr(m, gt))
|
| 98 |
+
gm = apply_intensity(out, (a2 * intensity(out) ** g + b2).clamp_min(1e-6))
|
| 99 |
+
acc["gamma+matrix"].append(psnr(fit_matrix(gm, gt), gt))
|
| 100 |
+
report = {k: sum(v) / len(v) for k, v in acc.items()}
|
| 101 |
+
report["gamma_median"] = float(torch.tensor(gammas).median())
|
| 102 |
+
report["n"] = len(ds)
|
| 103 |
+
print("ORACLE", args.group, json.dumps({k: (round(v, 3) if isinstance(v, float) else v) for k, v in report.items()}))
|
| 104 |
+
if args.output:
|
| 105 |
+
args.output.write_text(json.dumps(report, indent=2))
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
if __name__ == "__main__":
|
| 109 |
+
main()
|
dataset/phase1_noise_20260906/code/probe_v7_taps.py
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Inference-time tap sensitivity for a v7 checkpoint (no training).
|
| 3 |
+
|
| 4 |
+
Two ablation levels, each evaluated on the full validation split with the
|
| 5 |
+
exact training-time sampler:
|
| 6 |
+
|
| 7 |
+
* fields — one Phase-1 representation field at a time is replaced by its
|
| 8 |
+
batch mean (instance information removed, population statistics
|
| 9 |
+
kept); measures what the encoder's OUTPUTS contribute.
|
| 10 |
+
* channels — one conditioning channel of the bundle (context / global_vector /
|
| 11 |
+
content / spatial / gate) is neutralised; measures which of the
|
| 12 |
+
parallel INJECTION PATHS the trunk actually relies on.
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
from __future__ import annotations
|
| 16 |
+
|
| 17 |
+
import argparse
|
| 18 |
+
import copy
|
| 19 |
+
import dataclasses
|
| 20 |
+
import json
|
| 21 |
+
from pathlib import Path
|
| 22 |
+
from typing import Any, Dict
|
| 23 |
+
|
| 24 |
+
import torch
|
| 25 |
+
from torch import nn
|
| 26 |
+
from torch.utils.data import DataLoader
|
| 27 |
+
|
| 28 |
+
import train_phase2_graph_resshift_v4 as v4
|
| 29 |
+
import train_phase2_unified_v7 as v7
|
| 30 |
+
from src.data.phase2_v4 import Phase2PairDataset, load_train_val_manifest
|
| 31 |
+
from visualize_v7_uformer import _load_run_args
|
| 32 |
+
|
| 33 |
+
FIELDS = (
|
| 34 |
+
"content_latent", "node_tokens", "routing_probs", "severity_coords",
|
| 35 |
+
"spatial_maps", "unknown_residual", "global_condition",
|
| 36 |
+
)
|
| 37 |
+
CHANNELS = ("context", "global_vector", "content", "spatial", "gate")
|
| 38 |
+
EXTRAS = ("gate_uniform", "no_conditioning")
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def _batch_mean(value: torch.Tensor) -> torch.Tensor:
|
| 42 |
+
return value.mean(dim=0, keepdim=True).expand_as(value).contiguous()
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
class FieldAblatedPhase1(nn.Module):
|
| 46 |
+
def __init__(self, phase1: nn.Module, field: str) -> None:
|
| 47 |
+
super().__init__()
|
| 48 |
+
self.phase1 = phase1
|
| 49 |
+
self.field = field
|
| 50 |
+
|
| 51 |
+
def forward(self, degraded: torch.Tensor):
|
| 52 |
+
representation = self.phase1(degraded)
|
| 53 |
+
if self.field:
|
| 54 |
+
value = getattr(representation, self.field)
|
| 55 |
+
if torch.is_tensor(value):
|
| 56 |
+
setattr(representation, self.field, _batch_mean(value))
|
| 57 |
+
return representation
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def _replace(bundle: Any, **changes: Any) -> Any:
|
| 61 |
+
if dataclasses.is_dataclass(bundle):
|
| 62 |
+
return dataclasses.replace(bundle, **changes)
|
| 63 |
+
clone = copy.copy(bundle)
|
| 64 |
+
for name, value in changes.items():
|
| 65 |
+
setattr(clone, name, value)
|
| 66 |
+
return clone
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def _uniform_gate(gate: Any) -> Any:
|
| 70 |
+
strengths = torch.full_like(gate.strengths, 0.2)
|
| 71 |
+
mask = torch.ones_like(strengths)
|
| 72 |
+
return _replace(
|
| 73 |
+
gate, strengths=strengths, top2_mask=mask,
|
| 74 |
+
spatial_gates=torch.full_like(gate.spatial_gates, 0.5),
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def _neutralised_gate(gate: Any) -> Any:
|
| 79 |
+
strengths = _batch_mean(gate.strengths)
|
| 80 |
+
top2 = torch.topk(strengths, k=2, dim=1).indices
|
| 81 |
+
mask = torch.zeros_like(strengths).scatter_(1, top2, 1.0)
|
| 82 |
+
return _replace(
|
| 83 |
+
gate, strengths=strengths, top2_mask=mask,
|
| 84 |
+
spatial_gates=_batch_mean(gate.spatial_gates),
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def install_channel_ablation(restorer: nn.Module, channel: str) -> None:
|
| 89 |
+
original = restorer.build_condition
|
| 90 |
+
|
| 91 |
+
def patched(representation: Any):
|
| 92 |
+
bundle = original(representation)
|
| 93 |
+
if not channel:
|
| 94 |
+
return bundle
|
| 95 |
+
if channel == "gate":
|
| 96 |
+
return _replace(bundle, gate=_neutralised_gate(bundle.gate))
|
| 97 |
+
if channel == "gate_uniform":
|
| 98 |
+
return _replace(bundle, gate=_uniform_gate(bundle.gate))
|
| 99 |
+
if channel == "no_conditioning":
|
| 100 |
+
return _replace(
|
| 101 |
+
bundle,
|
| 102 |
+
context=torch.zeros_like(bundle.context),
|
| 103 |
+
global_vector=torch.zeros_like(bundle.global_vector),
|
| 104 |
+
content=torch.zeros_like(bundle.content),
|
| 105 |
+
spatial=torch.zeros_like(bundle.spatial),
|
| 106 |
+
gate=_uniform_gate(bundle.gate),
|
| 107 |
+
)
|
| 108 |
+
value = getattr(bundle, channel)
|
| 109 |
+
return _replace(bundle, **{channel: torch.zeros_like(value)})
|
| 110 |
+
|
| 111 |
+
restorer.build_condition = patched # type: ignore[assignment]
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
def _macro(result: Dict[str, Any]) -> Dict[str, float]:
|
| 115 |
+
restored = result.get("restored", result)
|
| 116 |
+
out = {
|
| 117 |
+
"macro_psnr": float(restored["macro_psnr"]),
|
| 118 |
+
"macro_ssim": float(restored["macro_ssim"]),
|
| 119 |
+
}
|
| 120 |
+
for domain, values in restored["per_domain"].items():
|
| 121 |
+
out[domain] = float(values["psnr"])
|
| 122 |
+
return out
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def main() -> None:
|
| 126 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 127 |
+
parser.add_argument(
|
| 128 |
+
"--run-dir", type=Path,
|
| 129 |
+
default=Path("outputs/phase2_v7/uformer_head8k_seed42"),
|
| 130 |
+
)
|
| 131 |
+
parser.add_argument("--level", choices=("fields", "channels", "extras"), required=True)
|
| 132 |
+
parser.add_argument("--output", type=Path, required=True)
|
| 133 |
+
args = parser.parse_args()
|
| 134 |
+
|
| 135 |
+
run_args = _load_run_args(args.run_dir)
|
| 136 |
+
device = torch.device("cuda")
|
| 137 |
+
checkpoint = v4._torch_load(args.run_dir / "best.pt", map_location="cpu")
|
| 138 |
+
model = v7._build_v7_restorer(run_args, device)
|
| 139 |
+
model.load_state_dict(checkpoint["ema_state_dict"]["shadow"], strict=True)
|
| 140 |
+
model.eval()
|
| 141 |
+
phase1, _ = v4.build_frozen_phase1(
|
| 142 |
+
run_args.phase1_checkpoint, run_args.phase1_sha256, device
|
| 143 |
+
)
|
| 144 |
+
splits = load_train_val_manifest(run_args.manifest)
|
| 145 |
+
loader = DataLoader(
|
| 146 |
+
Phase2PairDataset(
|
| 147 |
+
splits.val, crop_size=run_args.crop_size,
|
| 148 |
+
training=False, upscale_small=True,
|
| 149 |
+
),
|
| 150 |
+
batch_size=8, shuffle=False, num_workers=4, pin_memory=True,
|
| 151 |
+
)
|
| 152 |
+
names = ("",) + {"fields": FIELDS, "channels": CHANNELS, "extras": EXTRAS}[args.level]
|
| 153 |
+
report: Dict[str, Any] = {"level": args.level, "run_dir": str(args.run_dir)}
|
| 154 |
+
pristine_build = model.build_condition
|
| 155 |
+
with v7._installed_v7_backend(run_args):
|
| 156 |
+
for name in names:
|
| 157 |
+
label = name or "baseline"
|
| 158 |
+
if args.level == "fields":
|
| 159 |
+
encoder = FieldAblatedPhase1(phase1, name)
|
| 160 |
+
model.build_condition = pristine_build
|
| 161 |
+
else:
|
| 162 |
+
encoder = phase1
|
| 163 |
+
model.build_condition = pristine_build
|
| 164 |
+
install_channel_ablation(model, name)
|
| 165 |
+
with torch.no_grad():
|
| 166 |
+
result = v4.evaluate(
|
| 167 |
+
model, encoder, loader, device, int(run_args.eval_seed)
|
| 168 |
+
)
|
| 169 |
+
report[label] = _macro(result)
|
| 170 |
+
print(label, json.dumps(report[label]), flush=True)
|
| 171 |
+
args.output.write_text(json.dumps(report, indent=2, sort_keys=True))
|
| 172 |
+
print("WROTE", args.output)
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
if __name__ == "__main__":
|
| 176 |
+
main()
|
dataset/phase1_noise_20260906/code/relocate_manifest.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Rewrite the absolute file paths of a Phase-2 train/val manifest for another
|
| 3 |
+
machine and recompute the derived identities (record_id, split digests).
|
| 4 |
+
|
| 5 |
+
The manifest's record ids and digests hash the absolute paths, so a plain
|
| 6 |
+
text substitution is rejected by ``load_train_val_manifest``; this rebuilds
|
| 7 |
+
the records through ``RestorationRecord`` so the new manifest validates.
|
| 8 |
+
Usage:
|
| 9 |
+
relocate_manifest.py --manifest in.json --output out.json \
|
| 10 |
+
--map /home/admin_mcn/data/=/home/me/bundle/data/ \
|
| 11 |
+
--map /home/admin_mcn/.cache/kagglehub/=/home/me/bundle/kagglehub/
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
from __future__ import annotations
|
| 15 |
+
|
| 16 |
+
import argparse
|
| 17 |
+
import json
|
| 18 |
+
from pathlib import Path
|
| 19 |
+
|
| 20 |
+
from src.data.phase2_v4 import RestorationRecord, TrainValSplits, save_train_val_manifest, load_train_val_manifest
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def relocate(path: str, mapping: list) -> str:
|
| 24 |
+
for old, new in mapping:
|
| 25 |
+
if path.startswith(old):
|
| 26 |
+
return new + path[len(old):]
|
| 27 |
+
raise ValueError("no mapping for %s" % path)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def main() -> None:
|
| 31 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 32 |
+
parser.add_argument("--manifest", type=Path, required=True)
|
| 33 |
+
parser.add_argument("--output", type=Path, required=True)
|
| 34 |
+
parser.add_argument("--map", action="append", default=[], help="OLD_PREFIX=NEW_PREFIX (repeatable)")
|
| 35 |
+
parser.add_argument("--check-files", action="store_true", help="verify every relocated file exists")
|
| 36 |
+
args = parser.parse_args()
|
| 37 |
+
mapping = [tuple(m.split("=", 1)) for m in args.map]
|
| 38 |
+
payload = json.loads(args.manifest.read_text(encoding="utf-8"))
|
| 39 |
+
|
| 40 |
+
def rebuild(values):
|
| 41 |
+
records = []
|
| 42 |
+
for v in values:
|
| 43 |
+
records.append(RestorationRecord(
|
| 44 |
+
degraded=Path(relocate(v["degraded"], mapping)),
|
| 45 |
+
clean=Path(relocate(v["clean"], mapping)),
|
| 46 |
+
degradation=v["degradation"], dataset=v["dataset"], source_id=v["source_id"],
|
| 47 |
+
split_group=v["split_group"], clean_content_sha256=v["clean_content_sha256"],
|
| 48 |
+
))
|
| 49 |
+
return tuple(records)
|
| 50 |
+
|
| 51 |
+
splits = TrainValSplits(train=rebuild(payload["train"]), val=rebuild(payload["val"]),
|
| 52 |
+
quarantine_count=int(payload["quarantine_count"]))
|
| 53 |
+
if args.check_files:
|
| 54 |
+
missing = [str(p) for r in splits.train + splits.val for p in (r.degraded, r.clean) if not p.exists()]
|
| 55 |
+
if missing:
|
| 56 |
+
raise SystemExit("%d missing files, e.g. %s" % (len(missing), missing[:3]))
|
| 57 |
+
save_train_val_manifest(args.output, splits)
|
| 58 |
+
reloaded = load_train_val_manifest(args.output)
|
| 59 |
+
print("relocated %d train / %d val records -> %s (validated: %d/%d)" % (
|
| 60 |
+
len(splits.train), len(splits.val), args.output, len(reloaded.train), len(reloaded.val)))
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
if __name__ == "__main__":
|
| 64 |
+
main()
|
dataset/phase1_noise_20260906/code/run_phase1_v5f.sh
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Phase-1 v5f pair (2026-09-04): v5c_ab recipe (RANDOM native crops) + crop-level severity floor only.
|
| 3 |
+
# SupCon all, raw-weight eval, F1 selection) + residual-aware training crops
|
| 4 |
+
# GPU0 phase1_v5f --severity-floor 0.05
|
| 5 |
+
# GPU1 phase1_v5f_b --severity-floor 0.03
|
| 6 |
+
# v5e showed max-residual crop selection biases training crops (sky/dense streaks) away from the val centre-crop distribution; the floor alone keeps the distribution and fixes empty-crop labels. Each launch can wait for a previous run (WAIT0/WAIT1 = its train log).
|
| 7 |
+
# path of that run's train log) so it starts as soon as the GPU frees up.
|
| 8 |
+
# Usage: WAIT1=outputs/phase1_v5e_ab_train.log bash run_phase1_v5f.sh
|
| 9 |
+
set -u
|
| 10 |
+
cd /home/admin_mcn/scdc_ban
|
| 11 |
+
PY=/home/admin_mcn/anaconda3/bin/python
|
| 12 |
+
CACHE=outputs/phase1_cache/sidd_native_256
|
| 13 |
+
DATA=/home/admin_mcn/data
|
| 14 |
+
COMMON="--batch-size 32 --eval-batch-size 16 --epochs 50 --steps-per-epoch 500 \
|
| 15 |
+
--learning-rate 1e-4 --weight-decay 1e-4 --max-grad-norm 1.0 --image-size 256 \
|
| 16 |
+
--workers 8 --no-amp --seed 42 \
|
| 17 |
+
--photometric --photometric-dim 128 --photometric-weight 0.5 \
|
| 18 |
+
--embed-weight 0.25 --embed-temperature 0.1 --embed-members all \
|
| 19 |
+
--ood-real-root $DATA/Snow100K/train/all/synthetic --ood-real-prob 0.35 --ood-real-val-count 512 \
|
| 20 |
+
--extra-clean-root $DATA/Snow100K/train/all/gt --extra-null-weight 0.05 \
|
| 21 |
+
--reside-limit 5000 --reside-val-count 100 --run-final-test \
|
| 22 |
+
--crop-policy native --sidd-native-crops 32 --cache-root $CACHE \
|
| 23 |
+
--crop-select random"
|
| 24 |
+
|
| 25 |
+
wait_log() { # $1 = train log to wait for ("" = no wait)
|
| 26 |
+
[ -z "$1" ] && return 0
|
| 27 |
+
while ! grep -q "Training complete" "$1" 2>/dev/null; do
|
| 28 |
+
if grep -q Traceback "$1" 2>/dev/null && ! pgrep -f "[t]rain_graph_encoder_v2.py.*$(basename ${1%_train.log})" >/dev/null; then
|
| 29 |
+
echo "[v5f] $1 crashed; launching anyway"; return 0
|
| 30 |
+
fi
|
| 31 |
+
sleep 120
|
| 32 |
+
done
|
| 33 |
+
sleep 30
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
launch() { # $1 = run name, $2 = gpu, $3 = extra flags
|
| 37 |
+
local name=$1 gpu=$2 extra=$3
|
| 38 |
+
mkdir -p outputs/$name
|
| 39 |
+
[ -f outputs/$name/severity_calibration.json ] || cp outputs/phase1_v5c/severity_calibration.json outputs/$name/ 2>/dev/null
|
| 40 |
+
CUDA_VISIBLE_DEVICES=$gpu setsid nohup $PY train_graph_encoder_v2.py $COMMON $extra \
|
| 41 |
+
--output-dir outputs/$name > outputs/${name}_train.log 2>&1 < /dev/null &
|
| 42 |
+
echo "[v5f] $(date +%H:%M) launched $name on GPU$gpu ($extra) pid $!"
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
ONLY=${ONLY:-both}
|
| 46 |
+
WAIT0=${WAIT0:-}; WAIT1=${WAIT1:-}
|
| 47 |
+
case "$ONLY" in
|
| 48 |
+
v5f) wait_log "$WAIT0"; launch phase1_v5f 0 "--severity-floor 0.05" ;;
|
| 49 |
+
v5f_b) wait_log "$WAIT1"; launch phase1_v5f_b 1 "--severity-floor 0.03" ;;
|
| 50 |
+
both)
|
| 51 |
+
( wait_log "$WAIT0"; launch phase1_v5f 0 "--severity-floor 0.05" ) &
|
| 52 |
+
( wait_log "$WAIT1"; launch phase1_v5f_b 1 "--severity-floor 0.03" ) &
|
| 53 |
+
wait
|
| 54 |
+
;;
|
| 55 |
+
*) echo "ONLY must be v5f | v5f_b | both"; exit 2 ;;
|
| 56 |
+
esac
|
dataset/phase1_noise_20260906/code/run_uformer_v9a.sh
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# v9a: the A recipe (uformer_p5) with ONE variable changed — Phase-1 is
|
| 3 |
+
# phase1_v5f (native crops + severity floor 0.05) instead of ll_v3. Same
|
| 4 |
+
# warm-start (dgf8k best, EMA), same 8k steps, same seed, same flags, so the
|
| 5 |
+
# macro PSNR is directly comparable to A's 27.903 / 0.8591.
|
| 6 |
+
set -u
|
| 7 |
+
cd /home/admin_mcn/scdc_ban
|
| 8 |
+
RUN_DIR=outputs/phase2_v7/uformer_v9a_8k_seed42
|
| 9 |
+
LOG=outputs/phase2_v7/uformer_v9a_train.log
|
| 10 |
+
PY=/home/admin_mcn/anaconda3/bin/python
|
| 11 |
+
MAX_RESTARTS=20
|
| 12 |
+
FINAL_STEP=8000
|
| 13 |
+
WARMSTART=outputs/phase2_v7/uformer_dgf8k_seed42/best.pt
|
| 14 |
+
WARMSTART_SHA=f92dc6d37ffe4e8a55ce723a1acf51042bf9821b98eefeaebb8ba140b7ce0f97
|
| 15 |
+
PHASE1=${PHASE1_CKPT:-outputs/phase1_v5f/graph_encoder_best.pt}
|
| 16 |
+
PHASE1_SHA=$(sha256sum $PHASE1 | cut -d' ' -f1)
|
| 17 |
+
|
| 18 |
+
is_running() { pgrep -f "[t]rain_phase2_unified_v7.py.*uformer_v9a_8k_seed42" >/dev/null; }
|
| 19 |
+
is_complete() {
|
| 20 |
+
grep -q "\"event\": \"evaluation\".*\"step\": $FINAL_STEP\|\"step\": $FINAL_STEP.*\"event\": \"evaluation\"" \
|
| 21 |
+
"$RUN_DIR/metrics.jsonl" 2>/dev/null
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
launch() {
|
| 25 |
+
if [ "$1" = "fresh" ]; then
|
| 26 |
+
SOURCE_FLAGS="--warmstart-v6 $WARMSTART --warmstart-v6-sha256 $WARMSTART_SHA --warmstart-weight-source ema"
|
| 27 |
+
else
|
| 28 |
+
SOURCE_FLAGS="--resume $RUN_DIR/overflow_recovery.pt"
|
| 29 |
+
fi
|
| 30 |
+
# shellcheck disable=SC2086
|
| 31 |
+
CUDA_VISIBLE_DEVICES=0 nohup "$PY" \
|
| 32 |
+
train_phase2_unified_v7.py \
|
| 33 |
+
--backbone uformer --timesteps 2 \
|
| 34 |
+
$SOURCE_FLAGS \
|
| 35 |
+
--phase1-checkpoint $PHASE1 \
|
| 36 |
+
--phase1-sha256 $PHASE1_SHA \
|
| 37 |
+
--manifest outputs/phase2_graph_resshift_v4/train_val_manifest_v1.json \
|
| 38 |
+
--output-dir "$RUN_DIR" \
|
| 39 |
+
--fine-chroma-weight 0.5 --fine-luma-weight 0.5 --fine-vgg-weight 0.1 \
|
| 40 |
+
--full-res-tail-blocks 6 --full-res-tail-width 48 --output-film \
|
| 41 |
+
--pyramid-heads --pyramid-loss-weights 0.1,0.2,0.3 \
|
| 42 |
+
--cond-dropout-prob 0.15 --identity-pair-prob 0.10 --noise-pair-prob 0.20 \
|
| 43 |
+
--kappa 0.11607981286942959 \
|
| 44 |
+
--expert-kappa-values 0.09780,0.03836,0.13436,0.41464,0.11608 \
|
| 45 |
+
--eta-end 0.99 --min-noise 0.2 --power 0.3 \
|
| 46 |
+
--cond-dim 256 --expert-rank 16 --gate-hidden-dim 128 --gate-max-correction 1.0 \
|
| 47 |
+
--batch-size 8 --grad-accum 2 --eval-batch-size 8 --workers 4 \
|
| 48 |
+
--learning-rate 3e-5 --max-steps $FINAL_STEP --run-until-step $FINAL_STEP \
|
| 49 |
+
--eval-steps 0,500,1000,2000,3000,4000,6000,8000 \
|
| 50 |
+
--milestone-steps 4000 \
|
| 51 |
+
--seed 42 --eval-seed 20260830 >> "$LOG" 2>&1 &
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
overflow_count() { local n; n=$(grep -c "RecoverableAmpOverflow" "$LOG" 2>/dev/null | head -n 1); echo "${n:-0}"; }
|
| 55 |
+
|
| 56 |
+
restarts=0
|
| 57 |
+
seen_overflows=$(overflow_count)
|
| 58 |
+
if [ -f "$RUN_DIR/overflow_recovery.pt" ]; then
|
| 59 |
+
echo "[supervisor] resuming from an existing overflow_recovery.pt phase1=$PHASE1 sha=$PHASE1_SHA (prior overflows in log: $seen_overflows)"
|
| 60 |
+
launch resume
|
| 61 |
+
else
|
| 62 |
+
echo "[supervisor] fresh launch phase1=$PHASE1 sha=$PHASE1_SHA (prior overflows in log: $seen_overflows)"
|
| 63 |
+
launch fresh
|
| 64 |
+
fi
|
| 65 |
+
sleep 90
|
| 66 |
+
|
| 67 |
+
while true; do
|
| 68 |
+
if is_complete; then
|
| 69 |
+
echo "[supervisor] run complete (eval @$FINAL_STEP present); exiting"
|
| 70 |
+
break
|
| 71 |
+
fi
|
| 72 |
+
if ! is_running; then
|
| 73 |
+
current=$(overflow_count)
|
| 74 |
+
if [ "$current" -gt "$seen_overflows" ]; then
|
| 75 |
+
if [ "$restarts" -ge "$MAX_RESTARTS" ]; then
|
| 76 |
+
echo "[supervisor] restart budget exhausted ($MAX_RESTARTS); exiting"
|
| 77 |
+
break
|
| 78 |
+
fi
|
| 79 |
+
if [ ! -f "$RUN_DIR/overflow_recovery.pt" ]; then
|
| 80 |
+
echo "[supervisor] overflow logged but no recovery checkpoint; exiting"
|
| 81 |
+
break
|
| 82 |
+
fi
|
| 83 |
+
seen_overflows=$current
|
| 84 |
+
restarts=$((restarts + 1))
|
| 85 |
+
echo "[supervisor] relaunch #$restarts from overflow_recovery.pt (overflows=$current)"
|
| 86 |
+
launch resume
|
| 87 |
+
sleep 90
|
| 88 |
+
else
|
| 89 |
+
echo "[supervisor] process died WITHOUT a new overflow; not restarting"
|
| 90 |
+
break
|
| 91 |
+
fi
|
| 92 |
+
fi
|
| 93 |
+
sleep 45
|
| 94 |
+
done
|
dataset/phase1_noise_20260906/code/run_uformer_v9a15k.sh
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# v9a-15k: the A recipe on Phase-1 v5f, trained to 15k steps across BOTH GPUs
|
| 3 |
+
# (torchrun DDP, world size 2), with a decoder-first curriculum and early
|
| 4 |
+
# stopping.
|
| 5 |
+
#
|
| 6 |
+
# * Phase-1 outputs/phase1_v5f/graph_encoder_best.pt (native crops +
|
| 7 |
+
# severity floor 0.05; 4/4 gates)
|
| 8 |
+
# * warm start uformer_dgf8k_seed42/best.pt (EMA) — the same source A used,
|
| 9 |
+
# so the 8k-step v9a numbers stay comparable
|
| 10 |
+
# * effective batch 16 = batch 8 x grad-accum 1 x 2 ranks (A: 8 x 2 x 1 rank)
|
| 11 |
+
# * --ddp-find-unused is REQUIRED: the MoE experts are hard-skipped per
|
| 12 |
+
# batch, so the used-parameter set differs across ranks and the reducer
|
| 13 |
+
# deadlocks on the first divergent batch (observed: both ranks spinning
|
| 14 |
+
# at 100% inside the grad-norm all_reduce, no step ever logged)
|
| 15 |
+
# * curriculum first 3000 steps train the decoder / conditioning / heads
|
| 16 |
+
# only (encoder gradients dropped), then the whole network
|
| 17 |
+
# * early stopping 3 evaluations without a macro-PSNR gain above 0.02 dB
|
| 18 |
+
#
|
| 19 |
+
# Auto-resume supervisor: a designed RecoverableAmpOverflow resumes from
|
| 20 |
+
# overflow_recovery.pt; anything else stops the run.
|
| 21 |
+
set -u
|
| 22 |
+
cd /home/admin_mcn/scdc_ban
|
| 23 |
+
RUN_NAME=uformer_v9a15k_seed42
|
| 24 |
+
RUN_DIR=outputs/phase2_v7/$RUN_NAME
|
| 25 |
+
LOG=outputs/phase2_v7/uformer_v9a15k_train.log
|
| 26 |
+
PY=/home/admin_mcn/anaconda3/bin/python
|
| 27 |
+
MAX_RESTARTS=20
|
| 28 |
+
FINAL_STEP=15000
|
| 29 |
+
WARMSTART=outputs/phase2_v7/uformer_dgf8k_seed42/best.pt
|
| 30 |
+
WARMSTART_SHA=f92dc6d37ffe4e8a55ce723a1acf51042bf9821b98eefeaebb8ba140b7ce0f97
|
| 31 |
+
PHASE1=${PHASE1_CKPT:-outputs/phase1_v5f/graph_encoder_best.pt}
|
| 32 |
+
PHASE1_SHA=$(sha256sum $PHASE1 | cut -d' ' -f1)
|
| 33 |
+
|
| 34 |
+
is_running() { pgrep -f "[t]rain_phase2_unified_v7.py.*$RUN_NAME" >/dev/null; }
|
| 35 |
+
is_complete() {
|
| 36 |
+
grep -q "\"event\": \"evaluation\".*\"step\": $FINAL_STEP\|\"step\": $FINAL_STEP.*\"event\": \"evaluation\"" \
|
| 37 |
+
"$RUN_DIR/metrics.jsonl" 2>/dev/null || grep -q "\[early-stop\] training ended" "$LOG" 2>/dev/null
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
launch() {
|
| 41 |
+
if [ "$1" = "fresh" ]; then
|
| 42 |
+
SOURCE_FLAGS="--warmstart-v6 $WARMSTART --warmstart-v6-sha256 $WARMSTART_SHA --warmstart-weight-source ema"
|
| 43 |
+
else
|
| 44 |
+
SOURCE_FLAGS="--resume $RUN_DIR/overflow_recovery.pt"
|
| 45 |
+
fi
|
| 46 |
+
# shellcheck disable=SC2086
|
| 47 |
+
CUDA_VISIBLE_DEVICES=0,1 nohup "$PY" -m torch.distributed.run \
|
| 48 |
+
--nproc_per_node=2 --master_port=29517 \
|
| 49 |
+
train_phase2_unified_v7.py \
|
| 50 |
+
--ddp --ddp-find-unused \
|
| 51 |
+
--backbone uformer --timesteps 2 \
|
| 52 |
+
$SOURCE_FLAGS \
|
| 53 |
+
--phase1-checkpoint $PHASE1 \
|
| 54 |
+
--phase1-sha256 $PHASE1_SHA \
|
| 55 |
+
--manifest outputs/phase2_graph_resshift_v4/train_val_manifest_v1.json \
|
| 56 |
+
--output-dir "$RUN_DIR" \
|
| 57 |
+
--fine-chroma-weight 0.5 --fine-luma-weight 0.5 --fine-vgg-weight 0.1 \
|
| 58 |
+
--full-res-tail-blocks 6 --full-res-tail-width 48 --output-film \
|
| 59 |
+
--pyramid-heads --pyramid-loss-weights 0.1,0.2,0.3 \
|
| 60 |
+
--cond-dropout-prob 0.15 --identity-pair-prob 0.10 --noise-pair-prob 0.20 \
|
| 61 |
+
--kappa 0.11607981286942959 \
|
| 62 |
+
--expert-kappa-values 0.09780,0.03836,0.13436,0.41464,0.11608 \
|
| 63 |
+
--eta-end 0.99 --min-noise 0.2 --power 0.3 \
|
| 64 |
+
--cond-dim 256 --expert-rank 16 --gate-hidden-dim 128 --gate-max-correction 1.0 \
|
| 65 |
+
--batch-size 8 --grad-accum 1 --eval-batch-size 8 --workers 4 \
|
| 66 |
+
--learning-rate 3e-5 --max-steps $FINAL_STEP --run-until-step $FINAL_STEP \
|
| 67 |
+
--eval-steps 0,500,1000,2000,3000,4000,5000,6000,7000,8000,10000,12000,15000 \
|
| 68 |
+
--milestone-steps 4000,8000,12000 \
|
| 69 |
+
--freeze-encoder-steps 3000 \
|
| 70 |
+
--early-stop-patience 3 --early-stop-min-delta 0.02 \
|
| 71 |
+
--seed 42 --eval-seed 20260830 >> "$LOG" 2>&1 &
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
overflow_count() { local n; n=$(grep -c "RecoverableAmpOverflow" "$LOG" 2>/dev/null | head -n 1); echo "${n:-0}"; }
|
| 75 |
+
|
| 76 |
+
restarts=0
|
| 77 |
+
seen_overflows=$(overflow_count)
|
| 78 |
+
if [ -f "$RUN_DIR/overflow_recovery.pt" ]; then
|
| 79 |
+
echo "[supervisor] resuming from an existing overflow_recovery.pt phase1=$PHASE1 sha=$PHASE1_SHA (prior overflows: $seen_overflows)"
|
| 80 |
+
launch resume
|
| 81 |
+
else
|
| 82 |
+
echo "[supervisor] fresh launch phase1=$PHASE1 sha=$PHASE1_SHA ddp=2 steps=$FINAL_STEP (prior overflows: $seen_overflows)"
|
| 83 |
+
launch fresh
|
| 84 |
+
fi
|
| 85 |
+
sleep 120
|
| 86 |
+
|
| 87 |
+
while true; do
|
| 88 |
+
if is_complete; then
|
| 89 |
+
echo "[supervisor] run complete (eval @$FINAL_STEP or early stop); exiting"
|
| 90 |
+
break
|
| 91 |
+
fi
|
| 92 |
+
if ! is_running; then
|
| 93 |
+
current=$(overflow_count)
|
| 94 |
+
if [ "$current" -gt "$seen_overflows" ]; then
|
| 95 |
+
if [ "$restarts" -ge "$MAX_RESTARTS" ]; then
|
| 96 |
+
echo "[supervisor] restart budget exhausted ($MAX_RESTARTS); exiting"
|
| 97 |
+
break
|
| 98 |
+
fi
|
| 99 |
+
if [ ! -f "$RUN_DIR/overflow_recovery.pt" ]; then
|
| 100 |
+
echo "[supervisor] overflow logged but no recovery checkpoint; exiting"
|
| 101 |
+
break
|
| 102 |
+
fi
|
| 103 |
+
restarts=$((restarts + 1))
|
| 104 |
+
seen_overflows=$current
|
| 105 |
+
echo "[supervisor] relaunch #$restarts from overflow_recovery.pt (overflows=$current)"
|
| 106 |
+
launch resume
|
| 107 |
+
sleep 120
|
| 108 |
+
else
|
| 109 |
+
echo "[supervisor] process died WITHOUT a new overflow; not restarting"
|
| 110 |
+
break
|
| 111 |
+
fi
|
| 112 |
+
fi
|
| 113 |
+
sleep 45
|
| 114 |
+
done
|
dataset/phase1_noise_20260906/code/sweep_v7_dose.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Dose sweep for a DGF-trained v7 checkpoint.
|
| 3 |
+
|
| 4 |
+
For each dose w: full validation (per-domain PSNR/SSIM) with the coarse-step
|
| 5 |
+
guidance x0 = x0(null) + w (x0(c) - x0(null)), plus an IDENTITY test where the
|
| 6 |
+
clean image is fed as input (PSNR(f(x), x) per domain — the "do nothing"
|
| 7 |
+
score). Writes one JSON with everything.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
from __future__ import annotations
|
| 11 |
+
|
| 12 |
+
import argparse
|
| 13 |
+
import functools
|
| 14 |
+
import json
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
from typing import Any, Dict
|
| 17 |
+
|
| 18 |
+
import torch
|
| 19 |
+
from torch.utils.data import DataLoader, Dataset
|
| 20 |
+
|
| 21 |
+
import train_phase2_graph_resshift_v4 as v4
|
| 22 |
+
import train_phase2_unified_v7 as v7
|
| 23 |
+
from src.data.phase2_v4 import Phase2PairDataset, load_train_val_manifest
|
| 24 |
+
from visualize_v7_uformer import _load_run_args
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class CleanAsInput(Dataset):
|
| 28 |
+
def __init__(self, base: Dataset) -> None:
|
| 29 |
+
self.base = base
|
| 30 |
+
|
| 31 |
+
def __len__(self) -> int:
|
| 32 |
+
return len(self.base)
|
| 33 |
+
|
| 34 |
+
def __getitem__(self, index: int):
|
| 35 |
+
item = dict(self.base[index])
|
| 36 |
+
item["degraded"] = item["clean"]
|
| 37 |
+
return item
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def _summary(result: Dict[str, Any]) -> Dict[str, float]:
|
| 41 |
+
restored = result.get("restored", result)
|
| 42 |
+
out = {
|
| 43 |
+
"macro_psnr": float(restored["macro_psnr"]),
|
| 44 |
+
"macro_ssim": float(restored["macro_ssim"]),
|
| 45 |
+
}
|
| 46 |
+
for domain, values in restored["per_domain"].items():
|
| 47 |
+
out[domain] = float(values["psnr"])
|
| 48 |
+
return out
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def main() -> None:
|
| 52 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 53 |
+
parser.add_argument("--run-dir", type=Path, required=True)
|
| 54 |
+
parser.add_argument("--doses", default="0,0.25,0.5,0.75,1,1.25")
|
| 55 |
+
parser.add_argument("--output", type=Path, required=True)
|
| 56 |
+
parser.add_argument("--skip-identity", action="store_true")
|
| 57 |
+
args = parser.parse_args()
|
| 58 |
+
|
| 59 |
+
run_args = _load_run_args(args.run_dir)
|
| 60 |
+
device = torch.device("cuda")
|
| 61 |
+
checkpoint = v4._torch_load(args.run_dir / "best.pt", map_location="cpu")
|
| 62 |
+
model = v7._build_v7_restorer(run_args, device)
|
| 63 |
+
model.load_state_dict(checkpoint["ema_state_dict"]["shadow"], strict=True)
|
| 64 |
+
model.eval()
|
| 65 |
+
phase1, _ = v4.build_frozen_phase1(
|
| 66 |
+
run_args.phase1_checkpoint, run_args.phase1_sha256, device
|
| 67 |
+
)
|
| 68 |
+
splits = load_train_val_manifest(run_args.manifest)
|
| 69 |
+
base = Phase2PairDataset(
|
| 70 |
+
splits.val, crop_size=run_args.crop_size, training=False, upscale_small=True
|
| 71 |
+
)
|
| 72 |
+
loader_kwargs = dict(batch_size=8, shuffle=False, num_workers=4, pin_memory=True)
|
| 73 |
+
val_loader = DataLoader(base, **loader_kwargs)
|
| 74 |
+
identity_loader = DataLoader(CleanAsInput(base), **loader_kwargs)
|
| 75 |
+
|
| 76 |
+
doses = [float(v) for v in args.doses.split(",")]
|
| 77 |
+
report: Dict[str, Any] = {"run_dir": str(args.run_dir), "step": int(checkpoint["step"])}
|
| 78 |
+
with v7._installed_v7_backend(run_args):
|
| 79 |
+
for dose in doses:
|
| 80 |
+
v4.sample_restoration = functools.partial(
|
| 81 |
+
v7.sample_unified_restoration, dose=dose
|
| 82 |
+
)
|
| 83 |
+
with torch.no_grad():
|
| 84 |
+
val = _summary(v4.evaluate(model, phase1, val_loader, device, int(run_args.eval_seed)))
|
| 85 |
+
entry = {"val": val}
|
| 86 |
+
if not args.skip_identity:
|
| 87 |
+
entry["identity"] = _summary(
|
| 88 |
+
v4.evaluate(model, phase1, identity_loader, device, int(run_args.eval_seed))
|
| 89 |
+
)
|
| 90 |
+
report["dose_%g" % dose] = entry
|
| 91 |
+
print("dose %g val %s" % (dose, json.dumps(val)), flush=True)
|
| 92 |
+
if "identity" in entry:
|
| 93 |
+
print(" identity %s" % json.dumps(entry["identity"]), flush=True)
|
| 94 |
+
args.output.write_text(json.dumps(report, indent=2, sort_keys=True))
|
| 95 |
+
print("WROTE", args.output)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
if __name__ == "__main__":
|
| 99 |
+
main()
|
dataset/phase1_noise_20260906/code/visualize_phase1_tsne.py
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""t-SNE / UMAP / PCA views of the Phase-1 degradation graph.
|
| 3 |
+
|
| 4 |
+
Three panels per embedding field:
|
| 5 |
+
(a) coloured by group — four degraded types, their clean GTs, real OOD
|
| 6 |
+
(Snow100K synthetic), locked rain, SIDD scene008;
|
| 7 |
+
(b) coloured by the severity of the image's top node (continuous);
|
| 8 |
+
(c) the GRAPH itself: the per-image pre-aggregation graph vector
|
| 9 |
+
sum_k routing_k (anchor_k(sev_k) + token_k)/sqrt2 + free part, embedded
|
| 10 |
+
JOINTLY with the 4 x 8 branch anchors, the clean root and the 2 free
|
| 11 |
+
node embeddings, so the ordered branches and the free cluster are
|
| 12 |
+
visible as geometry, not just as colours.
|
| 13 |
+
Plus a JSON of quantitative complements (silhouette, kNN purity,
|
| 14 |
+
trustworthiness, severity ordering per type, free-mass AUROC), because a
|
| 15 |
+
t-SNE picture alone proves nothing.
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
from __future__ import annotations
|
| 19 |
+
|
| 20 |
+
import argparse
|
| 21 |
+
import hashlib
|
| 22 |
+
import json
|
| 23 |
+
import math
|
| 24 |
+
from pathlib import Path
|
| 25 |
+
|
| 26 |
+
import numpy as np
|
| 27 |
+
import torch
|
| 28 |
+
|
| 29 |
+
import eval_full_frame as ff
|
| 30 |
+
import train_graph_encoder_v2 as p1
|
| 31 |
+
import train_phase2_graph_resshift_v4 as v4
|
| 32 |
+
|
| 33 |
+
TYPES = ("rain", "noise", "haze", "lowlight")
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def _sha256(path: Path) -> str:
|
| 37 |
+
digest = hashlib.sha256()
|
| 38 |
+
with open(path, "rb") as handle:
|
| 39 |
+
for block in iter(lambda: handle.read(1 << 20), b""):
|
| 40 |
+
digest.update(block)
|
| 41 |
+
return digest.hexdigest()
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def _center(t: torch.Tensor, size: int = 256) -> torch.Tensor:
|
| 45 |
+
h, w = t.shape[-2:]
|
| 46 |
+
top, left = max((h - size) // 2, 0), max((w - size) // 2, 0)
|
| 47 |
+
return t[..., top:top + size, left:left + size]
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def collect(phase1, records, name: str, per_group: int, device, which: str = "degraded"):
|
| 51 |
+
dataset = ff.FullFrameDataset(records[:per_group])
|
| 52 |
+
rows = []
|
| 53 |
+
with torch.no_grad():
|
| 54 |
+
for index in range(len(dataset)):
|
| 55 |
+
item = dataset[index]
|
| 56 |
+
crop = _center(item[which]).unsqueeze(0).to(device)
|
| 57 |
+
rep = phase1(crop)
|
| 58 |
+
rows.append({
|
| 59 |
+
"group": name,
|
| 60 |
+
"global": rep.global_condition[0].float().cpu().numpy(),
|
| 61 |
+
"unknown": rep.unknown_residual[0].float().cpu().numpy(),
|
| 62 |
+
"photo": getattr(rep, "photometric_state", torch.zeros(1, 1))[0].float().cpu().numpy(),
|
| 63 |
+
"tokens": rep.node_tokens[0].float().cpu().numpy(),
|
| 64 |
+
"routing": rep.routing_probs[0].float().cpu().numpy(),
|
| 65 |
+
"severity": rep.severity_coords[0].float().cpu().numpy(),
|
| 66 |
+
})
|
| 67 |
+
return rows
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def graph_vectors(encoder, rows):
|
| 71 |
+
"""Per-image pre-aggregation graph vector plus the graph's own anchors."""
|
| 72 |
+
branches = encoder.branches
|
| 73 |
+
with torch.no_grad():
|
| 74 |
+
anchors = [b.anchor_embeddings[0].float().cpu().numpy() for b in branches] # 4 x [8, D]
|
| 75 |
+
root = encoder.clean_root().float().cpu().numpy()[0]
|
| 76 |
+
free = encoder.free_nodes().float().cpu().numpy() # [2, D]
|
| 77 |
+
vectors = []
|
| 78 |
+
for r in rows:
|
| 79 |
+
tokens = torch.tensor(r["tokens"])
|
| 80 |
+
routing = torch.tensor(r["routing"])
|
| 81 |
+
sev = torch.tensor(r["severity"])
|
| 82 |
+
branch_embs = torch.stack([
|
| 83 |
+
branches[k].get_branch_embedding((sev[k] * branches[k].max_severity).view(1).to(branches[k].anchor_embeddings.device))[0, 0].float().cpu()
|
| 84 |
+
for k in range(len(branches))
|
| 85 |
+
])
|
| 86 |
+
semantic = (branch_embs + tokens[: len(branches)]) / math.sqrt(2.0)
|
| 87 |
+
vec = (routing[: len(branches)].unsqueeze(-1) * semantic).sum(0)
|
| 88 |
+
vec = vec + (routing[len(branches):].unsqueeze(-1) * tokens[len(branches):]).sum(0)
|
| 89 |
+
vectors.append(vec.numpy())
|
| 90 |
+
return np.stack(vectors), anchors, root, free
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def embed(x: np.ndarray, method: str, seed: int = 0) -> np.ndarray:
|
| 94 |
+
from sklearn.decomposition import PCA
|
| 95 |
+
from sklearn.preprocessing import StandardScaler
|
| 96 |
+
|
| 97 |
+
z = StandardScaler().fit_transform(x)
|
| 98 |
+
if method == "pca":
|
| 99 |
+
return PCA(n_components=2, random_state=seed).fit_transform(z)
|
| 100 |
+
if method == "umap":
|
| 101 |
+
import umap
|
| 102 |
+
|
| 103 |
+
return umap.UMAP(n_components=2, random_state=seed, n_neighbors=30, min_dist=0.1).fit_transform(z)
|
| 104 |
+
from sklearn.manifold import TSNE
|
| 105 |
+
|
| 106 |
+
perplexity = max(5, min(30, (len(z) - 1) // 3))
|
| 107 |
+
return TSNE(n_components=2, perplexity=perplexity, init="pca", random_state=seed).fit_transform(z)
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
def metrics(x: np.ndarray, emb: np.ndarray, groups: list, rows: list) -> dict:
|
| 111 |
+
from scipy.stats import spearmanr
|
| 112 |
+
from sklearn.decomposition import PCA
|
| 113 |
+
from sklearn.manifold import trustworthiness
|
| 114 |
+
from sklearn.metrics import roc_auc_score, silhouette_score
|
| 115 |
+
from sklearn.neighbors import NearestNeighbors
|
| 116 |
+
|
| 117 |
+
g = np.array(groups)
|
| 118 |
+
degraded = np.isin(g, TYPES)
|
| 119 |
+
out = {}
|
| 120 |
+
if degraded.sum() > 10 and len(set(g[degraded])) > 1:
|
| 121 |
+
out["silhouette_type_feature"] = float(silhouette_score(x[degraded], g[degraded]))
|
| 122 |
+
out["silhouette_type_embedding"] = float(silhouette_score(emb[degraded], g[degraded]))
|
| 123 |
+
knn = NearestNeighbors(n_neighbors=11).fit(x)
|
| 124 |
+
_, idx = knn.kneighbors(x)
|
| 125 |
+
out["knn10_purity_all_groups"] = float((g[idx[:, 1:]] == g[:, None]).mean())
|
| 126 |
+
out["trustworthiness_k10"] = float(trustworthiness(x, emb, n_neighbors=10))
|
| 127 |
+
free = np.array([r["routing"][len(TYPES):].sum() for r in rows])
|
| 128 |
+
is_null = np.array([gg.startswith("clean") or gg == "snow_ood" for gg in groups])
|
| 129 |
+
if is_null.any() and (~is_null).any():
|
| 130 |
+
out["free_mass_auroc_null_vs_degraded"] = float(roc_auc_score(is_null, free))
|
| 131 |
+
order = {}
|
| 132 |
+
for k, name in enumerate(TYPES):
|
| 133 |
+
mask = g == name
|
| 134 |
+
if mask.sum() > 10:
|
| 135 |
+
axis = PCA(n_components=1).fit_transform(x[mask])[:, 0]
|
| 136 |
+
sev = np.array([r["severity"][k] for r in rows])[mask]
|
| 137 |
+
rho = spearmanr(axis, sev).correlation
|
| 138 |
+
order[name] = float(abs(rho))
|
| 139 |
+
out["severity_ordering_abs_spearman_pc1"] = order
|
| 140 |
+
return out
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
def plot(emb, groups, sevs, anchors2d, root2d, free2d, title, path):
|
| 144 |
+
import matplotlib
|
| 145 |
+
|
| 146 |
+
matplotlib.use("Agg")
|
| 147 |
+
import matplotlib.pyplot as plt
|
| 148 |
+
|
| 149 |
+
g = np.array(groups)
|
| 150 |
+
palette = {"rain": "tab:blue", "noise": "tab:orange", "haze": "tab:green", "lowlight": "tab:red",
|
| 151 |
+
"clean_rain": "lightsteelblue", "clean_noise": "navajowhite", "clean_haze": "lightgreen",
|
| 152 |
+
"clean_lowlight": "lightcoral", "snow_ood": "black", "rain_locked": "royalblue", "scene008": "darkorange"}
|
| 153 |
+
fig, axes = plt.subplots(1, 3, figsize=(20, 6.2))
|
| 154 |
+
ax = axes[0]
|
| 155 |
+
for name in sorted(set(groups)):
|
| 156 |
+
m = g == name
|
| 157 |
+
ax.scatter(emb[m, 0], emb[m, 1], s=9, c=palette.get(name, "grey"), label="%s (%d)" % (name, m.sum()),
|
| 158 |
+
alpha=0.75, marker="x" if name.startswith("clean") else ("^" if name == "snow_ood" else "o"))
|
| 159 |
+
ax.set_title("%s — by group" % title); ax.legend(fontsize=7, markerscale=1.6, loc="best")
|
| 160 |
+
ax = axes[1]
|
| 161 |
+
sc = ax.scatter(emb[:, 0], emb[:, 1], s=9, c=sevs, cmap="viridis", vmin=0, vmax=1)
|
| 162 |
+
ax.set_title("severity of the top node"); fig.colorbar(sc, ax=ax, fraction=0.04)
|
| 163 |
+
ax = axes[2]
|
| 164 |
+
for name in sorted(set(groups)):
|
| 165 |
+
m = g == name
|
| 166 |
+
ax.scatter(emb[m, 0], emb[m, 1], s=6, c=palette.get(name, "grey"), alpha=0.35)
|
| 167 |
+
if anchors2d is not None:
|
| 168 |
+
for k, name in enumerate(TYPES):
|
| 169 |
+
a = anchors2d[k]
|
| 170 |
+
ax.plot(a[:, 0], a[:, 1], "-", c=palette[name], lw=2)
|
| 171 |
+
ax.scatter(a[:, 0], a[:, 1], s=40, c=palette[name], edgecolors="k", zorder=5)
|
| 172 |
+
ax.annotate(name + " branch", a[-1], fontsize=8)
|
| 173 |
+
ax.scatter(root2d[0], root2d[1], s=160, marker="*", c="gold", edgecolors="k", zorder=6, label="clean root")
|
| 174 |
+
ax.scatter(free2d[:, 0], free2d[:, 1], s=90, marker="s", c="white", edgecolors="k", zorder=6, label="free nodes")
|
| 175 |
+
ax.legend(fontsize=8)
|
| 176 |
+
ax.set_title("graph geometry (anchors, root, free nodes)")
|
| 177 |
+
for a in axes:
|
| 178 |
+
a.set_xticks([]); a.set_yticks([])
|
| 179 |
+
fig.tight_layout(); fig.savefig(path, dpi=140); plt.close(fig)
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
def main() -> None:
|
| 183 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 184 |
+
parser.add_argument("--checkpoint", type=Path, default=Path("outputs/phase1_v5f/graph_encoder_best.pt"))
|
| 185 |
+
parser.add_argument("--output-dir", type=Path, default=Path("outputs/phase1_tsne"))
|
| 186 |
+
parser.add_argument("--per-group", type=int, default=100)
|
| 187 |
+
parser.add_argument("--ood-count", type=int, default=200)
|
| 188 |
+
parser.add_argument("--methods", default="tsne,umap,pca")
|
| 189 |
+
parser.add_argument("--seed", type=int, default=0)
|
| 190 |
+
parser.add_argument("--ood-root", type=Path, default=None,
|
| 191 |
+
help="folder of real-unknown images (default: <data-root>/Snow100K/train/all/synthetic)")
|
| 192 |
+
args = parser.parse_args()
|
| 193 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 194 |
+
phase1, _ = v4.build_frozen_phase1(args.checkpoint, _sha256(args.checkpoint), device)
|
| 195 |
+
encoder = phase1.encoder
|
| 196 |
+
|
| 197 |
+
p1_args = p1.build_parser().parse_args([])
|
| 198 |
+
splits = p1.build_data_splits(p1_args)
|
| 199 |
+
rows = []
|
| 200 |
+
for name in TYPES:
|
| 201 |
+
recs = [r for r in splits.val if r.degradation == name]
|
| 202 |
+
rows += collect(phase1, recs, name, args.per_group, device, "degraded")
|
| 203 |
+
rows += collect(phase1, recs, "clean_" + name, args.per_group, device, "clean")
|
| 204 |
+
rows += collect(phase1, [r for r in splits.locked_test if r.degradation == "rain"], "rain_locked", args.per_group, device)
|
| 205 |
+
rows += collect(phase1, [r for r in splits.locked_test if r.degradation == "noise"], "scene008", 20, device)
|
| 206 |
+
ood_root = args.ood_root or Path(p1_args.data_root) / "Snow100K/train/all/synthetic"
|
| 207 |
+
if ood_root.is_dir():
|
| 208 |
+
from src.data.folder_crops import FolderCropDataset, list_image_files
|
| 209 |
+
|
| 210 |
+
files = list_image_files(ood_root)
|
| 211 |
+
step = max(len(files) // args.ood_count, 1)
|
| 212 |
+
ds = FolderCropDataset(files[::step][: args.ood_count], size=256, deterministic=True)
|
| 213 |
+
with torch.no_grad():
|
| 214 |
+
for index in range(len(ds)):
|
| 215 |
+
rep = phase1(ds[index].unsqueeze(0).to(device))
|
| 216 |
+
rows.append({"group": "snow_ood", "global": rep.global_condition[0].float().cpu().numpy(),
|
| 217 |
+
"unknown": rep.unknown_residual[0].float().cpu().numpy(),
|
| 218 |
+
"photo": getattr(rep, "photometric_state", torch.zeros(1, 1))[0].float().cpu().numpy(),
|
| 219 |
+
"tokens": rep.node_tokens[0].float().cpu().numpy(),
|
| 220 |
+
"routing": rep.routing_probs[0].float().cpu().numpy(),
|
| 221 |
+
"severity": rep.severity_coords[0].float().cpu().numpy()})
|
| 222 |
+
groups = [r["group"] for r in rows]
|
| 223 |
+
sevs = np.array([r["severity"][int(np.argmax(r["routing"][:4]))] if np.argmax(r["routing"]) < 4 else 0.0 for r in rows])
|
| 224 |
+
args.output_dir.mkdir(parents=True, exist_ok=True)
|
| 225 |
+
report = {"n": len(rows), "groups": {g: int(np.sum(np.array(groups) == g)) for g in set(groups)}}
|
| 226 |
+
graph_x, anchors, root, free = graph_vectors(encoder, rows)
|
| 227 |
+
fields = {
|
| 228 |
+
"global_condition": np.stack([r["global"] for r in rows]),
|
| 229 |
+
"unknown_residual": np.stack([r["unknown"] for r in rows]),
|
| 230 |
+
"graph_vector": graph_x,
|
| 231 |
+
}
|
| 232 |
+
for method in [m.strip() for m in args.methods.split(",") if m.strip()]:
|
| 233 |
+
for field, x in fields.items():
|
| 234 |
+
if field == "graph_vector":
|
| 235 |
+
extra = np.concatenate([np.concatenate(anchors), root[None], free])
|
| 236 |
+
joint = embed(np.concatenate([x, extra]), method, args.seed)
|
| 237 |
+
emb, e = joint[: len(x)], joint[len(x):]
|
| 238 |
+
anchors2d = [e[k * 8:(k + 1) * 8] for k in range(4)]
|
| 239 |
+
root2d, free2d = e[32], e[33:35]
|
| 240 |
+
else:
|
| 241 |
+
emb, anchors2d, root2d, free2d = embed(x, method, args.seed), None, None, None
|
| 242 |
+
path = args.output_dir / ("%s_%s.png" % (method, field))
|
| 243 |
+
plot(emb, groups, sevs, anchors2d, root2d, free2d, "%s / %s" % (method, field), path)
|
| 244 |
+
report["%s/%s" % (method, field)] = metrics(x, emb, groups, rows)
|
| 245 |
+
print(method, field, json.dumps(report["%s/%s" % (method, field)]), flush=True)
|
| 246 |
+
(args.output_dir / "report.json").write_text(json.dumps(report, indent=2))
|
| 247 |
+
print("WROTE", args.output_dir)
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
if __name__ == "__main__":
|
| 251 |
+
main()
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/.gitattributes
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Auto detect text files and perform LF normalization
|
| 2 |
+
* text=auto
|
| 3 |
+
|
| 4 |
+
# Custom for Visual Studio
|
| 5 |
+
*.cs diff=csharp
|
| 6 |
+
|
| 7 |
+
# Standard to msysgit
|
| 8 |
+
*.doc diff=astextplain
|
| 9 |
+
*.DOC diff=astextplain
|
| 10 |
+
*.docx diff=astextplain
|
| 11 |
+
*.DOCX diff=astextplain
|
| 12 |
+
*.dot diff=astextplain
|
| 13 |
+
*.DOT diff=astextplain
|
| 14 |
+
*.pdf diff=astextplain
|
| 15 |
+
*.PDF diff=astextplain
|
| 16 |
+
*.rtf diff=astextplain
|
| 17 |
+
*.RTF diff=astextplain
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/.gitignore
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Windows image file caches
|
| 2 |
+
Thumbs.db
|
| 3 |
+
ehthumbs.db
|
| 4 |
+
|
| 5 |
+
# Folder config file
|
| 6 |
+
Desktop.ini
|
| 7 |
+
|
| 8 |
+
# Recycle Bin used on file shares
|
| 9 |
+
$RECYCLE.BIN/
|
| 10 |
+
|
| 11 |
+
# Windows Installer files
|
| 12 |
+
*.cab
|
| 13 |
+
*.msi
|
| 14 |
+
*.msm
|
| 15 |
+
*.msp
|
| 16 |
+
|
| 17 |
+
# Windows shortcuts
|
| 18 |
+
*.lnk
|
| 19 |
+
|
| 20 |
+
# =========================
|
| 21 |
+
# Operating System Files
|
| 22 |
+
# =========================
|
| 23 |
+
|
| 24 |
+
# OSX
|
| 25 |
+
# =========================
|
| 26 |
+
|
| 27 |
+
.DS_Store
|
| 28 |
+
.AppleDouble
|
| 29 |
+
.LSOverride
|
| 30 |
+
|
| 31 |
+
# Thumbnails
|
| 32 |
+
._*
|
| 33 |
+
|
| 34 |
+
# Files that might appear in the root of a volume
|
| 35 |
+
.DocumentRevisions-V100
|
| 36 |
+
.fseventsd
|
| 37 |
+
.Spotlight-V100
|
| 38 |
+
.TemporaryItems
|
| 39 |
+
.Trashes
|
| 40 |
+
.VolumeIcon.icns
|
| 41 |
+
|
| 42 |
+
# Directories potentially created on remote AFP share
|
| 43 |
+
.AppleDB
|
| 44 |
+
.AppleDesktop
|
| 45 |
+
Network Trash Folder
|
| 46 |
+
Temporary Items
|
| 47 |
+
.apdisk
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/ChangeLog.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
07 Apr. 2018 - 1.0
|
| 2 |
+
- Initial release
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_bicycle_8_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_bicycle_8_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_desk_4_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_desk_5_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_desk_5_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_desk_7_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_reciever_2_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_reciever_2_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_reciever_4_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_160_6400_reciever_4_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_200_3200_toy_1_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_200_3200_toy_1_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon5D2_5_200_3200_toy_3_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon600D_3-5_125_1600_waterhouse_10_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon600D_3-5_125_1600_waterhouse_11_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon600D_3-5_125_1600_waterhouse_12_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon600D_4-5_125_1600_toy_13_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon600D_4-5_125_1600_toy_16_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon600D_4-5_125_1600_toy_3_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon80D_8_8_12800_printer_11_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon80D_8_8_3200_ball_2_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon80D_8_8_3200_ball_6_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/Canon80D_8_8_800_GO_11_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_11_160_3200_classroom_15_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_11_160_3200_classroom_4_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_4-5_160_1800_classroom_15_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_4-5_160_1800_classroom_5_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_4-5_160_1800_classroom_9_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_5-6_160_6400_wall_2_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_5-6_160_6400_wall_2_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_5-6_160_6400_wall_9_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_5_100_4000_flower_15_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_5_100_4000_flower_2_mean.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_5_125_6400_stair_7_real.JPG
ADDED
|
|
dataset/phase1_noise_20260906/polyu_original/PolyU-Real-World-Noisy-Images-Dataset-3af0f2646b267a00446fe4b7113a15e67bc80b4e/CroppedImages/NikonD800_6-3_125_5000_plant_1_real.JPG
ADDED
|
|