From f354dd9e2ffbf79707b82fe0b73f60a5ced0c4ac Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Thu, 19 Jan 2023 10:11:27 +0100 Subject: [PATCH] [Save Pretrained] Remove dead code lines that can accidentally remove pytorch files (#2038) correct safetensors --- src/diffusers/models/modeling_utils.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/diffusers/models/modeling_utils.py b/src/diffusers/models/modeling_utils.py index 1822bb49d5..afe5689fdb 100644 --- a/src/diffusers/models/modeling_utils.py +++ b/src/diffusers/models/modeling_utils.py @@ -272,15 +272,6 @@ class ModelMixin(torch.nn.Module): weights_name = SAFETENSORS_WEIGHTS_NAME if safe_serialization else WEIGHTS_NAME - # Clean the folder from a previous save - for filename in os.listdir(save_directory): - full_filename = os.path.join(save_directory, filename) - # If we have a shard file that is not going to be replaced, we delete it, but only from the main process - # in distributed settings to avoid race conditions. - weights_no_suffix = weights_name.replace(".bin", "").replace(".safetensors", "") - if filename.startswith(weights_no_suffix) and os.path.isfile(full_filename) and is_main_process: - os.remove(full_filename) - # Save the model save_function(state_dict, os.path.join(save_directory, weights_name))