(models, weights, output_dir)
| 827 | if version.parse(accelerate.__version__) >= version.parse("0.16.0"): |
| 828 | # create custom saving & loading hooks so that `accelerator.save_state(...)` serializes in a nice format |
| 829 | def save_model_hook(models, weights, output_dir): |
| 830 | if accelerator.is_main_process: |
| 831 | i = len(weights) - 1 |
| 832 | |
| 833 | while len(weights) > 0: |
| 834 | weights.pop() |
| 835 | model = models[i] |
| 836 | |
| 837 | sub_dir = "controlnet" |
| 838 | model.save_pretrained(os.path.join(output_dir, sub_dir)) |
| 839 | |
| 840 | i -= 1 |
| 841 | |
| 842 | def load_model_hook(models, input_dir): |
| 843 | while len(models) > 0: |
nothing calls this directly
no test coverage detected