Skip to content

Commit f354dd9

Browse files
[Save Pretrained] Remove dead code lines that can accidentally remove pytorch files (#2038)
correct safetensors
1 parent 007c914 commit f354dd9

File tree

1 file changed

+0
-9
lines changed

1 file changed

+0
-9
lines changed

src/diffusers/models/modeling_utils.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,6 @@ def save_pretrained(
272272

273273
weights_name = SAFETENSORS_WEIGHTS_NAME if safe_serialization else WEIGHTS_NAME
274274

275-
# Clean the folder from a previous save
276-
for filename in os.listdir(save_directory):
277-
full_filename = os.path.join(save_directory, filename)
278-
# If we have a shard file that is not going to be replaced, we delete it, but only from the main process
279-
# in distributed settings to avoid race conditions.
280-
weights_no_suffix = weights_name.replace(".bin", "").replace(".safetensors", "")
281-
if filename.startswith(weights_no_suffix) and os.path.isfile(full_filename) and is_main_process:
282-
os.remove(full_filename)
283-
284275
# Save the model
285276
save_function(state_dict, os.path.join(save_directory, weights_name))
286277

0 commit comments

Comments
 (0)