import subprocess import sys # Common base arguments across all runs BASE_CMD = [ sys.executable, # Uses the currently active Python interpreter "batch_agent_orchestrator.py", "--input-dir", r"C:\Users\admin_mtds\OneDrive\Desktop\ChinKuan\TestingImage\01_bubble_sensor", "--output-dir", r"C:\Users\admin_mtds\OneDrive\Desktop\ChinKuan\ArtiAgent - Defect\agent_output", "--defectdiffu-ckpt", r"C:\Users\admin_mtds\OneDrive\Desktop\ChinKuan\ArtiAgent - Defect\engine\DefectDiffu\checkpoint_old-4\model_300.pth", "--vae-path", r"C:\Users\admin_mtds\OneDrive\Desktop\ChinKuan\ArtiAgent - Defect\engine\DefectDiffu\checkpoints\sd-vae-ft-mse", "--product-desc", "VCSEL laser diode with emission aperture and surrounding mesa", "--max-defects-per-image", "3", "--device", "cuda" ] # Variations for each step in a single loop TASKS = [ ["--defect-type", "tiger-strip"], ["--defect-type", "bubble"], [] # Default/No defect-type specified ] TOTAL_LOOPS = 16 if __name__ == "__main__": for loop_num in range(1, TOTAL_LOOPS + 1): print(f"\n" + "=" * 50) print(f"šŸš€ STARTING LOOP {loop_num} OF {TOTAL_LOOPS}") print("=" * 50) for step_idx, task_args in enumerate(TASKS, start=1): full_command = BASE_CMD + task_args print(f"\n--> Running Task {step_idx}/3 for Loop {loop_num}...") # Run command and block until it completes result = subprocess.run(full_command) # Check if command failed if result.returncode != 0: print(f"āŒ Error encountered on Loop {loop_num}, Task {step_idx}. Execution stopped.") sys.exit(result.returncode) print("\nšŸŽ‰ Success! Completed all 16 loops.")