From 6ab3537649e3553cf8c620aea2053cd0738dd055 Mon Sep 17 00:00:00 2001 From: plexpt Date: Tue, 2 Jan 2024 21:25:55 +0800 Subject: [PATCH 1/3] add error logging --- fooocusapi/worker.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fooocusapi/worker.py b/fooocusapi/worker.py index 9a4f47f..438b4b8 100644 --- a/fooocusapi/worker.py +++ b/fooocusapi/worker.py @@ -4,6 +4,8 @@ import numpy as np import torch import re +import logging + from typing import List from fooocusapi.file_utils import save_output_file from fooocusapi.parameters import GenerationFinishReason, ImageGenerationParams, ImageGenerationResult @@ -830,6 +832,8 @@ def callback(step, x0, x, total_steps, y): return yield_result(None, results, tasks) except Exception as e: print('Worker error:', e) + logging.exception(e) + if not async_task.is_finished: task_queue.finish_task(async_task.job_id) async_task.set_result([], True, str(e)) From 1219b169cc7c4fd8713f47a53dd47053a4096f5f Mon Sep 17 00:00:00 2001 From: plexpt Date: Tue, 2 Jan 2024 21:25:55 +0800 Subject: [PATCH 2/3] add error logging --- fooocusapi/worker.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fooocusapi/worker.py b/fooocusapi/worker.py index 9a4f47f..438b4b8 100644 --- a/fooocusapi/worker.py +++ b/fooocusapi/worker.py @@ -4,6 +4,8 @@ import numpy as np import torch import re +import logging + from typing import List from fooocusapi.file_utils import save_output_file from fooocusapi.parameters import GenerationFinishReason, ImageGenerationParams, ImageGenerationResult @@ -830,6 +832,8 @@ def callback(step, x0, x, total_steps, y): return yield_result(None, results, tasks) except Exception as e: print('Worker error:', e) + logging.exception(e) + if not async_task.is_finished: task_queue.finish_task(async_task.job_id) async_task.set_result([], True, str(e)) From 69b718f15bb8397eab9b1f66c07f1c515be68fdb Mon Sep 17 00:00:00 2001 From: plexpt Date: Wed, 3 Jan 2024 19:23:43 +0800 Subject: [PATCH 3/3] check ar format --- fooocusapi/worker.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fooocusapi/worker.py b/fooocusapi/worker.py index 438b4b8..3404e26 100644 --- a/fooocusapi/worker.py +++ b/fooocusapi/worker.py @@ -225,7 +225,14 @@ def yield_result(_, imgs, tasks): denoising_strength = 1.0 tiled = False + # Validate input format + if not aspect_ratios_selection.replace('*', ' ').replace(' ', '').isdigit(): + raise ValueError("Invalid input format. Please enter aspect ratios in the form 'width*height'.") width, height = aspect_ratios_selection.replace('*', '*').replace('*', ' ').split(' ')[:2] + # Validate width and height are integers + if not (width.isdigit() and height.isdigit()): + raise ValueError("Invalid width or height. Please enter valid integers.") + width, height = int(width), int(height) skip_prompt_processing = False