Merge pull request #522 from cmdr2/beta

v2.4.11 updates
This commit is contained in:
cmdr2 2022-11-21 12:43:03 +05:30 committed by GitHub
commit efa684c5e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 115 additions and 47 deletions

View File

@ -21,6 +21,9 @@
- A `What's New?` tab in the UI
### 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.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

View File

@ -1,5 +1,8 @@
@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\bootstrap.bat scripts\ /Y
@ -7,11 +10,17 @@ if exist "%cd%\profile" (
set USERPROFILE=%cd%\profile
)
@mkdir tmp
@set TMP=%cd%\tmp
@set TEMP=%cd%\tmp
@rem activate the installer env
call conda activate
@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.
@rem @if "%ERRORLEVEL%" NEQ "0" (
@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 pause
@rem exit /b
@rem)
@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"
@ -28,8 +37,8 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd"
@call git pull
@call git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c
@call git apply ..\ui\sd_internal\ddim_callback.patch
@call git apply ..\ui\sd_internal\env_yaml.patch
@call git apply --whitespace=fix ..\ui\sd_internal\ddim_callback.patch
@call git apply --whitespace=fix ..\ui\sd_internal\env_yaml.patch
@cd ..
) else (
@ -46,8 +55,8 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd"
@cd stable-diffusion
@call git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c
@call git apply ..\ui\sd_internal\ddim_callback.patch
@call git apply ..\ui\sd_internal\env_yaml.patch
@call git apply --whitespace=fix ..\ui\sd_internal\ddim_callback.patch
@call git apply --whitespace=fix ..\ui\sd_internal\env_yaml.patch
@cd ..
)
@ -68,8 +77,6 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd"
@set PYTHONNOUSERSITE=1
set USERPROFILE=%cd%\profile
set TMP=%cd%\tmp
set TEMP=%cd%\tmp
set PYTHONPATH=%cd%;%cd%\env\lib\site-packages
@ -107,8 +114,6 @@ set PATH=C:\Windows\System32;%PATH%
@set PYTHONNOUSERSITE=1
set USERPROFILE=%cd%\profile
set TMP=%cd%\tmp
set TEMP=%cd%\tmp
set PYTHONPATH=%cd%;%cd%\env\lib\site-packages
@ -142,8 +147,6 @@ set PATH=C:\Windows\System32;%PATH%
@set PYTHONNOUSERSITE=1
set USERPROFILE=%cd%\profile
set TMP=%cd%\tmp
set TEMP=%cd%\tmp
set PYTHONPATH=%cd%;%cd%\env\lib\site-packages
@ -171,8 +174,6 @@ set PATH=C:\Windows\System32;%PATH%
@set PYTHONNOUSERSITE=1
set USERPROFILE=%cd%\profile
set TMP=%cd%\tmp
set TEMP=%cd%\tmp
set PYTHONPATH=%cd%;%cd%\env\lib\site-packages

View File

@ -30,8 +30,8 @@ if [ -e "scripts/install_status.txt" ] && [ `grep -c sd_git_cloned scripts/insta
git pull
git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c
git apply ../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/ddim_callback.patch || fail "ddim patch failed"
git apply --whitespace=fix ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed"
cd ..
else
@ -46,8 +46,8 @@ else
cd stable-diffusion
git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c
git apply ../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/ddim_callback.patch || fail "ddim patch failed"
git apply --whitespace=fix ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed"
cd ..
fi

View File

@ -823,16 +823,26 @@ function getCurrentUserRequest() {
function makeImage() {
if (!isServerAvailable()) {
alert('The server is not available.')
return
}
const taskTemplate = getCurrentUserRequest()
const newTaskRequests = []
getPrompts().forEach((prompt) => newTaskRequests.push(Object.assign({}, taskTemplate, {
reqBody: Object.assign({ prompt: prompt }, taskTemplate.reqBody)
})))
newTaskRequests.forEach(createTask)
} else if (!randomSeedField.checked && seedField.value == '') {
alert('The "Seed" field must not be empty.')
} else if (numOutputsTotalField.value == '') {
alert('The "Number of Images" field must not be empty.')
} else if (numOutputsParallelField.value == '') {
alert('The "Number of parallel Images" field must not be empty.')
} else if (numInferenceStepsField.value == '') {
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) {

View File

@ -114,6 +114,24 @@ var PARAMETERS = [
icon: "fa-gear",
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",
type: ParameterType.checkbox,
@ -176,6 +194,8 @@ let useGPUsField = document.querySelector('#use_gpus')
let useFullPrecisionField = document.querySelector('#use_full_precision')
let saveToDiskField = document.querySelector('#save_to_disk')
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 uiOpenBrowserOnStartField = document.querySelector("#ui_open_browser_on_start")
@ -205,11 +225,17 @@ async function getAppConfig() {
if (config.update_branch === 'beta') {
useBetaChannelField.checked = true
document.querySelector("#updateBranchLabel").innerText = "(beta)"
document.querySelector("#updateBranchLabel").innerText = "(beta)"
}
if (config.ui && config.ui.open_browser_on_start === 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)
} catch (e) {
@ -336,12 +362,20 @@ async function getDevices() {
saveSettingsBtn.addEventListener('click', function() {
let updateBranch = (useBetaChannelField.checked ? 'beta' : 'main')
changeAppConfig({
'render_devices': getCurrentRenderDeviceSelection(),
'update_branch': updateBranch,
'ui_open_browser_on_start': uiOpenBrowserOnStartField.checked
})
if (listenPortField.value == '') {
alert('The network port field must not be empty.')
} else if (listenPortField.value<1 || listenPortField.value>65535) {
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')
asyncDelay(300).then(() => saveSettingsBtn.classList.remove('active'))
saveSettingsBtn.classList.add('active')
asyncDelay(300).then(() => saveSettingsBtn.classList.remove('active'))
})

View File

@ -83,13 +83,21 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
if not os.path.exists(config_json_path):
return default_val
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:
print(str(e))
print(traceback.format_exc())
return default_val
def setConfig(config):
print( json.dumps(config) )
try: # config.json
config_json_path = os.path.join(CONFIG_DIR, 'config.json')
with open(config_json_path, 'w', encoding='utf-8') as f:
@ -103,10 +111,10 @@ def setConfig(config):
if 'update_branch' in config:
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')}")
if os.getenv('SD_UI_BIND_IP') is not None:
config_bat.append(f"@set SD_UI_BIND_IP={os.getenv('SD_UI_BIND_IP')}")
config_bat.append(f"@set SD_UI_BIND_PORT={config['net']['listen_port']}")
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={bind_ip}")
if len(config_bat) > 0:
with open(config_bat_path, 'w', encoding='utf-8') as f:
@ -120,10 +128,10 @@ def setConfig(config):
if 'update_branch' in config:
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')}")
if os.getenv('SD_UI_BIND_IP') is not None:
config_sh.append(f"export SD_UI_BIND_IP={os.getenv('SD_UI_BIND_IP')}")
config_sh.append(f"export SD_UI_BIND_PORT={config['net']['listen_port']}")
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={bind_ip}")
if len(config_sh) > 1:
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
model_vae: str = None
ui_open_browser_on_start: bool = None
listen_to_network: bool = None
listen_port: int = None
@app.post('/app_config')
async def setAppConfig(req : SetAppConfigRequest):
@ -190,6 +200,14 @@ async def setAppConfig(req : SetAppConfigRequest):
if 'ui' not in config:
config['ui'] = {}
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:
setConfig(config)
@ -435,7 +453,9 @@ update_render_threads()
def open_browser():
config = getConfig()
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):
import webbrowser; webbrowser.open('http://localhost:9000')
import webbrowser; webbrowser.open(f"http://localhost:{port}")
open_browser()