1313
1414# ================= Configuration =================
1515# Modify these lists to specify which actors, sequences, and frames to run
16- ACTORS = ["Actor01" , "Actor02" , "Actor03" , "Actor04" , "Actor05" , "Actor06" , "Actor07" , "Actor08" ]
16+ # ACTORS = ["Actor01", "Actor02", "Actor03", "Actor04", "Actor05", "Actor06", "Actor07", "Actor08"]
17+ ACTORS = ["Actor06" , "Actor02" ]
1718SEQUENCES = ["Sequence1" ] # e.g., ["Sequence1", "Sequence2"]
18- FRAME_IDS = [0 ]
19+ FRAME_IDS = [1 ]
1920
2021# Method: "train" or "eval"
2122METHOD = "train"
2223
2324# GPUs to use (list of GPU IDs, e.g., ["0", "1", "2", "3"] or ["0"])
2425# Jobs will be distributed across these GPUs in parallel
25- CUDA_DEVICES = ["0" , "1" ]
26+ CUDA_DEVICES = ["0" , "1" , "2" , "3" ]
2627
2728# Base data directory
2829BASE_DATA_DIR = "/synology/actorshq/colmap"
3233
3334# Root run path (working directory for running experiments)
3435ROOT_RUN_PATH = os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." ))
36+
37+ # Path to the run_actorshq.py script
38+ RUN_SCRIPT_PATH = os .path .join (os .path .dirname (__file__ ), "run_actorshq.py" )
3539# ================================================
3640
3741
@@ -44,110 +48,40 @@ class RunConfig:
4448 cuda_device : str = "1"
4549
4650
47- def build_data_dir (actor : str , sequence : str , resolution : int = 4 ) -> str :
48- """Build the data directory path for a given actor and sequence ."""
49- return f"{ BASE_DATA_DIR } /{ actor } /{ sequence } /{ resolution } x/frames"
51+ def build_data_dir (actor : str , sequence : str , frame_id : int , resolution : int = 4 ) -> str :
52+ """Build the data directory path for a given actor, sequence, and frame ."""
53+ return f"{ BASE_DATA_DIR } /{ actor } /{ sequence } /{ resolution } x/frames/frame { frame_id } "
5054
5155
5256def run_single_experiment (config : RunConfig ):
5357 """Run a single experiment with the given configuration."""
54- data_dir = build_data_dir (config .actor , config .sequence , RESOLUTION )
58+ data_dir = build_data_dir (config .actor , config .sequence , config .frame_id , RESOLUTION )
59+ exp_name_prefix = f"{ config .actor } _{ config .sequence } "
5560
5661 print (f"\n { '=' * 60 } " )
5762 print (f"Running: Actor={ config .actor } , Sequence={ config .sequence } , Frame={ config .frame_id } " )
5863 print (f"Data dir: { data_dir } " )
5964 print (f"Method: { config .method } " )
65+ print (f"GPU: { config .cuda_device } " )
6066 print (f"{ '=' * 60 } \n " )
6167
6268 # Set environment variables
6369 env = os .environ .copy ()
6470 env ["CUDA_VISIBLE_DEVICES" ] = config .cuda_device
6571
66- # Build the command - we'll modify the config via command line or temp config
67- # For simplicity, we'll create a modified version of the script inline
68- script_content = f'''
69- import sys
70- import os
71- sys.path.insert(0, "{ ROOT_RUN_PATH } ")
72- from examples.simple_trainer import main2
73- from gsplat.strategy import DefaultStrategy
74- from examples.config import Config, load_config_from_toml, merge_config
75- from scripts.utils import set_result_dir
76-
77- os.environ["CUDA_VISIBLE_DEVICES"] = "{ config .cuda_device } "
78-
79- # Build default config
80- default_cfg = Config(strategy=DefaultStrategy(verbose=True))
81- default_cfg.adjust_steps(default_cfg.steps_scaler)
82-
83- # Load template config
84- template_path = "./configs/actorshq.toml"
85- cfg = load_config_from_toml(template_path)
86- cfg = merge_config(default_cfg, cfg)
87-
88- # Override data directory
89- cfg.data_dir = "{ data_dir } /frame{ config .frame_id } "
90-
91- # Build experiment name
92- exp_name = f"{ config .actor } _{ config .sequence } _l1_{{1.0 - cfg.ssim_lambda}}_ssim_{{cfg.ssim_lambda}}"
93- if cfg.masked_l1_loss:
94- exp_name += f"_ml1_{{cfg.masked_l1_lambda}}"
95- if cfg.masked_ssim_loss:
96- exp_name += f"_mssim_{{cfg.masked_ssim_lambda}}"
97- if cfg.alpha_loss:
98- exp_name += f"_alpha_{{cfg.alpha_lambda}}"
99- if cfg.scale_var_loss:
100- exp_name += f"_svar_{{cfg.scale_var_lambda}}"
101- if cfg.random_bkgd:
102- exp_name += "_rbkgd"
103-
104- cfg.disable_viewer = True
105- frame_id = { config .frame_id }
106-
107- if "{ config .method } " == "train":
108- cfg.exp_name = exp_name
109- cfg.scene_id = frame_id
110- set_result_dir(cfg, exp_name)
111- cfg.run_mode = "train"
112- cfg.save_ply = True
113- cfg.max_steps = 30000
114- cfg.save_steps = list(sorted(set(range(0, cfg.max_steps + 1, 10000)) | {{1}}))
115- cfg.ply_steps = cfg.save_steps
116- cfg.eval_steps = cfg.save_steps
117- cfg.init_type = "sfm"
118- cfg.strategy = DefaultStrategy(verbose=True)
119-
120- print(f"Training frame {{frame_id}}")
121- print(f"exp_name={{cfg.exp_name}}, scene_id={{cfg.scene_id}}, run_mode={{cfg.run_mode}}")
122- main2(0, 0, 1, cfg)
123-
124- elif "{ config .method } " == "eval":
125- cfg.exp_name = exp_name
126- cfg.run_mode = "eval"
127- cfg.init_type = "sfm"
128- cfg.save_ply = False
129- cfg.scene_id = frame_id
130- set_result_dir(cfg, exp_name=exp_name)
131- iter = cfg.max_steps
132- ckpt = os.path.join(f"{{cfg.result_dir}}/ckpts/ckpt_{{iter - 1}}_rank0.pt")
133- cfg.ckpt = ckpt
134-
135- print(f"Evaluating frame {{frame_id}}")
136- main2(0, 0, 1, cfg)
137- '''
138-
139- # Write temp script and run it
140- temp_script = f"/tmp/run_actorshq_{ config .actor } _{ config .sequence } _{ config .frame_id } .py"
141- with open (temp_script , "w" ) as f :
142- f .write (script_content )
72+ # Build the command to call run_actorshq.py
73+ cmd = [
74+ "python" , RUN_SCRIPT_PATH ,
75+ "--data_dir" , data_dir ,
76+ "--frame_id" , str (config .frame_id ),
77+ "--method" , config .method ,
78+ "--exp_name_prefix" , exp_name_prefix ,
79+ "--disable_viewer" ,
80+ ]
14381
14482 # Run the script
145- cmd = ["python" , temp_script ]
14683 result = subprocess .run (cmd , env = env , cwd = ROOT_RUN_PATH )
14784
148- # Clean up temp script
149- os .remove (temp_script )
150-
15185 return result .returncode
15286
15387
0 commit comments