Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/diffusers/models/model_loading_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ def load_state_dict(
with dduf_entries[checkpoint_file].as_mmap() as mm:
return safetensors.torch.load(mm)
if disable_mmap:
return safetensors.torch.load(open(checkpoint_file, "rb").read())
with open(checkpoint_file, "rb") as f:
return safetensors.torch.load(f.read())
else:
return safetensors.torch.load_file(checkpoint_file, device=map_location)
elif file_extension == GGUF_FILE_EXTENSION:
Expand Down
2 changes: 1 addition & 1 deletion src/diffusers/models/unets/unet_stable_cascade.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def forward(self, x):


class SDCascadeTimestepBlock(nn.Module):
def __init__(self, c, c_timestep, conds=[]):
def __init__(self, c, c_timestep, conds=()):
super().__init__()

self.mapper = nn.Linear(c_timestep, c * 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def inputs(self) -> list[tuple[str, Any]]:
]

@staticmethod
def prepare_extra_kwargs(func, exclude_kwargs=[], **kwargs):
def prepare_extra_kwargs(func, exclude_kwargs=(), **kwargs):
accepted_kwargs = set(inspect.signature(func).parameters.keys())
extra_kwargs = {}
for key, value in kwargs.items():
Expand Down Expand Up @@ -498,7 +498,7 @@ def intermediate_outputs(self) -> list[OutputParam]:

# YiYi TODO: move this out of here
@staticmethod
def prepare_extra_kwargs(func, exclude_kwargs=[], **kwargs):
def prepare_extra_kwargs(func, exclude_kwargs=(), **kwargs):
accepted_kwargs = set(inspect.signature(func).parameters.keys())
extra_kwargs = {}
for key, value in kwargs.items():
Expand Down Expand Up @@ -584,7 +584,7 @@ def intermediate_outputs(self) -> list[OutputParam]:
return [OutputParam("latents", type_hint=torch.Tensor, description="The denoised latents")]

@staticmethod
def prepare_extra_kwargs(func, exclude_kwargs=[], **kwargs):
def prepare_extra_kwargs(func, exclude_kwargs=(), **kwargs):
accepted_kwargs = set(inspect.signature(func).parameters.keys())
extra_kwargs = {}
for key, value in kwargs.items():
Expand Down
8 changes: 6 additions & 2 deletions src/diffusers/quantizers/gguf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def _create_accelerate_new_hook(old_hook):
return new_hook


def _replace_with_gguf_linear(model, compute_dtype, state_dict, prefix="", modules_to_not_convert=[]):
def _replace_with_gguf_linear(model, compute_dtype, state_dict, prefix="", modules_to_not_convert=None):
if modules_to_not_convert is None:
modules_to_not_convert = []
def _should_convert_to_gguf(state_dict, prefix):
weight_key = prefix + "weight"
return weight_key in state_dict and isinstance(state_dict[weight_key], GGUFParameter)
Expand Down Expand Up @@ -157,7 +159,9 @@ def _should_convert_to_gguf(state_dict, prefix):
return model


def _dequantize_gguf_and_restore_linear(model, modules_to_not_convert=[]):
def _dequantize_gguf_and_restore_linear(model, modules_to_not_convert=None):
if modules_to_not_convert is None:
modules_to_not_convert = []
for name, module in model.named_children():
if isinstance(module, GGUFLinear) and name not in modules_to_not_convert:
device = module.weight.device
Expand Down
2 changes: 1 addition & 1 deletion src/diffusers/utils/loading_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def load_image(
f"Incorrect path or URL. URLs must start with `http://` or `https://`, and {image} is not a valid path."
)
elif isinstance(image, PIL.Image.Image):
image = image
pass
else:
raise ValueError(
"Incorrect format used for the image. Should be a URL linking to an image, a local path, or a PIL image."
Expand Down