(models, weights, output_dir)
| 951 | |
| 952 | # create custom saving & loading hooks so that `accelerator.save_state(...)` serializes in a nice format |
| 953 | def save_model_hook(models, weights, output_dir): |
| 954 | if accelerator.is_main_process: |
| 955 | for model in models: |
| 956 | sub_dir = "unet" if isinstance(model, type(unwrap_model(unet))) else "text_encoder" |
| 957 | model.save_pretrained(os.path.join(output_dir, sub_dir)) |
| 958 | |
| 959 | # make sure to pop weight so that corresponding model is not saved again |
| 960 | weights.pop() |
| 961 | |
| 962 | def load_model_hook(models, input_dir): |
| 963 | while len(models) > 0: |
nothing calls this directly
no test coverage detected