From 44a3f63f99af82917197b53e92e97b7e3faf1d47 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Mon, 5 Sep 2022 13:22:34 +0530 Subject: [PATCH] Show suggestions if an out of memory error is encountered by the user --- ui/index.html | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/index.html b/ui/index.html index 3cff9ebd..efbb82c4 100644 --- a/ui/index.html +++ b/ui/index.html @@ -383,6 +383,7 @@ const USE_CPU_KEY = "useCPU" const USE_FULL_PRECISION_KEY = "useFullPrecision" const USE_TURBO_MODE_KEY = "useTurboMode" const HEALTH_PING_INTERVAL = 5 // seconds +const MAX_INIT_IMAGE_DIMENSION = 768 const IMAGE_REGEX = new RegExp('data:image/[A-Za-z]+;base64') @@ -565,6 +566,15 @@ async function doMakeImage(reqBody) { let msg = '' if (res.detail !== undefined) { msg = res.detail + + if (msg.toLowerCase().includes('out of memory')) { + msg += `

+ Suggestions: +
+ 1. If you have set an initial image, please try reducing its dimension to ${MAX_INIT_IMAGE_DIMENSION}x${MAX_INIT_IMAGE_DIMENSION} or smaller.
+ 2. Try disabling the 'Turbo mode' under 'Advanced Settings'.
+ 3. Try generating a smaller image.
` + } } else { msg = res } @@ -659,8 +669,6 @@ async function doMakeImage(reqBody) { } function validateInput() { - const MAX_INIT_IMAGE_DIMENSION = 768 - let width = parseInt(widthField.value) let height = parseInt(heightField.value)