(models, weights, output_dir)
| 1016 | if version.parse(accelerate.__version__) >= version.parse("0.16.0"): |
| 1017 | # create custom saving & loading hooks so that `accelerator.save_state(...)` serializes in a nice format |
| 1018 | def save_model_hook(models, weights, output_dir): |
| 1019 | if accelerator.is_main_process: |
| 1020 | i = len(weights) - 1 |
| 1021 | |
| 1022 | while len(weights) > 0: |
| 1023 | weights.pop() |
| 1024 | model = models[i] |
| 1025 | |
| 1026 | sub_dir = "controlnet" |
| 1027 | model.save_pretrained(os.path.join(output_dir, sub_dir)) |
| 1028 | |
| 1029 | i -= 1 |
| 1030 | |
| 1031 | def load_model_hook(models, input_dir): |
| 1032 | while len(models) > 0: |
nothing calls this directly
no test coverage detected