From 1d4c5cc96ff957c76c7c34f460b5f239ca720ac6 Mon Sep 17 00:00:00 2001 From: Marc-Andre Ferland Date: Sun, 16 Oct 2022 23:07:55 -0400 Subject: [PATCH] Added clear error response when submitting tasks that requires GFPGANer if cuda:0 and cpu rendering is disabled. --- ui/server.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/server.py b/ui/server.py index 64fbbeca..55786906 100644 --- a/ui/server.py +++ b/ui/server.py @@ -245,6 +245,8 @@ def save_model_to_config(model_name): @app.post('/render') def render(req : task_manager.ImageRequest): if req.use_cpu and task_manager.is_alive('cpu') <= 0: return HTTPException(status_code=403, detail=f'CPU rendering is not enabled in config.json or the thread has died...') # HTTP403 Forbidden + if req.use_face_correction and task_manager.is_alive(0) <= 0 and task_manager.is_alive('cpu') <= 0: #TODO Remove when GFPGANer is fixed upstream. + return HTTPException(status_code=412, detail=f'GFPGANer only works on CPU or GPU:0, use CUDA_VISIBLE_DEVICES if GFPGANer is needed on a specific GPU.') # HTTP412 Precondition Failed try: save_model_to_config(req.use_stable_diffusion_model) req.use_stable_diffusion_model = resolve_model_to_use(req.use_stable_diffusion_model)