mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
Run python black
This commit is contained in:
@@ -95,10 +95,7 @@ class ModelGroup(metaclass=ABCMeta):
|
||||
pass
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return (
|
||||
f"<{self.__class__.__name__} object at {id(self):x}: "
|
||||
f"device={self.execution_device} >"
|
||||
)
|
||||
return f"<{self.__class__.__name__} object at {id(self):x}: " f"device={self.execution_device} >"
|
||||
|
||||
|
||||
class LazilyLoadedModelGroup(ModelGroup):
|
||||
@@ -143,8 +140,7 @@ class LazilyLoadedModelGroup(ModelGroup):
|
||||
self.load(module)
|
||||
if len(forward_input) == 0:
|
||||
warnings.warn(
|
||||
f"Hook for {module.__class__.__name__} got no input. "
|
||||
f"Inputs must be positional, not keywords.",
|
||||
f"Hook for {module.__class__.__name__} got no input. " f"Inputs must be positional, not keywords.",
|
||||
stacklevel=3,
|
||||
)
|
||||
return send_to_device(forward_input, self.execution_device)
|
||||
@@ -161,9 +157,7 @@ class LazilyLoadedModelGroup(ModelGroup):
|
||||
self.clear_current_model()
|
||||
|
||||
def _load(self, module: torch.nn.Module) -> torch.nn.Module:
|
||||
assert (
|
||||
self.is_empty()
|
||||
), f"A model is already loaded: {self._current_model_ref()}"
|
||||
assert self.is_empty(), f"A model is already loaded: {self._current_model_ref()}"
|
||||
module = module.to(self.execution_device)
|
||||
self.set_current_model(module)
|
||||
return module
|
||||
@@ -192,12 +186,8 @@ class LazilyLoadedModelGroup(ModelGroup):
|
||||
|
||||
def device_for(self, model):
|
||||
if model not in self:
|
||||
raise KeyError(
|
||||
f"This does not manage this model {type(model).__name__}", model
|
||||
)
|
||||
return (
|
||||
self.execution_device
|
||||
) # this implementation only dispatches to one device
|
||||
raise KeyError(f"This does not manage this model {type(model).__name__}", model)
|
||||
return self.execution_device # this implementation only dispatches to one device
|
||||
|
||||
def ready(self):
|
||||
pass # always ready to load on-demand
|
||||
@@ -256,12 +246,8 @@ class FullyLoadedModelGroup(ModelGroup):
|
||||
|
||||
def device_for(self, model):
|
||||
if model not in self:
|
||||
raise KeyError(
|
||||
"This does not manage this model f{type(model).__name__}", model
|
||||
)
|
||||
return (
|
||||
self.execution_device
|
||||
) # this implementation only dispatches to one device
|
||||
raise KeyError("This does not manage this model f{type(model).__name__}", model)
|
||||
return self.execution_device # this implementation only dispatches to one device
|
||||
|
||||
def __contains__(self, model):
|
||||
return model in self._models
|
||||
|
||||
Reference in New Issue
Block a user