fix(api): use min/max from config for more params
This commit is contained in:
parent
85b332467e
commit
56ff9022da
|
@ -86,14 +86,18 @@ def expand_prompt(
|
||||||
if skip_clip_states > 0:
|
if skip_clip_states > 0:
|
||||||
layer_norm = torch.nn.LayerNorm(last_state.shape[2])
|
layer_norm = torch.nn.LayerNorm(last_state.shape[2])
|
||||||
norm_state = layer_norm(
|
norm_state = layer_norm(
|
||||||
torch.from_numpy(hidden_states[-skip_clip_states].astype(np.float32)).detach()
|
torch.from_numpy(
|
||||||
|
hidden_states[-skip_clip_states].astype(np.float32)
|
||||||
|
).detach()
|
||||||
)
|
)
|
||||||
logger.trace(
|
logger.trace(
|
||||||
"normalized results after skipping %s layers: %s",
|
"normalized results after skipping %s layers: %s",
|
||||||
skip_clip_states,
|
skip_clip_states,
|
||||||
norm_state.shape,
|
norm_state.shape,
|
||||||
)
|
)
|
||||||
group_embeds.append(norm_state)
|
group_embeds.append(
|
||||||
|
norm_state.numpy().astype(hidden_states[-skip_clip_states].dtype)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
group_embeds.append(last_state)
|
group_embeds.append(last_state)
|
||||||
|
|
||||||
|
|
|
@ -139,30 +139,76 @@ def pipeline_from_request(
|
||||||
|
|
||||||
def border_from_request() -> Border:
|
def border_from_request() -> Border:
|
||||||
left = get_and_clamp_int(
|
left = get_and_clamp_int(
|
||||||
request.args, "left", 0, get_config_value("width", "max"), 0
|
request.args,
|
||||||
|
"left",
|
||||||
|
get_config_value("width"),
|
||||||
|
get_config_value("width", "max"),
|
||||||
|
get_config_value("width", "min"),
|
||||||
)
|
)
|
||||||
right = get_and_clamp_int(
|
right = get_and_clamp_int(
|
||||||
request.args, "right", 0, get_config_value("width", "max"), 0
|
request.args,
|
||||||
|
"right",
|
||||||
|
get_config_value("width"),
|
||||||
|
get_config_value("width", "max"),
|
||||||
|
get_config_value("width", "min"),
|
||||||
)
|
)
|
||||||
top = get_and_clamp_int(
|
top = get_and_clamp_int(
|
||||||
request.args, "top", 0, get_config_value("height", "max"), 0
|
request.args,
|
||||||
|
"top",
|
||||||
|
get_config_value("width"),
|
||||||
|
get_config_value("height", "max"),
|
||||||
|
get_config_value("height", "min"),
|
||||||
)
|
)
|
||||||
bottom = get_and_clamp_int(
|
bottom = get_and_clamp_int(
|
||||||
request.args, "bottom", 0, get_config_value("height", "max"), 0
|
request.args,
|
||||||
|
"bottom",
|
||||||
|
get_config_value("width"),
|
||||||
|
get_config_value("height", "max"),
|
||||||
|
get_config_value("height", "min"),
|
||||||
)
|
)
|
||||||
|
|
||||||
return Border(left, right, top, bottom)
|
return Border(left, right, top, bottom)
|
||||||
|
|
||||||
|
|
||||||
def upscale_from_request() -> UpscaleParams:
|
def upscale_from_request() -> UpscaleParams:
|
||||||
denoise = get_and_clamp_float(request.args, "denoise", 0.5, 1.0, 0.0)
|
denoise = get_and_clamp_float(
|
||||||
scale = get_and_clamp_int(request.args, "scale", 1, 4, 1)
|
request.args,
|
||||||
outscale = get_and_clamp_int(request.args, "outscale", 1, 4, 1)
|
"denoise",
|
||||||
|
get_config_value("denoise"),
|
||||||
|
get_config_value("denoise", "max"),
|
||||||
|
get_config_value("denoise", "min"),
|
||||||
|
)
|
||||||
|
scale = get_and_clamp_int(
|
||||||
|
request.args,
|
||||||
|
"scale",
|
||||||
|
get_config_value("scale"),
|
||||||
|
get_config_value("scale", "max"),
|
||||||
|
get_config_value("scale", "min"),
|
||||||
|
)
|
||||||
|
outscale = get_and_clamp_int(
|
||||||
|
request.args,
|
||||||
|
"outscale",
|
||||||
|
get_config_value("outscale"),
|
||||||
|
get_config_value("outscale", "max"),
|
||||||
|
get_config_value("outscale", "min"),
|
||||||
|
)
|
||||||
upscaling = get_from_list(request.args, "upscaling", get_upscaling_models())
|
upscaling = get_from_list(request.args, "upscaling", get_upscaling_models())
|
||||||
correction = get_from_list(request.args, "correction", get_correction_models())
|
correction = get_from_list(request.args, "correction", get_correction_models())
|
||||||
faces = get_not_empty(request.args, "faces", "false") == "true"
|
faces = get_not_empty(request.args, "faces", "false") == "true"
|
||||||
face_outscale = get_and_clamp_int(request.args, "faceOutscale", 1, 4, 1)
|
face_outscale = get_and_clamp_int(
|
||||||
face_strength = get_and_clamp_float(request.args, "faceStrength", 0.5, 1.0, 0.0)
|
request.args,
|
||||||
|
"faceOutscale",
|
||||||
|
get_config_value("faceOutscale"),
|
||||||
|
get_config_value("faceOutscale", "max"),
|
||||||
|
get_config_value("faceOutscale", "min"),
|
||||||
|
)
|
||||||
|
face_strength = get_and_clamp_float(
|
||||||
|
request.args,
|
||||||
|
"faceStrength",
|
||||||
|
get_config_value("faceStrength"),
|
||||||
|
get_config_value("faceStrength", "max"),
|
||||||
|
get_config_value("faceStrength", "min"),
|
||||||
|
)
|
||||||
upscale_order = request.args.get("upscaleOrder", "correction-first")
|
upscale_order = request.args.get("upscaleOrder", "correction-first")
|
||||||
|
|
||||||
return UpscaleParams(
|
return UpscaleParams(
|
||||||
|
@ -181,9 +227,27 @@ def upscale_from_request() -> UpscaleParams:
|
||||||
|
|
||||||
def highres_from_request() -> HighresParams:
|
def highres_from_request() -> HighresParams:
|
||||||
method = get_from_list(request.args, "highresMethod", get_highres_methods())
|
method = get_from_list(request.args, "highresMethod", get_highres_methods())
|
||||||
scale = get_and_clamp_int(request.args, "highresScale", 1, 4, 1)
|
scale = get_and_clamp_int(
|
||||||
steps = get_and_clamp_int(request.args, "highresSteps", 1, 200, 1)
|
request.args,
|
||||||
strength = get_and_clamp_float(request.args, "highresStrength", 0.5, 1.0, 0.0)
|
"highresScale",
|
||||||
|
get_config_value("highresScale"),
|
||||||
|
get_config_value("highresScale", "max"),
|
||||||
|
get_config_value("highresScale", "min"),
|
||||||
|
)
|
||||||
|
steps = get_and_clamp_int(
|
||||||
|
request.args,
|
||||||
|
"highresSteps",
|
||||||
|
get_config_value("highresSteps"),
|
||||||
|
get_config_value("highresSteps", "max"),
|
||||||
|
get_config_value("highresSteps", "min"),
|
||||||
|
)
|
||||||
|
strength = get_and_clamp_float(
|
||||||
|
request.args,
|
||||||
|
"highresStrength",
|
||||||
|
get_config_value("highresStrength"),
|
||||||
|
get_config_value("highresStrength"),
|
||||||
|
get_config_value("highresStrength", "min"),
|
||||||
|
)
|
||||||
|
|
||||||
return HighresParams(
|
return HighresParams(
|
||||||
scale,
|
scale,
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
"step": 1
|
"step": 1
|
||||||
},
|
},
|
||||||
"highresStrength": {
|
"highresStrength": {
|
||||||
"default": 0.5,
|
"default": 0.1,
|
||||||
"min": 0,
|
"min": 0,
|
||||||
"max": 1,
|
"max": 1,
|
||||||
"step": 0.01
|
"step": 0.01
|
||||||
|
|
Loading…
Reference in New Issue