|
|
d920863a0c
|
fix: Goodman 流式处理 — 逐波段写入磁盘杜绝 OOM
问题: 6522×13215×150 大影像处理到第 142 波段时崩溃
'Unable to allocate 329. MiB for an array'
根因: _get_corrected_bands_gdal 将全部 150 个波段累积在
corrected_bands 列表中 (≈46 GB),内存耗尽。
修复 (Goodman.py):
- _get_corrected_bands_gdal(): 新增 out_dataset 参数,
流式模式下每处理完一个波段立即 WriteArray→FlushCache→del
- 新增 _get_corrected_bands_streaming(): 创建输出文件后
调用流式处理,内存峰值 ≈ 3 波段 (NIR×2 + 当前) ≈ 1 GB
- get_corrected_bands(): output_path 已设置时自动走流式模式
- 原 _get_corrected_bands_numpy() 和 _gdal_mem() 的
output_path=None 路径保持向后兼容
修复 (glint_removal_step.py):
- corrected_bands 为 None 时跳过 _save_bands_as_image
(流式模式已直接写入磁盘)
性能微优化:
- corrected = R - R_750 → += self.A → += self.B*diff (原地)
- del R_640 提早释放
- WriteArray + FlushCache 确保数据及时落盘
|
2026-07-07 14:10:47 +08:00 |
|