diff --git a/main.py b/main.py index 9594573..6bfd75c 100644 --- a/main.py +++ b/main.py @@ -25,6 +25,7 @@ from utilities.constants import VALUE_APP from utilities.constants import VALUE_JOB_PENDING from utilities.constants import VALUE_JOB_RUNNING from utilities.constants import VALUE_JOB_DONE +from utilities.constants import VALUE_JOB_FAILED from utilities.envvar import get_env_var_with_default from utilities.envvar import get_env_var from utilities.times import wait_for_seconds @@ -221,9 +222,15 @@ def backend(event_termination): config = Config().set_config(next_job) - result_dict = text2img.lunch( - prompt=prompt, negative_prompt=negative_prompt, config=config - ) + try: + result_dict = text2img.lunch( + prompt=prompt, negative_prompt=negative_prompt, config=config + ) + except BaseException as e: + logger.error("text2img.lunch error: {}".format(e)) + local_job_stack.pop(0) + next_job[KEY_JOB_STATUS] = VALUE_JOB_FAILED + local_completed_jobs.append(next_job) with memory_lock: local_job_stack.pop(0) diff --git a/templates/index.html b/templates/index.html index e8bec2a..c5b87b8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -69,7 +69,7 @@
+ aria-describedby="inputStepsHelp" placeholder="default is 50">
Each step is about 38s (CPU) or 0.1s (GPU)
@@ -145,10 +145,12 @@ $('#resultStatus').html(response.jobs[0].status) $('#resultSeed').html(response.jobs[0].seed) if (response.jobs[0].status == "done") { - $('#resultStatus').html(response.jobs[0].status); $('#newJobImg').attr('src', response.jobs[0].img); return; } + if (response.jobs[0].status == "failed") { + return; + } } setTimeout(function () { waitForImage(apikeyVal, uuidValue); }, 1000); // refresh every second }, @@ -189,7 +191,7 @@ } var stepsVal = parseInt($('#inputSteps').val()); if (isNaN(stepsVal)) { - stepsVal = 20; + stepsVal = 50; } var widthVal = parseInt($('#inputWidth').val()); if (isNaN(widthVal)) { @@ -205,6 +207,16 @@ return; } + if (widthVal % 8 != 0) { + alert("width must be divisible by 8!"); + return; + } + + if (heightVal % 8 != 0) { + alert("height must be divisible by 8!"); + return; + } + // Send POST request using Ajax $.ajax({ type: 'POST', diff --git a/utilities/constants.py b/utilities/constants.py index 1c39679..ef0512b 100644 --- a/utilities/constants.py +++ b/utilities/constants.py @@ -46,6 +46,7 @@ KEY_JOB_STATUS = "status" VALUE_JOB_PENDING = "pending" VALUE_JOB_RUNNING = "running" VALUE_JOB_DONE = "done" +VALUE_JOB_FAILED = "failed" REQUIRED_KEYS = [ API_KEY.lower(),