diff --git a/ui/index.html b/ui/index.html
index 922e9070..25f70a91 100644
--- a/ui/index.html
+++ b/ui/index.html
@@ -339,7 +339,7 @@
-
+
@@ -382,6 +382,7 @@ const SOUND_ENABLED_KEY = "soundEnabled"
const USE_CPU_KEY = "useCPU"
const USE_FULL_PRECISION_KEY = "useFullPrecision"
const USE_TURBO_MODE_KEY = "useTurboMode"
+const DISK_PATH_KEY = "diskPath"
const HEALTH_PING_INTERVAL = 5 // seconds
const MAX_INIT_IMAGE_DIMENSION = 768
@@ -405,6 +406,7 @@ let turboField = document.querySelector('#turbo')
let useCPUField = document.querySelector('#use_cpu')
let useFullPrecisionField = document.querySelector('#use_full_precision')
let saveToDiskField = document.querySelector('#save_to_disk')
+let diskPathField = document.querySelector('#diskPath')
// let allowNSFWField = document.querySelector("#allow_nsfw")
let promptStrengthField = document.querySelector('#prompt_strength')
let promptStrengthValueLabel = document.querySelector('#prompt_strength_value')
@@ -463,6 +465,12 @@ function handleBoolSettingChange(key) {
}
}
+function handleStringSettingChange(key) {
+ return function(e) {
+ localStorage.setItem(key, e.target.value.toString())
+ }
+}
+
function isSoundEnabled() {
return getLocalStorageBoolItem(SOUND_ENABLED_KEY, true)
}
@@ -479,6 +487,10 @@ function isUseTurboModeEnabled() {
return getLocalStorageBoolItem(USE_TURBO_MODE_KEY, true)
}
+function getSavedDiskPath() {
+ return getLocalStorageItem(DISK_PATH_KEY, '')
+}
+
function setStatus(statusType, msg, msgType) {
if (statusType !== 'server') {
return;
@@ -728,7 +740,6 @@ async function makeImage() {
width: widthField.value,
height: heightField.value,
// allow_nsfw: allowNSFWField.checked,
- save_to_disk: saveToDiskField.checked,
turbo: turboField.checked,
use_cpu: useCPUField.checked,
use_full_precision: useFullPrecisionField.checked
@@ -743,6 +754,10 @@ async function makeImage() {
// }
}
+ if (saveToDiskField.checked && diskPathField.value.trim() !== '') {
+ reqBody['save_to_disk_path'] = diskPathField.value.trim()
+ }
+
let time = new Date().getTime()
imagesContainer.innerHTML = ''
@@ -828,6 +843,12 @@ useFullPrecisionField.checked = isUseFullPrecisionEnabled()
turboField.addEventListener('click', handleBoolSettingChange(USE_TURBO_MODE_KEY))
turboField.checked = isUseTurboModeEnabled()
+diskPathField.addEventListener('change', handleStringSettingChange(DISK_PATH_KEY))
+
+saveToDiskField.addEventListener('click', function() {
+ diskPathField.disabled = !this.checked
+})
+
makeImageBtn.addEventListener('click', makeImage)
@@ -986,12 +1007,19 @@ function refreshTagsList() {
async function getDiskPath() {
try {
+ let diskPath = getSavedDiskPath()
+
+ if (diskPath !== '') {
+ diskPathField.value = diskPath
+ return
+ }
+
let res = await fetch('/output_dir')
if (res.status === 200) {
res = await res.json()
res = res[0]
- document.querySelector('#diskPath').innerHTML = '(to ' + res + ')'
+ document.querySelector('#diskPath').value = res
}
} catch (e) {
console.log('error fetching output dir path', e)
diff --git a/ui/server.py b/ui/server.py
index 0750fcd0..af7d1ea2 100644
--- a/ui/server.py
+++ b/ui/server.py
@@ -38,7 +38,7 @@ class ImageRequest(BaseModel):
seed: int = 42
prompt_strength: float = 0.8
# allow_nsfw: bool = False
- save_to_disk: bool = False
+ save_to_disk_path: str = None
turbo: bool = True
use_cpu: bool = False
use_full_precision: bool = False
@@ -90,9 +90,7 @@ async def image(req : ImageRequest):
r.turbo = req.turbo
r.use_cpu = req.use_cpu
r.use_full_precision = req.use_full_precision
-
- if req.save_to_disk:
- r.save_to_disk_path = outpath
+ r.save_to_disk_path = req.save_to_disk_path
try:
res: Response = runtime.mk_img(r)