11def main ():
22 import argparse
3- import math
43 from opensr_utils .pipeline import large_file_processing
54
65
@@ -28,24 +27,30 @@ def main():
2827 help = "🖼️ Also save one georeferenced crop and 10 LR/SR previews" )
2928 parser .add_argument ("--debug" , action = "store_true" ,
3029 help = "🐞 Debug mode: process only ~100 windows" )
30+ parser .add_argument ("--overwrite" , action = "store_true" ,
31+ help = "Replace an existing sr.tif output" )
32+ parser .add_argument ("--keep_temp" , action = "store_true" ,
33+ help = "Keep temporary patch files after stitching" )
34+ parser .add_argument ("--delete_input_zip" , action = "store_true" ,
35+ help = "Delete the source .zip after successful extraction" )
36+ parser .add_argument ("--batch_size" , type = int , default = 16 ,
37+ help = "Prediction batch size (default: 16)" )
38+ parser .add_argument ("--num_workers" , type = int , default = 4 ,
39+ help = "DataLoader worker count (default: 4)" )
40+ parser .add_argument ("--prefetch_factor" , type = int , default = 2 ,
41+ help = "DataLoader prefetch factor when workers > 0 (default: 2)" )
42+ parser .add_argument ("--compressed_patches" , action = "store_true" ,
43+ help = "Store temporary patches as compressed .npz files" )
3144
3245 args = parser .parse_args ()
3346
3447 # --- Resolve model selection ---
3548 if args .model == "LDSRS2" :
3649 # Lazy import to avoid CUDA init unless needed
3750 try :
38- from omegaconf import OmegaConf
39- from io import StringIO
40- import requests # your model package
41- import opensr_model # your model package
42- # Instantiate model
51+ from opensr_utils .model_utils .get_models import get_ldsrs2
4352 device = "cpu" # "cuda" or "cpu" - Dont use the torch automated detection here, it messes up the lightning trainer multi-GPU setup
44- config_url = "https://raw.githubusercontent.com/ESAOpenSR/opensr-model/refs/heads/main/opensr_model/configs/config_10m.yaml"
45- response = requests .get (config_url )
46- config = OmegaConf .load (StringIO (response .text ))
47- model = opensr_model .SRLatentDiffusion (config , device = device )
48- model .load_pretrained (config .ckpt_version )
53+ model = get_ldsrs2 (device = device )
4954
5055 except Exception as e :
5156 print ("❌ Could not load LDSR-S2 model from 'opensr_model'." )
@@ -67,7 +72,15 @@ def main():
6772 gpus = args .gpus if args .device == "cuda" else None ,
6873 save_preview = args .save_preview ,
6974 debug = args .debug ,
75+ cleanup = not args .keep_temp ,
76+ overwrite = args .overwrite ,
77+ delete_input_zip = args .delete_input_zip ,
78+ batch_size = args .batch_size ,
79+ num_workers = args .num_workers ,
80+ prefetch_factor = args .prefetch_factor ,
81+ compressed_patches = args .compressed_patches ,
7082 )
83+ runner .run ()
7184
7285if __name__ == "__main__" :
73- main ()
86+ main ()
0 commit comments