File size: 816 Bytes
f56ede2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
import sys
import subprocess

def run_controlnet_training(args):
    """Run train_controlnet.py with the provided command-line arguments."""
    # Path to train_controlnet.py
    controlnet_script = os.path.join(os.path.dirname(__file__), "..", 
                                     "third_party", "diffusers", "examples", "controlnet", "train_controlnet.py")
    
    # Construct the command: python + script path + arguments
    command = [sys.executable, controlnet_script] + args
    
    # Run the command
    try:
        subprocess.run(command, check=True)
    except subprocess.CalledProcessError as e:
        print(f"Error running train_controlnet.py: {e}", file=sys.stderr)
        sys.exit(e.returncode)

if __name__ == "__main__":
    run_controlnet_training(sys.argv[1:])