mirror of
https://github.com/mudler/LocalAI.git
synced 2025-04-21 09:31:29 +00:00
feat(diffusers): allow to override image gen options (#4807)
Use the options field in the model to override kwargs if needed. This allows to specify from the model yaml config: ```yaml options: - foo:bar ``` And each option will be used directly when calling the diffusers pipeline, e.g: ```python pipe( foo="bar", ) ``` Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
5f64cc6328
commit
f5638a6354
@ -159,6 +159,18 @@ class BackendServicer(backend_pb2_grpc.BackendServicer):
|
||||
torchType = torch.float16
|
||||
variant = "fp16"
|
||||
|
||||
options = request.Options
|
||||
|
||||
# empty dict
|
||||
self.options = {}
|
||||
|
||||
# The options are a list of strings in this form optname:optvalue
|
||||
# We are storing all the options in a dict so we can use it later when
|
||||
# generating the images
|
||||
for opt in options:
|
||||
key, value = opt.split(":")
|
||||
self.options[key] = value
|
||||
|
||||
local = False
|
||||
modelFile = request.Model
|
||||
|
||||
@ -441,6 +453,9 @@ class BackendServicer(backend_pb2_grpc.BackendServicer):
|
||||
# create a dictionary of parameters by using the keys from EnableParameters and the values from defaults
|
||||
kwargs = {key: options.get(key) for key in keys if key in options}
|
||||
|
||||
# populate kwargs from self.options.
|
||||
kwargs.update(self.options)
|
||||
|
||||
# Set seed
|
||||
if request.seed > 0:
|
||||
kwargs["generator"] = torch.Generator(device=self.device).manual_seed(
|
||||
|
Loading…
x
Reference in New Issue
Block a user