Files
InvokeAI/invokeai/app/services
psychedelicious b745411866 fix(app): add trusted classes to torch safe globals to prevent errors when loading them
In `ObjectSerializerDisk`, we use `torch.load` to load serialized objects from disk. With torch 2.6.0, torch defaults to `weights_only=True`. As a result, torch will raise when attempting to deserialize anything with an unrecognized class.

For example, our `ConditioningFieldData` class is untrusted. When we load conditioning from disk, we will get a runtime error.

Torch provides a method to add trusted classes to an allowlist. This change adds an arg to `ObjectSerializerDisk` to add a list of safe globals to the allowlist and uses it for both `ObjectSerializerDisk` instances.

Note: My first attempt inferred the class from the generic type arg that `ObjectSerializerDisk` accepts, and added that to the allowlist. Unfortunately, this doesn't work.

For example, `ConditioningFieldData` has a `conditionings` attribute that may be one some other untrusted classes representing model-specific conditioning data. So, even if we allowlist `ConditioningFieldData`, loading will fail when torch deserializes the `conditionings` attribute.
2025-04-03 08:55:45 +10:00
..
2024-10-11 17:23:34 -04:00
2025-03-06 10:57:54 +11:00
2025-03-26 12:55:10 +11:00
2025-03-26 12:55:10 +11:00
2025-03-26 12:55:10 +11:00
2025-03-26 12:55:10 +11:00
2025-03-26 12:55:10 +11:00
2025-03-18 08:00:51 +11:00
2023-03-03 00:02:15 -05:00