Skip to content

Commit

Permalink
Merge pull request #147 from PlexPt/main
Browse files Browse the repository at this point in the history
add error logging and check aspect_ratios_selection
  • Loading branch information
mrhan1993 authored Jan 4, 2024
2 parents 491c2ae + 3f6614a commit 8872939
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions fooocusapi/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -223,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
Expand Down Expand Up @@ -830,6 +839,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))
Expand Down

0 comments on commit 8872939

Please sign in to comment.