Download src/controlnet_image_generator/train.py from danhtran2mind/ControlNet-Image-Generator: direct link, hf CLI and curl.
- Browser
- Download file 816 Bytes
-
https://huggingface.co/spaces/danhtran2mind/ControlNet-Image-Generator/resolve/main/src/controlnet_image_generator/train.py
- Command line
-
hf download hf://spaces/danhtran2mind/ControlNet-Image-Generator/src/controlnet_image_generator/train.py
-
curl -L -o train.py https://huggingface.co/spaces/danhtran2mind/ControlNet-Image-Generator/resolve/main/src/controlnet_image_generator/train.py
816 Bytes
| 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:]) |