Skip to content

Commit

Permalink
feat: support codeformer face restoration model (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikoTan authored Jan 10, 2023
1 parent 937337f commit 6184f96
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions stable_horde.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ async def get_popped_request(self) -> Optional[Dict[str, Any]]:
"nsfw": self.config.nsfw,
"blacklist": [],
"models": self.config.models,
"bridge_version": 8,
"bridge_version": 9,
"threads": 1,
"max_pixels": self.config.max_pixels,
"allow_img2img": self.config.allow_img2img,
Expand Down Expand Up @@ -207,6 +207,15 @@ async def handle_request(self, req: Dict[str, Any]):
negative = ""

postprocessors = req['payload'].get('post_processing', None) or []
restore_faces = False
if "GFPGAN" in postprocessors:
restore_faces = True
shared.opts.face_restoration_model = "GFPGAN"
shared.opts.save(shared.config_filename)
elif "CodeFormers" in postprocessors:
restore_faces = True
shared.opts.face_restoration_model = "CodeFormer"
shared.opts.save(shared.config_filename)

params = {
"sd_model": shared.sd_model,
Expand All @@ -221,7 +230,7 @@ async def handle_request(self, req: Dict[str, Any]):
"subseed": req['payload'].get('seed_variation', 1),
"steps": req['payload']['ddim_steps'],
"n_iter": req['payload']['n_iter'],
"restore_faces": "GFPGAN" in postprocessors,
"restore_faces": restore_faces,
"do_not_save_samples": True,
"do_not_save_grid": True,
}
Expand Down

0 comments on commit 6184f96

Please sign in to comment.