feat: add hires fix feature (#78)
close #69 * feat: ad hires_fix feature (#69) * fix: change to new hires fix method * revert: removal of firstphase resolution calculation re-added --------- Co-authored-by: Sebastian Grunow <sebastian@prodigy.solutions>pull/82/head^2
parent
6dd338ddbc
commit
b579ab6616
|
|
@ -60,7 +60,7 @@ Here is the compatibilities with the [official bridge](https://github.com/db0/AI
|
|||
|Inpainting|✔️|
|
||||
|Interrogate|❌|
|
||||
|Tiling|✔️|
|
||||
|Hi-res Fix|❌|
|
||||
|Hi-res Fix|✔️|
|
||||
|Clip Skip|❌|
|
||||
|Face Restoration (GFPGAN)|✔️|
|
||||
|Upscale (ESRGAN)|✔️|
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ class StableHordeConfig(object):
|
|||
save_images: bool = False
|
||||
save_images_folder: str = "horde"
|
||||
current_models: dict = {}
|
||||
hires_firstphase_resolution: int = 512
|
||||
hr_upscaler: str = "Latent"
|
||||
|
||||
def __init__(self, basedir: str):
|
||||
self.basedir = basedir
|
||||
|
|
@ -56,6 +58,8 @@ class StableHordeConfig(object):
|
|||
"interval": 10,
|
||||
"max_pixels": 1048576,
|
||||
"nsfw": False,
|
||||
"hr_upscaler": "Latent",
|
||||
"hires_firstphase_resolution": 512,
|
||||
}
|
||||
self.save()
|
||||
|
||||
|
|
|
|||
|
|
@ -322,8 +322,21 @@ class StableHorde:
|
|||
"override_settings": {
|
||||
"sd_model_checkpoint": local_model,
|
||||
},
|
||||
"enable_hr": job.hires_fix,
|
||||
"hr_upscaler": self.config.hr_upscaler,
|
||||
}
|
||||
|
||||
if job.hires_fix:
|
||||
ar = job.width / job.height
|
||||
params["firstphase_width"] = min(
|
||||
self.config.hires_firstphase_resolution,
|
||||
int(self.config.hires_firstphase_resolution * ar),
|
||||
)
|
||||
params["firstphase_height"] = min(
|
||||
self.config.hires_firstphase_resolution,
|
||||
int(self.config.hires_firstphase_resolution / ar),
|
||||
)
|
||||
|
||||
if job.source_image is not None:
|
||||
p = img2img.StableDiffusionProcessingImg2Img(
|
||||
init_images=[job.source_image],
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ class HordeJob:
|
|||
source_processing: Optional[str] = "img2img",
|
||||
source_mask: Optional[Image.Image] = None,
|
||||
r2_upload: Optional[str] = None,
|
||||
hires_fix: bool = False,
|
||||
):
|
||||
self.status: JobStatus = JobStatus.PENDING
|
||||
self.session = session
|
||||
|
|
@ -77,6 +78,7 @@ class HordeJob:
|
|||
)
|
||||
self.source_mask = source_mask
|
||||
self.r2_upload = r2_upload
|
||||
self.hires_fix = hires_fix
|
||||
|
||||
async def submit(self, image: Image.Image):
|
||||
self.status = JobStatus.SUBMITTING
|
||||
|
|
@ -193,7 +195,8 @@ class HordeJob:
|
|||
# 1 - img2img, inpainting, karras, r2, CodeFormers
|
||||
# 2 - tiling
|
||||
# 3 - r2 source
|
||||
version = 3
|
||||
# 4 - hires_fix, clip_skip
|
||||
version = 4
|
||||
name = "SD-WebUI Stable Horde Worker Bridge"
|
||||
repo = "https://github.com/sdwebui-w-horde/sd-webui-stable-horde-worker"
|
||||
# https://stablehorde.net/api/
|
||||
|
|
@ -203,9 +206,8 @@ class HordeJob:
|
|||
"nsfw": config.nsfw,
|
||||
"blacklist": [],
|
||||
"models": models,
|
||||
# TODO: add support for bridge version 13 (clip_skip, hires_fix)
|
||||
# and 14 (r2_source)
|
||||
"bridge_version": 11,
|
||||
# TODO: add support for bridge version 14 (r2_source)
|
||||
"bridge_version": 13,
|
||||
"bridge_agent": f"{name}:{version}:{repo}",
|
||||
"threads": 1,
|
||||
"max_pixels": config.max_pixels,
|
||||
|
|
@ -274,4 +276,5 @@ class HordeJob:
|
|||
source_processing=req.get("source_processing"),
|
||||
source_mask=await to_image(req.get("source_mask")),
|
||||
r2_upload=req.get("r2_upload"),
|
||||
hires_fix=payload.get("hires_fix", False),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue