Mega-1.1 全链路路径归一化收尾(18 文件)
This commit is contained in:
@ -903,7 +903,7 @@ if __name__ == '__main__':
|
||||
output_path = r"E:\code\WQ\封装\test/yangdian_output.csv" # CSV格式输出文件路径
|
||||
|
||||
radius = 5 # 采样半径(像素),0表示单点采样,>0表示半径内平均
|
||||
flare_path = r"E:\code\WQ\封装\work_dir\2_glint\severe_glint_area.dat" # 耀斑掩膜文件路径(可选,None表示不使用)
|
||||
flare_path = r"E:\code\WQ\封装\work_dir\2_Glint_Detection\severe_glint_area.dat" # 耀斑掩膜文件路径(可选,None表示不使用)
|
||||
boundary_path ="D:\BaiduNetdiskDownload\yaobao\water_mask.dat" # 边界掩膜文件路径(可选,None表示不使用)
|
||||
source_epsg = 4326 # 源坐标系EPSG代码,默认为4326 (WGS84地理坐标系)
|
||||
|
||||
|
||||
@ -810,7 +810,7 @@ if __name__ == '__main__':
|
||||
output_path = r"E:\code\WQ\封装\work_dir\5_training_spectra/yangdian_output.csv" # CSV格式输出文件路径
|
||||
|
||||
radius = 5 # 采样半径(像素),0表示单点采样,>0表示半径内平均
|
||||
flare_path = r"E:\code\WQ\封装\work_dir\2_glint\severe_glint_area.dat" # 耀斑掩膜文件路径(可选,None表示不使用)
|
||||
flare_path = r"E:\code\WQ\封装\work_dir\2_Glint_Detection\severe_glint_area.dat" # 耀斑掩膜文件路径(可选,None表示不使用)
|
||||
boundary_path = r"D:\BaiduNetdiskDownload\yaobao\water_mask.dat" # 边界掩膜文件路径(可选,None表示不使用)
|
||||
source_epsg = 4326 # 源坐标系EPSG代码,默认为4326 (WGS84地理坐标系)
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ PIPELINE_STEPS: List[StepSpec] = [
|
||||
step_id="step2", method_name="step2_find_glint_area",
|
||||
requires=["img_path", "water_mask_path"], produces=["glint_mask_path"],
|
||||
required_input_files=["img_path", "water_mask_path"],
|
||||
output_file="{work_dir}/2_glint/glint_mask.dat",
|
||||
output_file="{work_dir}/2_Glint_Detection/severe_glint_area.dat",
|
||||
description="耀斑区域检测",
|
||||
),
|
||||
StepSpec(
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
"""
|
||||
自定义回归预测模块
|
||||
|
||||
该模块根据9_Custom_Regression_Modeling文件夹中的CSV信息,批量预测水质指数。
|
||||
该模块根据13_Custom_Regression文件夹中的CSV信息,批量预测水质指数。
|
||||
处理流程:
|
||||
1. 读取9_Custom_Regression_Modeling文件夹中的CSV文件
|
||||
1. 读取13_Custom_Regression文件夹中的CSV文件
|
||||
2. 根据r_squared选择最佳模型(指数公式+反演公式)
|
||||
3. 使用指数公式计算光谱指数值
|
||||
4. 使用反演公式计算水质参数值
|
||||
@ -38,12 +38,12 @@ class CustomRegressionPredictor:
|
||||
"""
|
||||
自定义回归预测器
|
||||
|
||||
基于9_Custom_Regression_Modeling文件夹中的回归模型CSV文件,
|
||||
基于13_Custom_Regression文件夹中的回归模型CSV文件,
|
||||
进行水质参数的批量预测。
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
regression_models_dir: str = "9_Custom_Regression_Modeling",
|
||||
regression_models_dir: str = "13_Custom_Regression",
|
||||
formula_csv_path: Optional[str] = None,
|
||||
output_dir: str = "prediction_results",
|
||||
log_level: int = logging.INFO):
|
||||
@ -102,7 +102,7 @@ class CustomRegressionPredictor:
|
||||
|
||||
def load_regression_models(self) -> Dict[str, pd.DataFrame]:
|
||||
"""
|
||||
加载9_Custom_Regression_Modeling文件夹中的所有CSV文件
|
||||
加载13_Custom_Regression文件夹中的所有CSV文件
|
||||
|
||||
支持的CSV格式:
|
||||
- 回归结果CSV包含列:y_variable, x_variable, equation, r_squared
|
||||
@ -621,7 +621,7 @@ def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description='自定义回归预测模块')
|
||||
parser.add_argument('--input_csv', required=True, help='输入的光谱采样CSV文件路径')
|
||||
parser.add_argument('--models_dir', default='9_Custom_Regression_Modeling',
|
||||
parser.add_argument('--models_dir', default='13_Custom_Regression',
|
||||
help='回归模型CSV文件目录')
|
||||
parser.add_argument('--output_dir', default='prediction_results',
|
||||
help='预测结果输出目录')
|
||||
|
||||
@ -28,7 +28,7 @@ class GlintDetectionStep:
|
||||
max_area: Optional[int] = None,
|
||||
buffer_size: Optional[int] = None,
|
||||
water_mask_path: Optional[str] = None,
|
||||
glint_dir: Union[str, Path] = "./2_glint",
|
||||
glint_dir: Union[str, Path] = "./2_Glint_Detection",
|
||||
callback: Optional[callable] = None,
|
||||
) -> str:
|
||||
"""
|
||||
|
||||
@ -362,7 +362,7 @@ class ModelingStep:
|
||||
raise ValueError(f"因变量列不存在: {missing_y}")
|
||||
|
||||
if output_dir is None:
|
||||
custom_regression_dir = Path(work_dir) / "9_Custom_Regression_Modeling"
|
||||
custom_regression_dir = Path(work_dir) / "13_Custom_Regression"
|
||||
else:
|
||||
custom_regression_dir = Path(work_dir) / output_dir
|
||||
custom_regression_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@ -105,7 +105,7 @@ class PredictionStep:
|
||||
models_dir: Optional[str] = None,
|
||||
metric: str = "test_r2",
|
||||
prediction_column: str = "prediction",
|
||||
output_dir: Union[str, Path] = "./11_12_13_predictions/Machine_Learning_Prediction",
|
||||
output_dir: Union[str, Path] = "./9_ML_Prediction",
|
||||
callback: Optional[Callable] = None,
|
||||
_report_generator=None,
|
||||
_external_model=None,
|
||||
@ -363,14 +363,14 @@ class PredictionStep:
|
||||
if custom_regression_dir is not None:
|
||||
final_regression_dir = custom_regression_dir
|
||||
else:
|
||||
final_regression_dir = str(Path(work_dir) / "9_Custom_Regression_Modeling")
|
||||
final_regression_dir = str(Path(work_dir) / "13_Custom_Regression")
|
||||
if not Path(final_regression_dir).exists():
|
||||
raise ValueError(
|
||||
"请先执行步骤6.75: 自定义回归分析,或提供 custom_regression_dir 参数"
|
||||
)
|
||||
|
||||
if output_dir is None:
|
||||
custom_regression_prediction_dir = Path(work_dir) / "11_12_13_predictions" / "Custom_Regression_Prediction"
|
||||
custom_regression_prediction_dir = Path(work_dir) / "13_Custom_Regression" / "Custom_Regression_Prediction"
|
||||
custom_regression_prediction_dir.mkdir(parents=True, exist_ok=True)
|
||||
prediction_output_dir = str(custom_regression_prediction_dir)
|
||||
else:
|
||||
|
||||
@ -16,12 +16,12 @@ def generate_glint_deglint_previews(
|
||||
output_dir: Optional[str] = None
|
||||
) -> Dict[str, str]:
|
||||
"""
|
||||
生成2_glint和3_deglint文件夹中影像文件的PNG预览图
|
||||
生成2_Glint_Detection和3_deglint文件夹中影像文件的PNG预览图
|
||||
|
||||
Args:
|
||||
work_dir: 工作目录
|
||||
output_subdir: 输出子目录名称
|
||||
generate_glint: 是否处理2_glint文件夹
|
||||
generate_glint: 是否处理2_Glint_Detection文件夹
|
||||
generate_deglint: 是否处理3_deglint文件夹
|
||||
output_dir: 输出目录(None则使用默认)
|
||||
|
||||
|
||||
@ -136,14 +136,14 @@ class WaterQualityInversionPipeline:
|
||||
|
||||
# 创建子目录
|
||||
self.water_mask_dir = self.work_dir / "1_water_mask"
|
||||
self.glint_dir = self.work_dir / "2_glint"
|
||||
self.glint_dir = self.work_dir / "2_Glint_Detection"
|
||||
self.deglint_dir = self.work_dir / "3_deglint"
|
||||
self.processed_data_dir = self.work_dir / "4_processed_data"
|
||||
self.training_spectra_dir = self.work_dir / "5_training_spectra"
|
||||
self.indices_dir = self.work_dir / "6_water_quality_indices"
|
||||
self.models_dir = self.work_dir / "7_Supervised_Model_Training"
|
||||
self.non_empirical_models_dir = self.work_dir / "8_Regression_Modeling"
|
||||
self.custom_regression_dir = self.work_dir / "9_Custom_Regression_Modeling"
|
||||
self.custom_regression_dir = self.work_dir / "13_Custom_Regression"
|
||||
self.sampling_dir = self.work_dir / "4_sampling"
|
||||
self.prediction_dir = self.work_dir / "11_12_13_predictions"
|
||||
self.visualization_dir = self.work_dir / "14_visualization"
|
||||
@ -936,7 +936,7 @@ class WaterQualityInversionPipeline:
|
||||
models_dir=models_dir if models_dir else str(self.models_dir),
|
||||
metric=metric,
|
||||
prediction_column=prediction_column,
|
||||
output_dir=str(self.prediction_dir / "Machine_Learning_Prediction"),
|
||||
output_dir=str(self.prediction_dir / "9_ML_Prediction"),
|
||||
_report_generator=self.report_generator,
|
||||
_external_model=_external_model,
|
||||
_external_model_path=_external_model_path,
|
||||
@ -1429,12 +1429,12 @@ class WaterQualityInversionPipeline:
|
||||
generate_glint: bool = True,
|
||||
generate_deglint: bool = True) -> Dict[str, str]:
|
||||
"""
|
||||
生成2_glint和3_deglint文件夹中影像文件的PNG预览图
|
||||
|
||||
生成2_Glint_Detection和3_deglint文件夹中影像文件的PNG预览图
|
||||
|
||||
Args:
|
||||
work_dir: 工作目录(如果为None,则使用self.work_dir)
|
||||
output_subdir: 输出子目录名称
|
||||
generate_glint: 是否处理2_glint文件夹
|
||||
generate_glint: 是否处理2_Glint_Detection文件夹
|
||||
generate_deglint: 是否处理3_deglint文件夹
|
||||
|
||||
Returns:
|
||||
@ -2158,12 +2158,12 @@ class WaterQualityInversionPipeline:
|
||||
"""
|
||||
步骤12: 使用自定义回归模型进行参数预测
|
||||
|
||||
使用新的CustomRegressionPredictor模块,基于9_Custom_Regression_Modeling文件夹中的CSV,
|
||||
使用新的CustomRegressionPredictor模块,基于13_Custom_Regression文件夹中的CSV,
|
||||
根据r_squared选择最佳模型,批量预测水质参数
|
||||
|
||||
Args:
|
||||
sampling_csv_path: 采样点光谱数据CSV路径(来自步骤10)
|
||||
custom_regression_dir: 自定义回归模型目录(9_Custom_Regression_Modeling)
|
||||
custom_regression_dir: 自定义回归模型目录(13_Custom_Regression)
|
||||
formula_csv_path: 公式CSV文件路径,用于查找index_formula
|
||||
coordinate_columns: 坐标列名列表,默认为['longitude', 'latitude']或自动识别
|
||||
output_dir: 输出目录,默认为prediction_dir
|
||||
@ -2319,7 +2319,7 @@ def main():
|
||||
'enabled': True # 是否启用非经验模型预测
|
||||
},
|
||||
'step12': {
|
||||
'custom_regression_dir': None, # 自定义回归模型目录(None表示使用9_Custom_Regression_Modeling)
|
||||
'custom_regression_dir': None, # 自定义回归模型目录(None表示使用13_Custom_Regression)
|
||||
'formula_csv_path': None, # 公式CSV文件路径,用于查找index_formula(如water_quality_formulas.csv)
|
||||
'coordinate_columns': None, # 坐标列名(None表示自动识别)
|
||||
'output_dir': None, # 输出目录(None表示使用prediction_dir)
|
||||
@ -2346,7 +2346,7 @@ def main():
|
||||
'generate_boxplots': True, # 是否生成箱型图
|
||||
'generate_spectrum': True, # 是否生成光谱曲线图
|
||||
'generate_statistics': True, # 是否生成统计图表
|
||||
'generate_glint_previews': True, # 是否生成2_glint和3_deglint的PNG预览图
|
||||
'generate_glint_previews': True, # 是否生成2_Glint_Detection和3_deglint的PNG预览图
|
||||
'scatter_config': {
|
||||
'metric': 'test_r2', # 选择最佳模型的指标
|
||||
'use_enhanced': True, # 是否使用增强版散点图(带置信区间)
|
||||
@ -2363,7 +2363,7 @@ def main():
|
||||
'glint_preview_config': {
|
||||
'work_dir': None, # 工作目录(None表示使用pipeline的工作目录)
|
||||
'output_subdir': 'glint_deglint_previews', # 输出子目录
|
||||
'generate_glint': True, # 是否处理2_glint文件夹
|
||||
'generate_glint': True, # 是否处理2_Glint_Detection文件夹
|
||||
'generate_deglint': True # 是否处理3_deglint文件夹
|
||||
}
|
||||
}
|
||||
|
||||
@ -524,9 +524,9 @@ class Step11MapPanel(QWidget):
|
||||
# 若为相对路径,使用 work_dir 合成为绝对路径
|
||||
if not os.path.isabs(step10_output):
|
||||
step10_output = os.path.join(self.work_dir or '', step10_output).replace('\\', '/')
|
||||
# 提取父目录后追加 Machine_Learning_Prediction(最底层真实子目录)
|
||||
# 提取父目录后追加 9_ML_Prediction(最底层真实子目录)
|
||||
base_pred_dir = str(Path(step10_output).parent)
|
||||
ml_pred_dir = Path(base_pred_dir) / "Machine_Learning_Prediction"
|
||||
ml_pred_dir = Path(base_pred_dir) / "9_ML_Prediction"
|
||||
pred_dir = str(ml_pred_dir) if ml_pred_dir.exists() else base_pred_dir
|
||||
|
||||
# 2. 备选:从 Step11 界面读取非经验预测输出目录
|
||||
|
||||
@ -608,7 +608,7 @@ class ImageCategoryTree(QTreeWidget):
|
||||
DIR_MAPPING = {
|
||||
"14_visualization": "统计与分析报表",
|
||||
"1_water_mask": "水域掩膜识别",
|
||||
"2_glint": "耀斑区域检测",
|
||||
"2_Glint_Detection": "耀斑区域检测",
|
||||
"3_deglint": "去耀斑影像结果",
|
||||
"5_training_spectra": "训练光谱特征",
|
||||
"8_Regression_Modeling": "回归建模分析",
|
||||
@ -618,7 +618,7 @@ class ImageCategoryTree(QTreeWidget):
|
||||
"glint_deglint_previews": "耀斑处理预览",
|
||||
"sampling_maps": "采样点空间分布",
|
||||
"flight_maps": "无人机飞行轨迹",
|
||||
"Machine_Learning_Prediction": "机器学习预测",
|
||||
"9_ML_Prediction": "机器学习预测",
|
||||
"Non_Empirical_Prediction": "非经验模型预测",
|
||||
"Custom_Regression_Prediction": "自定义回归预测",
|
||||
"boxplot_dir": "水质参数箱线图",
|
||||
@ -822,7 +822,7 @@ class ImageCategoryTree(QTreeWidget):
|
||||
self._work_path / "8_Regression_Modeling",
|
||||
self._work_path / "10_feature_construction",
|
||||
self._work_path / "5_training_spectra",
|
||||
self._work_path / "2_glint",
|
||||
self._work_path / "2_Glint_Detection",
|
||||
self._work_path / "3_deglint",
|
||||
self._work_path / "1_water_mask",
|
||||
self._work_path / "9_water_quality_prediction",
|
||||
@ -1304,7 +1304,7 @@ class Step12VizPanel(QWidget):
|
||||
QMessageBox.warning(
|
||||
self,
|
||||
"警告",
|
||||
"未找到可处理的影像文件(2_glint/3_deglint 等)。",
|
||||
"未找到可处理的影像文件(2_Glint_Detection/3_deglint 等)。",
|
||||
)
|
||||
elif t == "sampling_map":
|
||||
map_path = payload.get("map_path")
|
||||
@ -1522,9 +1522,9 @@ class Step12VizPanel(QWidget):
|
||||
"""从全局配置自动推断并填入图像目录,然后自动加载目录内容。
|
||||
|
||||
推断优先级:
|
||||
1. {work_dir}/11_12_13_predictions/Machine_Learning_Prediction(机器学习预测)
|
||||
1. {work_dir}/9_ML_Prediction(机器学习预测)
|
||||
2. {work_dir}/11_12_13_predictions/Non_Empirical_Prediction(普通回归预测)
|
||||
3. {work_dir}/11_12_13_predictions/Custom_Regression_Prediction(自定义回归预测)
|
||||
3. {work_dir}/13_Custom_Regression/Custom_Regression_Prediction(自定义回归预测)
|
||||
4. {work_dir}/14_visualization(可视化目录)
|
||||
5. {work_dir}(工作目录根)
|
||||
"""
|
||||
@ -1540,9 +1540,9 @@ class Step12VizPanel(QWidget):
|
||||
|
||||
# 按优先级寻找存在的目录
|
||||
candidates = [
|
||||
pred_dir / "Machine_Learning_Prediction",
|
||||
work_path / "9_ML_Prediction",
|
||||
pred_dir / "Non_Empirical_Prediction",
|
||||
pred_dir / "Custom_Regression_Prediction",
|
||||
work_path / "13_Custom_Regression" / "Custom_Regression_Prediction",
|
||||
work_path / "14_visualization",
|
||||
work_path,
|
||||
]
|
||||
@ -1621,9 +1621,9 @@ class Step12VizPanel(QWidget):
|
||||
"""设置三个预测步骤的默认输出目录"""
|
||||
try:
|
||||
base_prediction_dir = work_path / "11_12_13_predictions"
|
||||
ml_dir = base_prediction_dir / "Machine_Learning_Prediction"
|
||||
ml_dir = work_path / "9_ML_Prediction"
|
||||
reg_dir = base_prediction_dir / "Regression_Model_Prediction"
|
||||
custom_dir = base_prediction_dir / "Custom_Regression_Prediction"
|
||||
custom_dir = work_path / "13_Custom_Regression" / "Custom_Regression_Prediction"
|
||||
ml_dir.mkdir(parents=True, exist_ok=True)
|
||||
reg_dir.mkdir(parents=True, exist_ok=True)
|
||||
custom_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@ -31,7 +31,7 @@ class Step12Panel(QWidget):
|
||||
)
|
||||
layout.addWidget(self.sampling_csv_file)
|
||||
|
||||
# 自定义回归模型目录选择(9_Custom_Regression_Modeling)
|
||||
# 自定义回归模型目录选择(13_Custom_Regression)
|
||||
self.regression_models_dir = FileSelectWidget(
|
||||
"回归模型目录:",
|
||||
"Directories;;All Files (*.*)"
|
||||
@ -133,12 +133,12 @@ class Step12Panel(QWidget):
|
||||
if self.work_dir:
|
||||
models_dir = self.regression_models_dir.get_path().strip()
|
||||
if not models_dir:
|
||||
default_models_dir = os.path.join(self.work_dir, "9_Custom_Regression_Modeling").replace('\\', '/')
|
||||
default_models_dir = os.path.join(self.work_dir, "13_Custom_Regression").replace('\\', '/')
|
||||
self.regression_models_dir.set_path(default_models_dir)
|
||||
|
||||
# 4. 自动填充输出目录(自定义回归预测目录)
|
||||
if self.work_dir:
|
||||
output_dir = os.path.join(self.work_dir, "11_12_13_predictions/Custom_Regression_Prediction")
|
||||
output_dir = os.path.join(self.work_dir, "13_Custom_Regression/Custom_Regression_Prediction")
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
existing_out = self.output_dir_widget.get_path()
|
||||
if not existing_out or not existing_out.strip():
|
||||
@ -161,7 +161,7 @@ class Step12Panel(QWidget):
|
||||
"""浏览回归模型目录"""
|
||||
default = self._get_default_work_dir()
|
||||
if default:
|
||||
default = os.path.join(default, "9_Custom_Regression_Modeling")
|
||||
default = os.path.join(default, "13_Custom_Regression")
|
||||
dir_path = QFileDialog.getExistingDirectory(self, "选择回归模型目录", default)
|
||||
if dir_path:
|
||||
self.regression_models_dir.set_path(dir_path)
|
||||
@ -170,7 +170,7 @@ class Step12Panel(QWidget):
|
||||
"""浏览输出目录"""
|
||||
default = self._get_default_work_dir()
|
||||
if default:
|
||||
default = os.path.join(default, "11_12_13_predictions/Custom_Regression_Prediction")
|
||||
default = os.path.join(default, "13_Custom_Regression/Custom_Regression_Prediction")
|
||||
dir_path = QFileDialog.getExistingDirectory(self, "选择输出目录", default)
|
||||
if dir_path:
|
||||
self.output_dir_widget.set_path(dir_path)
|
||||
|
||||
@ -524,9 +524,9 @@ class Step14Panel(QWidget):
|
||||
# 若为相对路径,使用 work_dir 合成为绝对路径
|
||||
if not os.path.isabs(step10_output):
|
||||
step10_output = os.path.join(self.work_dir or '', step10_output).replace('\\', '/')
|
||||
# 提取父目录后追加 Machine_Learning_Prediction(最底层真实子目录)
|
||||
# 提取父目录后追加 9_ML_Prediction(最底层真实子目录)
|
||||
base_pred_dir = str(Path(step10_output).parent)
|
||||
ml_pred_dir = Path(base_pred_dir) / "Machine_Learning_Prediction"
|
||||
ml_pred_dir = Path(base_pred_dir) / "9_ML_Prediction"
|
||||
pred_dir = str(ml_pred_dir) if ml_pred_dir.exists() else base_pred_dir
|
||||
|
||||
# 2. 备选:从 Step11 界面读取非经验预测输出目录
|
||||
|
||||
@ -186,10 +186,10 @@ class Step2Panel(QWidget):
|
||||
|
||||
# 3. 自动填充输出路径(基于工作目录)
|
||||
if self.work_dir:
|
||||
# 生成输出耀斑掩膜的标准路径:workspace/2_glint_mask/glint_mask_out.dat
|
||||
output_dir = os.path.join(self.work_dir, "2_glint_mask")
|
||||
# 生成输出耀斑掩膜的标准路径:workspace/2_Glint_Detection/severe_glint_area.dat
|
||||
output_dir = os.path.join(self.work_dir, "2_Glint_Detection")
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
default_output_path = os.path.join(output_dir, "glint_mask_out.dat").replace('\\', '/')
|
||||
default_output_path = os.path.join(output_dir, "severe_glint_area.dat").replace('\\', '/')
|
||||
self.output_file.set_path(default_output_path)
|
||||
else:
|
||||
# 没有工作目录时,清空输出路径
|
||||
|
||||
@ -190,7 +190,7 @@ class Step9MlPredictPanel(QWidget):
|
||||
"""浏览模型母文件夹,自动扫描子目录中的 .joblib 文件"""
|
||||
default = self._get_default_work_dir()
|
||||
if default:
|
||||
default = os.path.join(default, "9_supervised_modeling")
|
||||
default = os.path.join(default, "9_ML_Prediction")
|
||||
dir_path = QFileDialog.getExistingDirectory(
|
||||
self,
|
||||
"选择模型母文件夹",
|
||||
@ -352,7 +352,7 @@ class Step9MlPredictPanel(QWidget):
|
||||
|
||||
# 3. 自动填充输出路径(机器学习预测目录)
|
||||
if self.work_dir:
|
||||
output_dir = os.path.join(self.work_dir, "11_ml_prediction")
|
||||
output_dir = os.path.join(self.work_dir, "9_ML_Prediction")
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
existing_out = self.output_file.get_path()
|
||||
if not existing_out or not existing_out.strip():
|
||||
@ -375,7 +375,7 @@ class Step9MlPredictPanel(QWidget):
|
||||
"""浏览模型目录"""
|
||||
default = self._get_default_work_dir()
|
||||
if default:
|
||||
default = os.path.join(default, "9_supervised_modeling")
|
||||
default = os.path.join(default, "9_ML_Prediction")
|
||||
dir_path = QFileDialog.getExistingDirectory(self, "选择模型目录", default)
|
||||
if dir_path:
|
||||
self.models_dir_file.set_path(dir_path)
|
||||
|
||||
@ -1366,14 +1366,14 @@ class WaterQualityGUI(QMainWindow):
|
||||
# 定义每个步骤的标准输出路径模式(相对于工作目录)
|
||||
self.step_default_outputs = {
|
||||
'step1': "1_water_mask/water_mask_from_ndwi.dat",
|
||||
'step2': "2_glint/severe_glint_area.dat",
|
||||
'step2': "2_Glint_Detection/severe_glint_area.dat",
|
||||
'step3': "3_deglint/deglint_kutser.bsq",
|
||||
'step4_sampling': "4_sampling/sampling_spectra.csv",
|
||||
'step5_clean': "5_Data_Cleaning/cleaned_sampling_data.csv",
|
||||
'step6_feature': "6_Spectral_Feature_Extraction/training_spectra.csv",
|
||||
'step7_index': "7_Water_Quality_Indices/training_spectra_indices.csv",
|
||||
'step8_ml_train': "8_Supervised_Model_Training/",
|
||||
'step9_ml_predict': "11_12_13_predictions/Machine_Learning_Prediction/",
|
||||
'step9_ml_predict': "9_ML_Prediction/",
|
||||
'step10_watercolor': "10_WaterIndex_Images/",
|
||||
'step11_map': "14_visualization/"
|
||||
}
|
||||
@ -1415,7 +1415,7 @@ class WaterQualityGUI(QMainWindow):
|
||||
'bsq_file': ('step3', 'deglint_image', 'bsq_file') # 水色反演需要去耀斑BSQ影像
|
||||
},
|
||||
'step11_map': {
|
||||
'prediction_csv_dir_edit': ('step9_ml_predict', 'Machine_Learning_Prediction', 'prediction_csv_dir_edit'),
|
||||
'prediction_csv_dir_edit': ('step9_ml_predict', '9_ML_Prediction', 'prediction_csv_dir_edit'),
|
||||
'geotiff_dir_edit': ('step10_watercolor', 'WaterIndex_Images', 'geotiff_dir_edit')
|
||||
}
|
||||
}
|
||||
@ -2379,17 +2379,17 @@ class WaterQualityGUI(QMainWindow):
|
||||
# 扫描各个子目录
|
||||
subdirs = {
|
||||
'1_water_mask': 'step1',
|
||||
'2_glint': 'step2',
|
||||
'2_Glint_Detection': 'step2',
|
||||
'3_deglint': 'step3',
|
||||
'5_Data_Cleaning': 'step5_clean',
|
||||
'6_Spectral_Feature_Extraction': 'step6_feature',
|
||||
'7_Water_Quality_Indices': 'step7_index',
|
||||
'8_Supervised_Model_Training': 'step8_ml_train',
|
||||
'8_Regression_Modeling': 'step8_ml_train',
|
||||
'9_Custom_Regression_Modeling': 'step9_ml_predict',
|
||||
'11_12_13_predictions/Machine_Learning_Prediction': 'step9_ml_predict',
|
||||
'13_Custom_Regression': 'step13',
|
||||
'9_ML_Prediction': 'step9_ml_predict',
|
||||
'11_12_13_predictions/Non_Empirical_Prediction': 'step11_map',
|
||||
'11_12_13_predictions/Custom_Regression_Prediction': 'step12_viz',
|
||||
'13_Custom_Regression/Custom_Regression_Prediction': 'step13',
|
||||
'14_visualization': 'step13_report',
|
||||
'10_geotiff_batch_rendering': 'step11_map'
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
5. 模型训练摘要报告:training_summary.csv
|
||||
6. 参数反演结果报告:包含预测统计信息
|
||||
7. 批量处理摘要:batch_inference_summary.json
|
||||
8. 掩膜和耀斑缩略图:2_glint和3_deglint文件夹的影像预览图
|
||||
8. 掩膜和耀斑缩略图:2_Glint_Detection和3_deglint文件夹的影像预览图
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
@ -423,10 +423,10 @@ class WaterQualityVisualization:
|
||||
generate_glint: bool = True,
|
||||
generate_deglint: bool = True) -> Dict[str, str]:
|
||||
"""
|
||||
根据工作目录的2_glint和3_deglint文件夹中的文件生成PNG预览图
|
||||
根据工作目录的2_Glint_Detection和3_deglint文件夹中的文件生成PNG预览图
|
||||
|
||||
功能特点:
|
||||
- 2_glint文件夹:单波段二值耀斑掩膜,使用红色高亮显示
|
||||
- 2_Glint_Detection文件夹:单波段二值耀斑掩膜,使用红色高亮显示
|
||||
- 3_deglint文件夹:多波段去耀斑影像,使用RGB合成显示
|
||||
- 自动识别文件类型并应用相应的可视化方案
|
||||
- 输出保存至14_visualization/glint_deglint_previews/
|
||||
@ -434,7 +434,7 @@ class WaterQualityVisualization:
|
||||
Args:
|
||||
work_dir: 工作目录路径
|
||||
output_subdir: 输出子目录名称(默认 "glint_deglint_previews")
|
||||
generate_glint: 是否处理2_glint文件夹中的文件
|
||||
generate_glint: 是否处理2_Glint_Detection文件夹中的文件
|
||||
generate_deglint: 是否处理3_deglint文件夹中的文件
|
||||
|
||||
Returns:
|
||||
@ -461,17 +461,17 @@ class WaterQualityVisualization:
|
||||
print(f"{'='*60}")
|
||||
print(f"输出目录: {output_dir}")
|
||||
|
||||
# 处理2_glint文件夹
|
||||
# 处理2_Glint_Detection文件夹
|
||||
if generate_glint:
|
||||
glint_dir = work_dir_path / "2_glint"
|
||||
glint_dir = work_dir_path / "2_Glint_Detection"
|
||||
if glint_dir.exists():
|
||||
print(f"正在处理2_glint文件夹: {glint_dir}")
|
||||
print(f"正在处理2_Glint_Detection文件夹: {glint_dir}")
|
||||
glint_previews = self._process_image_folder(
|
||||
glint_dir, output_dir, "glint", preview_paths
|
||||
)
|
||||
processed_count += len(glint_previews)
|
||||
else:
|
||||
print(f"警告: 2_glint文件夹不存在: {glint_dir}")
|
||||
print(f"警告: 2_Glint_Detection文件夹不存在: {glint_dir}")
|
||||
|
||||
# 处理3_deglint文件夹
|
||||
if generate_deglint:
|
||||
@ -536,7 +536,7 @@ class WaterQualityVisualization:
|
||||
为可视化模块生成影像预览图
|
||||
|
||||
特别处理:
|
||||
- 耀斑掩膜 (2_glint/*.dat):单波段二值图,黑底(0)、耀斑区域为白(1)
|
||||
- 耀斑掩膜 (2_Glint_Detection/*.dat):单波段二值图,黑底(0)、耀斑区域为白(1)
|
||||
- 其他影像:多波段RGB合成,使用波长选择RGB波段
|
||||
|
||||
Args:
|
||||
|
||||
@ -1048,7 +1048,7 @@ if __name__ == "__main__":
|
||||
# 新功能使用示例
|
||||
bil_file = r"E:\wq_gui_test\3_deglint\deglint_goodman.bsq"
|
||||
water_mask_shp = r"E:\wq_gui_test\1_water_mask\water_mask_from_shp.dat"
|
||||
severe_glint = r"E:\wq_gui_test\2_glint\severe_glint_area.dat"
|
||||
severe_glint = r"E:\wq_gui_test\2_Glint_Detection\severe_glint_area.dat"
|
||||
output_csvpath = r"E:\wq_gui_test\4_sampling\sampling_spectra.csv"
|
||||
|
||||
# 设置参数
|
||||
|
||||
Reference in New Issue
Block a user