fix special param parsing within img2img/inpaint pipelines
This commit is contained in:
parent
7f0fbdc233
commit
4a89bee517
|
@ -263,12 +263,13 @@ def img2img(server: ServerContext, pool: DevicePoolExecutor):
|
||||||
source = Image.open(BytesIO(source_file.read())).convert("RGB")
|
source = Image.open(BytesIO(source_file.read())).convert("RGB")
|
||||||
|
|
||||||
data = get_request_data()
|
data = get_request_data()
|
||||||
|
data_params = data.get("params", data)
|
||||||
source_filter = get_from_list(
|
source_filter = get_from_list(
|
||||||
data["params"], "sourceFilter", list(get_source_filters().keys())
|
data_params, "sourceFilter", list(get_source_filters().keys())
|
||||||
)
|
)
|
||||||
|
|
||||||
strength = get_and_clamp_float(
|
strength = get_and_clamp_float(
|
||||||
data["params"],
|
data_params,
|
||||||
"strength",
|
"strength",
|
||||||
get_config_value("strength"),
|
get_config_value("strength"),
|
||||||
get_config_value("strength", "max"),
|
get_config_value("strength", "max"),
|
||||||
|
@ -336,11 +337,12 @@ def inpaint(server: ServerContext, pool: DevicePoolExecutor):
|
||||||
mask.convert(mode="L")
|
mask.convert(mode="L")
|
||||||
|
|
||||||
data = get_request_data()
|
data = get_request_data()
|
||||||
|
data_params = data.get("params", data)
|
||||||
full_res_inpaint = get_boolean(
|
full_res_inpaint = get_boolean(
|
||||||
data["params"], "fullresInpaint", get_config_value("fullresInpaint")
|
data_params, "fullresInpaint", get_config_value("fullresInpaint")
|
||||||
)
|
)
|
||||||
full_res_inpaint_padding = get_and_clamp_float(
|
full_res_inpaint_padding = get_and_clamp_float(
|
||||||
data["params"],
|
data_params,
|
||||||
"fullresInpaintPadding",
|
"fullresInpaintPadding",
|
||||||
get_config_value("fullresInpaintPadding"),
|
get_config_value("fullresInpaintPadding"),
|
||||||
get_config_value("fullresInpaintPadding", "max"),
|
get_config_value("fullresInpaintPadding", "max"),
|
||||||
|
@ -350,13 +352,11 @@ def inpaint(server: ServerContext, pool: DevicePoolExecutor):
|
||||||
params = get_request_params(server, JobType.INPAINT.value)
|
params = get_request_params(server, JobType.INPAINT.value)
|
||||||
replace_wildcards(params.image, get_wildcard_data())
|
replace_wildcards(params.image, get_wildcard_data())
|
||||||
|
|
||||||
fill_color = get_not_empty(data["params"], "fillColor", "white")
|
fill_color = get_not_empty(data_params, "fillColor", "white")
|
||||||
mask_filter = get_from_map(data["params"], "filter", get_mask_filters(), "none")
|
mask_filter = get_from_map(data_params, "filter", get_mask_filters(), "none")
|
||||||
noise_source = get_from_map(
|
noise_source = get_from_map(data_params, "noise", get_noise_sources(), "histogram")
|
||||||
data["params"], "noise", get_noise_sources(), "histogram"
|
|
||||||
)
|
|
||||||
tile_order = get_from_list(
|
tile_order = get_from_list(
|
||||||
data["params"],
|
data_params,
|
||||||
"tileOrder",
|
"tileOrder",
|
||||||
[TileOrder.grid, TileOrder.kernel, TileOrder.spiral],
|
[TileOrder.grid, TileOrder.kernel, TileOrder.spiral],
|
||||||
)
|
)
|
||||||
|
|
|
@ -476,10 +476,10 @@ def get_request_params(
|
||||||
|
|
||||||
device, params, size = pipeline_from_json(server, data, default_pipeline)
|
device, params, size = pipeline_from_json(server, data, default_pipeline)
|
||||||
|
|
||||||
border = build_border(data.get("border"))
|
border = build_border(data.get("border", {}))
|
||||||
upscale = build_upscale(data.get("upscale"))
|
upscale = build_upscale(data.get("upscale", {}))
|
||||||
highres = build_highres(data.get("highres"))
|
highres = build_highres(data.get("highres", {}))
|
||||||
experimental = build_experimental(data.get("experimental"))
|
experimental = build_experimental(data.get("experimental", {}))
|
||||||
|
|
||||||
return RequestParams(
|
return RequestParams(
|
||||||
device,
|
device,
|
||||||
|
|
|
@ -90,7 +90,7 @@ class TestTxt2ImgPipeline(unittest.TestCase):
|
||||||
|
|
||||||
self.assertTrue(path.exists("../outputs/test-txt2img-basic_0.png"))
|
self.assertTrue(path.exists("../outputs/test-txt2img-basic_0.png"))
|
||||||
|
|
||||||
with Image.open("../outputs/test-txt2img-basic.png") as output:
|
with Image.open("../outputs/test-txt2img-basic_0.png") as output:
|
||||||
self.assertEqual(output.size, (256, 256))
|
self.assertEqual(output.size, (256, 256))
|
||||||
# TODO: test contents of image
|
# TODO: test contents of image
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue