pokkiri commited on
Commit
af44c09
·
verified ·
1 Parent(s): ce14226

Create config.py

Browse files
Files changed (1) hide show
  1. config.py +81 -0
config.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Configuration module for biomass prediction model.
3
+ This recreates the config class needed for unpickling the model package.
4
+
5
+ Author: najahpokkiri
6
+ Date: 2025-05-17
7
+ """
8
+ from dataclasses import dataclass, field
9
+ from typing import List, Dict, Optional, Union, Tuple
10
+ from datetime import datetime
11
+
12
+ @dataclass
13
+ class BiomassPipelineConfig:
14
+ """Configuration for Biomass Prediction Pipeline"""
15
+ # Core settings
16
+ mode: str = "full"
17
+ random_seed: int = 42
18
+ project_name: str = "biomass-prediction"
19
+ created_by: str = "najahpokkiri"
20
+ created_date: str = "2025-05-16"
21
+
22
+ # Data paths
23
+ raster_pairs: List[tuple] = field(default_factory=lambda: [
24
+ ("/teamspace/studios/dl2/clean/data/s1_s2_l8_palsar_ch_dem_yellapur_2020.tif",
25
+ "/teamspace/studios/dl2/clean/data/agbd_yellapur_reprojected_1.tif"),
26
+ ("/teamspace/studios/dl2/clean/data/s1_s2_l8_palsar_ch_dem_betul_2020.tif",
27
+ "/teamspace/studios/dl2/clean/data/agbd_betul_reprojected_1.tif"),
28
+ ("/teamspace/studios/dl2/clean/data/s1_s2_l8_palsar_ch_goa_achankumar_2020_clipped.tif",
29
+ "/teamspace/studios/dl2/clean/data/02_Achanakmar_AGB40_band1_onImgGrid.tif"),
30
+ ("/teamspace/studios/dl2/clean/data/s1_s2_l8_palsar_ch_dem_Khaoyai_2020_clipped.tif",
31
+ "/teamspace/studios/dl2/clean/data/05_Khaoyai_AGB40_band1_onImgGrid.tif")
32
+ ])
33
+ data_dir: str = "data/"
34
+ results_dir: str = field(default_factory=lambda: f"biomass_results_{datetime.now().strftime('%Y%m%d_%H%M%S')}")
35
+
36
+ # Feature engineering settings
37
+ use_log_transform: bool = True
38
+ epsilon: float = 1.0
39
+ use_advanced_indices: bool = True
40
+ use_texture_features: bool = True
41
+ use_spatial_features: bool = True
42
+ use_pca_features: bool = True
43
+ pca_components: int = 25
44
+ scale_method: str = "robust"
45
+ outlier_removal: bool = True
46
+ outlier_threshold: float = 3.0
47
+
48
+ # Model settings
49
+ model_type: str = "StableResNet"
50
+ dropout_rate: float = 0.2
51
+ batch_size: int = 256
52
+ learning_rate: float = 0.001
53
+ weight_decay: float = 1e-5
54
+ max_epochs: int = 300
55
+ patience: int = 30
56
+ test_size: float = 0.15
57
+ val_size: float = 0.15
58
+
59
+ # Deployment settings
60
+ huggingface_repo: str = "najahpokkiri/biomass-prediction"
61
+ quantize_model: bool = False
62
+ max_samples_per_tile: Optional[int] = None
63
+
64
+ def __post_init__(self):
65
+ """Adjust settings based on mode"""
66
+ if self.mode == "test":
67
+ # Quick testing settings
68
+ self.raster_pairs = self.raster_pairs[:1] # Use only first tile
69
+ self.max_epochs = 10
70
+ self.batch_size = 32
71
+ self.use_texture_features = False
72
+ self.use_spatial_features = False
73
+ self.use_pca_features = False
74
+ self.max_samples_per_tile = 5000
75
+ self.pca_components = 10
76
+ else:
77
+ # Full mode settings
78
+ self.max_samples_per_tile = None
79
+
80
+ # Create a default config instance
81
+ default_config = BiomassPipelineConfig()