depth_fm.viz.train_viz¶
train_viz ¶
Publication-quality visualization for Mars DepthFM.
All figures follow NeurIPS style guidelines: - 300 DPI minimum - Seaborn 'flare' palette as default warm colormap - 'mako' for cool sequential (elevation) - Readable font sizes (≥8pt for labels, ≥10pt for axes) - Vector-friendly (PDF/SVG output)
Figure catalogue
- Prediction triptych: input image | predicted DTM | GT DTM
- Cross-sectional profiles: 4 directional slices through the heightmap
- Error heatmap: per-pixel absolute error with statistics
- Flow evolution: intermediate predictions at t = 0, 0.25, 0.5, 0.75, 1.0
- Metric distributions: violin/box plots across test set
- Multi-run convergence: loss curves with error bands
- Worst/best patch gallery: identifying failure and success modes
- Normal map comparison: predicted vs GT surface normals
- Slope histogram: distribution of slope errors
- Scatter plot: predicted vs GT elevation for a representative patch
set_neurips_style ¶
compute_surface_normals ¶
Compute surface normals with proper spatial scaling.
Source code in src/depth_fm/viz/train_viz.py
plot_prediction_triptych ¶
plot_prediction_triptych(image: ndarray, pred_dtm: ndarray, gt_dtm: ndarray, title: str = '', save_path: str | Path | None = None, mask: ndarray | None = None) -> plt.Figure
Three-panel figure: input orthoimage | predicted DTM | GT DTM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
ndarray
|
(H, W) or (H, W, 3) input orthoimage |
required |
pred_dtm
|
ndarray
|
(H, W) predicted elevation |
required |
gt_dtm
|
ndarray
|
(H, W) ground-truth elevation |
required |
mask
|
ndarray | None
|
optional (H, W) valid-data mask; invalid pixels shown as NaN |
None
|
Source code in src/depth_fm/viz/train_viz.py
plot_cross_sections ¶
plot_cross_sections(pred_dtm: ndarray, gt_dtm: ndarray, title: str = '', save_path: str | Path | None = None, mask: ndarray | None = None) -> plt.Figure
Four directional cross-sections through the heightmap centre.
Directions: horizontal (→), vertical (↓), diagonal NW→SE (↘), diagonal NE→SW (↙).
Source code in src/depth_fm/viz/train_viz.py
plot_error_heatmap ¶
plot_error_heatmap(pred_dtm: ndarray, gt_dtm: ndarray, title: str = '', save_path: str | Path | None = None, mask: ndarray | None = None) -> plt.Figure
Per-pixel absolute error map with marginal statistics.
Source code in src/depth_fm/viz/train_viz.py
plot_flow_evolution ¶
plot_flow_evolution(intermediates: dict[float, ndarray], gt_dtm: ndarray, title: str = 'Flow matching evolution', save_path: str | Path | None = None, mask: ndarray | None = None) -> plt.Figure
Show predicted DTM at multiple ODE timesteps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intermediates
|
dict[float, ndarray]
|
dict mapping t → (H, W) predicted depth at that timestep. Example: {0.0: z_img, 0.25: ..., 0.5: ..., 0.75: ..., 1.0: z_pred} |
required |
gt_dtm
|
ndarray
|
(H, W) ground-truth |
required |
mask
|
ndarray | None
|
optional (H, W) valid-data mask |
None
|
Source code in src/depth_fm/viz/train_viz.py
plot_metric_distributions ¶
plot_metric_distributions(metrics_df, metrics_to_plot: list[str] | None = None, title: str = 'Test set metric distributions', save_path: str | Path | None = None) -> plt.Figure
Violin + strip plots for each metric across the test set.
Source code in src/depth_fm/viz/train_viz.py
plot_convergence_curves ¶
plot_convergence_curves(run_histories: list[dict[str, list[float]]], metric_key: str = 'val/rmse', title: str = 'Training convergence', save_path: str | Path | None = None) -> plt.Figure
Loss/metric curves across multiple runs with mean ± std shading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_histories
|
list[dict[str, list[float]]]
|
list of dicts, each mapping metric_key → list of values at each validation step. |
required |
Source code in src/depth_fm/viz/train_viz.py
plot_patch_gallery ¶
plot_patch_gallery(patches: list[dict], title: str = 'Patch gallery', save_path: str | Path | None = None) -> plt.Figure
Grid of patches: each row = [image, pred, GT, error].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
patches
|
list[dict]
|
list of dicts with keys "image", "pred", "gt", "tile_id", "rmse", and optionally "mask" (valid-data mask per patch). |
required |
Source code in src/depth_fm/viz/train_viz.py
plot_normal_maps ¶
plot_normal_maps(pred_dtm: ndarray, gt_dtm: ndarray, title: str = '', save_path: str | Path | None = None, mask: ndarray | None = None) -> plt.Figure
Side-by-side surface normal maps (RGB-encoded) with spatial scaling.
Source code in src/depth_fm/viz/train_viz.py
plot_elevation_scatter ¶
plot_elevation_scatter(pred_dtm: ndarray, gt_dtm: ndarray, title: str = '', save_path: str | Path | None = None, subsample: int = 5000, mask: ndarray | None = None) -> plt.Figure
Scatter plot of predicted vs GT elevation with density coloring.
Source code in src/depth_fm/viz/train_viz.py
plot_multi_run_summary_table ¶
plot_multi_run_summary_table(run_summaries: list[dict[str, dict[str, float]]], metrics_to_show: list[str] | None = None, title: str = 'Multi-run test set results', save_path: str | Path | None = None) -> plt.Figure
Bar chart with error bars showing mean ± std across runs.
Source code in src/depth_fm/viz/train_viz.py
compute_hillshade ¶
compute_hillshade(elevation: ndarray, azimuth_deg: float = 315.0, altitude_deg: float = 45.0, z_factor: float = 1.0) -> np.ndarray
Compute an analytical hillshade from an elevation grid.
Uses the standard ESRI/GDAL algorithm: shade = cos(zenith) * cos(slope) + sin(zenith) * sin(slope) * cos(azimuth - aspect)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elevation
|
ndarray
|
(H, W) float32 elevation in metres. |
required |
azimuth_deg
|
float
|
Solar azimuth (compass bearing of the sun), degrees. 315° = NW illumination (standard planetary science convention). |
315.0
|
altitude_deg
|
float
|
Solar altitude above the horizon, degrees. 45° is typical for planetary DTM display. |
45.0
|
z_factor
|
float
|
Vertical exaggeration factor. Values > 1 emphasise relief. |
1.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
(H, W) float32 in [0, 1] where 1 = fully illuminated. |
Source code in src/depth_fm/viz/train_viz.py
plot_hillshade_comparison ¶
plot_hillshade_comparison(pred_dtm: ndarray, gt_dtm: ndarray, azimuth: float = 315.0, altitude: float = 45.0, z_factor: float = 2.0, title: str = '', save_path: str | Path | None = None) -> plt.Figure
Side-by-side hillshade rendering of predicted vs GT DTMs.
This is the standard planetary science visualisation for DTMs. Synthetic solar illumination reveals fine-scale terrain features (crater rims, ridges, dune textures) that are invisible in elevation-coloured maps.
A third panel shows the hillshade difference, which highlights exactly where the predicted surface normals diverge from ground truth: bright spots = predicted slope faces the sun more; dark = less.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pred_dtm
|
ndarray
|
(H, W) predicted elevation (will be affine-aligned to GT). |
required |
gt_dtm
|
ndarray
|
(H, W) ground-truth elevation. |
required |
azimuth
|
float
|
Solar azimuth in degrees (315 = NW, standard for Mars). |
315.0
|
altitude
|
float
|
Solar altitude in degrees. |
45.0
|
z_factor
|
float
|
Vertical exaggeration (2.0 emphasises subtle terrain). |
2.0
|
Source code in src/depth_fm/viz/train_viz.py
plot_lunar_lambert_comparison ¶
plot_lunar_lambert_comparison(pred_dtm: Union[Tensor, ndarray], gt_dtm: Union[Tensor, ndarray], real_ortho: Union[Tensor, ndarray], sun_vector: Union[Tensor, ndarray], intensity: Union[Tensor, ndarray, float], ambient: Union[Tensor, ndarray, float], loss_fn: 'PhotoclinometricLoss', valid_mask: Union[Tensor, ndarray, None] = None, title: str = '', save_path: Union[str, Path, None] = None) -> plt.Figure
Type-Agnostic PyTorch Lunar-Lambert diagnostic. Seamlessly handles both NumPy arrays and PyTorch tensors, automatically expanding shapes to (B, C, H, W) for the loss function's internal math.
Source code in src/depth_fm/viz/train_viz.py
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 | |
plot_timestep_ablation ¶
plot_timestep_ablation(step_counts: list[int], metrics_per_step: dict[int, dict[str, dict[str, float]]], primary_metric: str = 'rmse', secondary_metrics: list[str] | None = None, title: str = 'Inference quality vs Euler steps', save_path: str | Path | None = None) -> plt.Figure
Plot RMSE (and other metrics) as a function of the number of Euler ODE steps.
DepthFM's key claim is that 1-step inference is nearly as good as multi-step. This figure tests whether that holds on Mars terrain, which has higher-frequency detail than the Earth scenes DepthFM was evaluated on.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step_counts
|
list[int]
|
sorted list of step counts evaluated, e.g. [1, 2, 4, 8, 10, 20]. |
required |
metrics_per_step
|
dict[int, dict[str, dict[str, float]]]
|
dict mapping step_count → MetricsAggregator.summary(). Each summary is a dict of metric_name → {"mean": ..., "std": ...}. |
required |
primary_metric
|
str
|
metric plotted on the left y-axis (default "rmse"). |
'rmse'
|
secondary_metrics
|
list[str] | None
|
metrics plotted on the right y-axis. |
None
|
Source code in src/depth_fm/viz/train_viz.py
1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 | |
plot_uncertainty_map ¶
plot_uncertainty_map(pred_dtm: ndarray, var_dtm: ndarray, img: ndarray, title: str = 'Epistemic Uncertainty', save_path: str | Path | None = None, mask: ndarray | None = None) -> plt.Figure
Triptych: Input Image | Predicted DTM | Epistemic Variance (Uncertainty).
Source code in src/depth_fm/viz/train_viz.py
plot_geomorphometric_analysis ¶
plot_geomorphometric_analysis(pred_dtm: ndarray, gt_dtm: ndarray, title: str = 'Geomorphometric Analysis: Edges & Curvature', save_path: str | Path | None = None, mask: ndarray | None = None) -> plt.Figure
Triptych: Edge Boundaries | Predicted Laplacian | Error in Laplacian.
Source code in src/depth_fm/viz/train_viz.py
1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 | |
plot_radial_psd_curves ¶
plot_radial_psd_curves(pred_dtm: ndarray, gt_dtm: ndarray, valid_mask: ndarray | None = None, title: str = 'Radial Power Spectral Density', save_path: str | Path | None = None, mask: ndarray | None = None) -> plt.Figure
Log-log plot of radial PSD comparing synthetic vs true terrain frequencies.
Source code in src/depth_fm/viz/train_viz.py
1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 | |
plot_pareto_frontier ¶
plot_pareto_frontier(metrics_per_step: dict[int, dict[str, dict[str, float]]], primary_metric: str = 'rmse', title: str = 'Compute vs. Accuracy Pareto Frontier', save_path: str | Path | None = None) -> plt.Figure
Plots Error against Number of Function Evaluations (NFE).
Source code in src/depth_fm/viz/train_viz.py
plot_slope_error_map ¶
plot_slope_error_map(pred_dtm: ndarray, gt_dtm: ndarray, img: ndarray, title: str = 'Geomorphometric DoD (Slope Error)', save_path: str | Path | None = None, mask: ndarray | None = None) -> plt.Figure
Triptych: Ortho | GT Slope | Absolute Slope Error.
Source code in src/depth_fm/viz/train_viz.py
1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 | |