forked from extern/easydiffusion
commit
efa684c5e8
@ -21,6 +21,9 @@
|
|||||||
- A `What's New?` tab in the UI
|
- A `What's New?` tab in the UI
|
||||||
|
|
||||||
### Detailed changelog
|
### Detailed changelog
|
||||||
|
* 2.4.11 - 21 Nov 2022 - Installer improvements: avoid crashing if the username contains a space or special characters, allow moving/renaming the folder after installation on Windows, whitespace fix on git apply
|
||||||
|
* 2.4.11 - 21 Nov 2022 - Validate inputs before submitting the Image request
|
||||||
|
* 2.4.11 - 19 Nov 2022 - New system settings to manage the network config (port number and whether to only listen on localhost)
|
||||||
* 2.4.11 - 19 Nov 2022 - Address a regression in how long images take to generate. Use the previous code for moving a model to CPU. This improves things by a second or two per image, but we still have a regression (investigating).
|
* 2.4.11 - 19 Nov 2022 - Address a regression in how long images take to generate. Use the previous code for moving a model to CPU. This improves things by a second or two per image, but we still have a regression (investigating).
|
||||||
* 2.4.10 - 18 Nov 2022 - Textarea for negative prompts. Thanks @JeLuf
|
* 2.4.10 - 18 Nov 2022 - Textarea for negative prompts. Thanks @JeLuf
|
||||||
* 2.4.10 - 18 Nov 2022 - Improved design for Settings, and rounded toggle buttons instead of checkboxes for a more modern look. Thanks @mdiller
|
* 2.4.10 - 18 Nov 2022 - Improved design for Settings, and rounded toggle buttons instead of checkboxes for a more modern look. Thanks @mdiller
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
|
@REM Caution, this file will make your eyes and brain bleed. It's such an unholy mess.
|
||||||
|
@REM Note to self: Please rewrite this in Python. For the sake of your own sanity.
|
||||||
|
|
||||||
@copy sd-ui-files\scripts\on_env_start.bat scripts\ /Y
|
@copy sd-ui-files\scripts\on_env_start.bat scripts\ /Y
|
||||||
@copy sd-ui-files\scripts\bootstrap.bat scripts\ /Y
|
@copy sd-ui-files\scripts\bootstrap.bat scripts\ /Y
|
||||||
|
|
||||||
@ -7,11 +10,17 @@ if exist "%cd%\profile" (
|
|||||||
set USERPROFILE=%cd%\profile
|
set USERPROFILE=%cd%\profile
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@mkdir tmp
|
||||||
|
@set TMP=%cd%\tmp
|
||||||
|
@set TEMP=%cd%\tmp
|
||||||
|
|
||||||
@rem activate the installer env
|
@rem activate the installer env
|
||||||
call conda activate
|
call conda activate
|
||||||
|
@rem @if "%ERRORLEVEL%" NEQ "0" (
|
||||||
@REM Caution, this file will make your eyes and brain bleed. It's such an unholy mess.
|
@rem @echo. & echo "Error activating conda for Stable Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo.
|
||||||
@REM Note to self: Please rewrite this in Python. For the sake of your own sanity.
|
@rem pause
|
||||||
|
@rem exit /b
|
||||||
|
@rem)
|
||||||
|
|
||||||
@REM remove the old version of the dev console script, if it's still present
|
@REM remove the old version of the dev console script, if it's still present
|
||||||
if exist "Open Developer Console.cmd" del "Open Developer Console.cmd"
|
if exist "Open Developer Console.cmd" del "Open Developer Console.cmd"
|
||||||
@ -28,8 +37,8 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd"
|
|||||||
@call git pull
|
@call git pull
|
||||||
@call git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c
|
@call git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c
|
||||||
|
|
||||||
@call git apply ..\ui\sd_internal\ddim_callback.patch
|
@call git apply --whitespace=fix ..\ui\sd_internal\ddim_callback.patch
|
||||||
@call git apply ..\ui\sd_internal\env_yaml.patch
|
@call git apply --whitespace=fix ..\ui\sd_internal\env_yaml.patch
|
||||||
|
|
||||||
@cd ..
|
@cd ..
|
||||||
) else (
|
) else (
|
||||||
@ -46,8 +55,8 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd"
|
|||||||
@cd stable-diffusion
|
@cd stable-diffusion
|
||||||
@call git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c
|
@call git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c
|
||||||
|
|
||||||
@call git apply ..\ui\sd_internal\ddim_callback.patch
|
@call git apply --whitespace=fix ..\ui\sd_internal\ddim_callback.patch
|
||||||
@call git apply ..\ui\sd_internal\env_yaml.patch
|
@call git apply --whitespace=fix ..\ui\sd_internal\env_yaml.patch
|
||||||
|
|
||||||
@cd ..
|
@cd ..
|
||||||
)
|
)
|
||||||
@ -68,8 +77,6 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd"
|
|||||||
@set PYTHONNOUSERSITE=1
|
@set PYTHONNOUSERSITE=1
|
||||||
|
|
||||||
set USERPROFILE=%cd%\profile
|
set USERPROFILE=%cd%\profile
|
||||||
set TMP=%cd%\tmp
|
|
||||||
set TEMP=%cd%\tmp
|
|
||||||
|
|
||||||
set PYTHONPATH=%cd%;%cd%\env\lib\site-packages
|
set PYTHONPATH=%cd%;%cd%\env\lib\site-packages
|
||||||
|
|
||||||
@ -107,8 +114,6 @@ set PATH=C:\Windows\System32;%PATH%
|
|||||||
@set PYTHONNOUSERSITE=1
|
@set PYTHONNOUSERSITE=1
|
||||||
|
|
||||||
set USERPROFILE=%cd%\profile
|
set USERPROFILE=%cd%\profile
|
||||||
set TMP=%cd%\tmp
|
|
||||||
set TEMP=%cd%\tmp
|
|
||||||
|
|
||||||
set PYTHONPATH=%cd%;%cd%\env\lib\site-packages
|
set PYTHONPATH=%cd%;%cd%\env\lib\site-packages
|
||||||
|
|
||||||
@ -142,8 +147,6 @@ set PATH=C:\Windows\System32;%PATH%
|
|||||||
@set PYTHONNOUSERSITE=1
|
@set PYTHONNOUSERSITE=1
|
||||||
|
|
||||||
set USERPROFILE=%cd%\profile
|
set USERPROFILE=%cd%\profile
|
||||||
set TMP=%cd%\tmp
|
|
||||||
set TEMP=%cd%\tmp
|
|
||||||
|
|
||||||
set PYTHONPATH=%cd%;%cd%\env\lib\site-packages
|
set PYTHONPATH=%cd%;%cd%\env\lib\site-packages
|
||||||
|
|
||||||
@ -171,8 +174,6 @@ set PATH=C:\Windows\System32;%PATH%
|
|||||||
@set PYTHONNOUSERSITE=1
|
@set PYTHONNOUSERSITE=1
|
||||||
|
|
||||||
set USERPROFILE=%cd%\profile
|
set USERPROFILE=%cd%\profile
|
||||||
set TMP=%cd%\tmp
|
|
||||||
set TEMP=%cd%\tmp
|
|
||||||
|
|
||||||
set PYTHONPATH=%cd%;%cd%\env\lib\site-packages
|
set PYTHONPATH=%cd%;%cd%\env\lib\site-packages
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ if [ -e "scripts/install_status.txt" ] && [ `grep -c sd_git_cloned scripts/insta
|
|||||||
git pull
|
git pull
|
||||||
git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c
|
git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c
|
||||||
|
|
||||||
git apply ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed"
|
git apply --whitespace=fix ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed"
|
||||||
git apply ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed"
|
git apply --whitespace=fix ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed"
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
else
|
else
|
||||||
@ -46,8 +46,8 @@ else
|
|||||||
cd stable-diffusion
|
cd stable-diffusion
|
||||||
git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c
|
git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c
|
||||||
|
|
||||||
git apply ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed"
|
git apply --whitespace=fix ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed"
|
||||||
git apply ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed"
|
git apply --whitespace=fix ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed"
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
@ -823,16 +823,26 @@ function getCurrentUserRequest() {
|
|||||||
function makeImage() {
|
function makeImage() {
|
||||||
if (!isServerAvailable()) {
|
if (!isServerAvailable()) {
|
||||||
alert('The server is not available.')
|
alert('The server is not available.')
|
||||||
return
|
} else if (!randomSeedField.checked && seedField.value == '') {
|
||||||
}
|
alert('The "Seed" field must not be empty.')
|
||||||
const taskTemplate = getCurrentUserRequest()
|
} else if (numOutputsTotalField.value == '') {
|
||||||
const newTaskRequests = []
|
alert('The "Number of Images" field must not be empty.')
|
||||||
getPrompts().forEach((prompt) => newTaskRequests.push(Object.assign({}, taskTemplate, {
|
} else if (numOutputsParallelField.value == '') {
|
||||||
reqBody: Object.assign({ prompt: prompt }, taskTemplate.reqBody)
|
alert('The "Number of parallel Images" field must not be empty.')
|
||||||
})))
|
} else if (numInferenceStepsField.value == '') {
|
||||||
newTaskRequests.forEach(createTask)
|
alert('The "Inference Steps" field must not be empty.')
|
||||||
|
} else if (guidanceScaleField.value == '') {
|
||||||
|
alert('The Guidance Scale field must not be empty.')
|
||||||
|
} else {
|
||||||
|
const taskTemplate = getCurrentUserRequest()
|
||||||
|
const newTaskRequests = []
|
||||||
|
getPrompts().forEach((prompt) => newTaskRequests.push(Object.assign({}, taskTemplate, {
|
||||||
|
reqBody: Object.assign({ prompt: prompt }, taskTemplate.reqBody)
|
||||||
|
})))
|
||||||
|
newTaskRequests.forEach(createTask)
|
||||||
|
|
||||||
initialText.style.display = 'none'
|
initialText.style.display = 'none'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTask(task) {
|
function createTask(task) {
|
||||||
@ -1336,4 +1346,4 @@ window.addEventListener("beforeunload", function(e) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
createCollapsibles()
|
createCollapsibles()
|
||||||
prettifyInputs(document);
|
prettifyInputs(document);
|
||||||
|
@ -114,6 +114,24 @@ var PARAMETERS = [
|
|||||||
icon: "fa-gear",
|
icon: "fa-gear",
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "listen_to_network",
|
||||||
|
type: ParameterType.checkbox,
|
||||||
|
label: "Make Stable Diffusion available on your network",
|
||||||
|
note: "Other devices on your network can access this web page",
|
||||||
|
icon: "fa-network-wired",
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "listen_port",
|
||||||
|
type: ParameterType.custom,
|
||||||
|
label: "Network port",
|
||||||
|
note: "Port that this server listens to. The '9000' part in 'http://localhost:9000'",
|
||||||
|
icon: "fa-anchor",
|
||||||
|
render: (parameter) => {
|
||||||
|
return `<input id="${parameter.id}" name="${parameter.id}" size="6" value="9000" onkeypress="preventNonNumericalInput(event)">`
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "use_beta_channel",
|
id: "use_beta_channel",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
@ -176,6 +194,8 @@ let useGPUsField = document.querySelector('#use_gpus')
|
|||||||
let useFullPrecisionField = document.querySelector('#use_full_precision')
|
let useFullPrecisionField = document.querySelector('#use_full_precision')
|
||||||
let saveToDiskField = document.querySelector('#save_to_disk')
|
let saveToDiskField = document.querySelector('#save_to_disk')
|
||||||
let diskPathField = document.querySelector('#diskPath')
|
let diskPathField = document.querySelector('#diskPath')
|
||||||
|
let listenToNetworkField = document.querySelector("#listen_to_network")
|
||||||
|
let listenPortField = document.querySelector("#listen_port")
|
||||||
let useBetaChannelField = document.querySelector("#use_beta_channel")
|
let useBetaChannelField = document.querySelector("#use_beta_channel")
|
||||||
let uiOpenBrowserOnStartField = document.querySelector("#ui_open_browser_on_start")
|
let uiOpenBrowserOnStartField = document.querySelector("#ui_open_browser_on_start")
|
||||||
|
|
||||||
@ -205,11 +225,17 @@ async function getAppConfig() {
|
|||||||
|
|
||||||
if (config.update_branch === 'beta') {
|
if (config.update_branch === 'beta') {
|
||||||
useBetaChannelField.checked = true
|
useBetaChannelField.checked = true
|
||||||
document.querySelector("#updateBranchLabel").innerText = "(beta)"
|
document.querySelector("#updateBranchLabel").innerText = "(beta)"
|
||||||
}
|
}
|
||||||
if (config.ui && config.ui.open_browser_on_start === false) {
|
if (config.ui && config.ui.open_browser_on_start === false) {
|
||||||
uiOpenBrowserOnStartField.checked = false
|
uiOpenBrowserOnStartField.checked = false
|
||||||
}
|
}
|
||||||
|
if (config.net && config.net.listen_to_network === false) {
|
||||||
|
listenToNetworkField.checked = false
|
||||||
|
}
|
||||||
|
if (config.net && config.net.listen_port !== undefined) {
|
||||||
|
listenPortField.value = config.net.listen_port
|
||||||
|
}
|
||||||
|
|
||||||
console.log('get config status response', config)
|
console.log('get config status response', config)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -336,12 +362,20 @@ async function getDevices() {
|
|||||||
saveSettingsBtn.addEventListener('click', function() {
|
saveSettingsBtn.addEventListener('click', function() {
|
||||||
let updateBranch = (useBetaChannelField.checked ? 'beta' : 'main')
|
let updateBranch = (useBetaChannelField.checked ? 'beta' : 'main')
|
||||||
|
|
||||||
changeAppConfig({
|
if (listenPortField.value == '') {
|
||||||
'render_devices': getCurrentRenderDeviceSelection(),
|
alert('The network port field must not be empty.')
|
||||||
'update_branch': updateBranch,
|
} else if (listenPortField.value<1 || listenPortField.value>65535) {
|
||||||
'ui_open_browser_on_start': uiOpenBrowserOnStartField.checked
|
alert('The network port must be a number from 1 to 65535')
|
||||||
})
|
} else {
|
||||||
|
changeAppConfig({
|
||||||
|
'render_devices': getCurrentRenderDeviceSelection(),
|
||||||
|
'update_branch': updateBranch,
|
||||||
|
'ui_open_browser_on_start': uiOpenBrowserOnStartField.checked,
|
||||||
|
'listen_to_network': listenToNetworkField.checked,
|
||||||
|
'listen_port': listenPortField.value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
saveSettingsBtn.classList.add('active')
|
saveSettingsBtn.classList.add('active')
|
||||||
asyncDelay(300).then(() => saveSettingsBtn.classList.remove('active'))
|
asyncDelay(300).then(() => saveSettingsBtn.classList.remove('active'))
|
||||||
})
|
})
|
||||||
|
40
ui/server.py
40
ui/server.py
@ -83,13 +83,21 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
|
|||||||
if not os.path.exists(config_json_path):
|
if not os.path.exists(config_json_path):
|
||||||
return default_val
|
return default_val
|
||||||
with open(config_json_path, 'r', encoding='utf-8') as f:
|
with open(config_json_path, 'r', encoding='utf-8') as f:
|
||||||
return json.load(f)
|
config = json.load(f)
|
||||||
|
if 'net' not in config:
|
||||||
|
config['net'] = {}
|
||||||
|
if os.getenv('SD_UI_BIND_PORT') is not None:
|
||||||
|
config['net']['listen_port'] = int(os.getenv('SD_UI_BIND_PORT'))
|
||||||
|
if os.getenv('SD_UI_BIND_IP') is not None:
|
||||||
|
config['net']['listen_to_network'] = ( os.getenv('SD_UI_BIND_IP') == '0.0.0.0' )
|
||||||
|
return config
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
return default_val
|
return default_val
|
||||||
|
|
||||||
def setConfig(config):
|
def setConfig(config):
|
||||||
|
print( json.dumps(config) )
|
||||||
try: # config.json
|
try: # config.json
|
||||||
config_json_path = os.path.join(CONFIG_DIR, 'config.json')
|
config_json_path = os.path.join(CONFIG_DIR, 'config.json')
|
||||||
with open(config_json_path, 'w', encoding='utf-8') as f:
|
with open(config_json_path, 'w', encoding='utf-8') as f:
|
||||||
@ -103,10 +111,10 @@ def setConfig(config):
|
|||||||
|
|
||||||
if 'update_branch' in config:
|
if 'update_branch' in config:
|
||||||
config_bat.append(f"@set update_branch={config['update_branch']}")
|
config_bat.append(f"@set update_branch={config['update_branch']}")
|
||||||
if os.getenv('SD_UI_BIND_PORT') is not None:
|
|
||||||
config_bat.append(f"@set SD_UI_BIND_PORT={os.getenv('SD_UI_BIND_PORT')}")
|
config_bat.append(f"@set SD_UI_BIND_PORT={config['net']['listen_port']}")
|
||||||
if os.getenv('SD_UI_BIND_IP') is not None:
|
bind_ip = '0.0.0.0' if config['net']['listen_to_network'] else '127.0.0.1'
|
||||||
config_bat.append(f"@set SD_UI_BIND_IP={os.getenv('SD_UI_BIND_IP')}")
|
config_bat.append(f"@set SD_UI_BIND_IP={bind_ip}")
|
||||||
|
|
||||||
if len(config_bat) > 0:
|
if len(config_bat) > 0:
|
||||||
with open(config_bat_path, 'w', encoding='utf-8') as f:
|
with open(config_bat_path, 'w', encoding='utf-8') as f:
|
||||||
@ -120,10 +128,10 @@ def setConfig(config):
|
|||||||
|
|
||||||
if 'update_branch' in config:
|
if 'update_branch' in config:
|
||||||
config_sh.append(f"export update_branch={config['update_branch']}")
|
config_sh.append(f"export update_branch={config['update_branch']}")
|
||||||
if os.getenv('SD_UI_BIND_PORT') is not None:
|
|
||||||
config_sh.append(f"export SD_UI_BIND_PORT={os.getenv('SD_UI_BIND_PORT')}")
|
config_sh.append(f"export SD_UI_BIND_PORT={config['net']['listen_port']}")
|
||||||
if os.getenv('SD_UI_BIND_IP') is not None:
|
bind_ip = '0.0.0.0' if config['net']['listen_to_network'] else '127.0.0.1'
|
||||||
config_sh.append(f"export SD_UI_BIND_IP={os.getenv('SD_UI_BIND_IP')}")
|
config_sh.append(f"export SD_UI_BIND_IP={bind_ip}")
|
||||||
|
|
||||||
if len(config_sh) > 1:
|
if len(config_sh) > 1:
|
||||||
with open(config_sh_path, 'w', encoding='utf-8') as f:
|
with open(config_sh_path, 'w', encoding='utf-8') as f:
|
||||||
@ -178,6 +186,8 @@ class SetAppConfigRequest(BaseModel):
|
|||||||
render_devices: Union[List[str], List[int], str, int] = None
|
render_devices: Union[List[str], List[int], str, int] = None
|
||||||
model_vae: str = None
|
model_vae: str = None
|
||||||
ui_open_browser_on_start: bool = None
|
ui_open_browser_on_start: bool = None
|
||||||
|
listen_to_network: bool = None
|
||||||
|
listen_port: int = None
|
||||||
|
|
||||||
@app.post('/app_config')
|
@app.post('/app_config')
|
||||||
async def setAppConfig(req : SetAppConfigRequest):
|
async def setAppConfig(req : SetAppConfigRequest):
|
||||||
@ -190,6 +200,14 @@ async def setAppConfig(req : SetAppConfigRequest):
|
|||||||
if 'ui' not in config:
|
if 'ui' not in config:
|
||||||
config['ui'] = {}
|
config['ui'] = {}
|
||||||
config['ui']['open_browser_on_start'] = req.ui_open_browser_on_start
|
config['ui']['open_browser_on_start'] = req.ui_open_browser_on_start
|
||||||
|
if req.listen_to_network is not None:
|
||||||
|
if 'net' not in config:
|
||||||
|
config['net'] = {}
|
||||||
|
config['net']['listen_to_network'] = bool(req.listen_to_network)
|
||||||
|
if req.listen_port is not None:
|
||||||
|
if 'net' not in config:
|
||||||
|
config['net'] = {}
|
||||||
|
config['net']['listen_port'] = int(req.listen_port)
|
||||||
try:
|
try:
|
||||||
setConfig(config)
|
setConfig(config)
|
||||||
|
|
||||||
@ -435,7 +453,9 @@ update_render_threads()
|
|||||||
def open_browser():
|
def open_browser():
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
ui = config.get('ui', {})
|
ui = config.get('ui', {})
|
||||||
|
net = config.get('net', {'listen_port':9000})
|
||||||
|
port = net.get('listen_port', 9000)
|
||||||
if ui.get('open_browser_on_start', True):
|
if ui.get('open_browser_on_start', True):
|
||||||
import webbrowser; webbrowser.open('http://localhost:9000')
|
import webbrowser; webbrowser.open(f"http://localhost:{port}")
|
||||||
|
|
||||||
open_browser()
|
open_browser()
|
||||||
|
Loading…
Reference in New Issue
Block a user