Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dc34c0041c | |||
| fc54833505 |
@@ -88,7 +88,6 @@ module.exports = {
|
||||
// imageviewer.js
|
||||
modalPrevImage: "readonly",
|
||||
modalNextImage: "readonly",
|
||||
updateModalImageIfVisible: "readonly",
|
||||
// localStorage.js
|
||||
localSet: "readonly",
|
||||
localGet: "readonly",
|
||||
|
||||
@@ -133,7 +133,7 @@ If your system is very new, you need to install python3.11 or python3.10:
|
||||
# Ubuntu 24.04
|
||||
sudo add-apt-repository ppa:deadsnakes/ppa
|
||||
sudo apt update
|
||||
sudo apt install python3.11 python3.11-venv
|
||||
sudo apt install python3.11
|
||||
|
||||
# Manjaro/Arch
|
||||
sudo pacman -S yay
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<div>
|
||||
<a href="{api_docs}" target="_blank">API</a>
|
||||
<a href="{api_docs}">API</a>
|
||||
•
|
||||
<a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui">GitHub</a>
|
||||
•
|
||||
|
||||
@@ -54,7 +54,6 @@ function updateOnBackgroundChange() {
|
||||
updateModalImage();
|
||||
}
|
||||
}
|
||||
const updateModalImageIfVisible = updateOnBackgroundChange;
|
||||
|
||||
function modalImageSwitch(offset) {
|
||||
var galleryButtons = all_gallery_buttons();
|
||||
@@ -165,7 +164,6 @@ function modalLivePreviewToggle(event) {
|
||||
const modalToggleLivePreview = gradioApp().getElementById("modal_toggle_live_preview");
|
||||
opts.js_live_preview_in_modal_lightbox = !opts.js_live_preview_in_modal_lightbox;
|
||||
modalToggleLivePreview.innerHTML = opts.js_live_preview_in_modal_lightbox ? "🗇" : "🗆";
|
||||
updateModalImageIfVisible();
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ function requestProgress(id_task, progressbarContainer, gallery, atEnd, onProgre
|
||||
livePreview.className = 'livePreview';
|
||||
gallery.insertBefore(livePreview, gallery.firstElementChild);
|
||||
}
|
||||
updateModalImageIfVisible();
|
||||
|
||||
livePreview.appendChild(img);
|
||||
if (livePreview.childElementCount > 2) {
|
||||
livePreview.removeChild(livePreview.firstElementChild);
|
||||
|
||||
@@ -69,3 +69,39 @@ onOptionsChanged(function() {
|
||||
});
|
||||
});
|
||||
|
||||
function downloadSysinfo() {
|
||||
const pad = (n) => String(n).padStart(2, '0');
|
||||
const now = new Date();
|
||||
const YY = now.getFullYear();
|
||||
const MM = pad(now.getMonth() + 1);
|
||||
const DD = pad(now.getDate());
|
||||
const HH = pad(now.getHours());
|
||||
const mm = pad(now.getMinutes());
|
||||
const link = document.createElement('a');
|
||||
link.download = `sysinfo-${YY}-${MM}-${DD}-${HH}-${mm}.json`;
|
||||
const sysinfo_textbox = gradioApp().querySelector('#internal-sysinfo-textbox textarea');
|
||||
const content = sysinfo_textbox.value;
|
||||
if (content.startsWith('file=')) {
|
||||
link.href = content;
|
||||
} else {
|
||||
const blob = new Blob([content], {type: 'application/json'});
|
||||
link.href = URL.createObjectURL(blob);
|
||||
}
|
||||
link.click();
|
||||
sysinfo_textbox.value = '';
|
||||
updateInput(sysinfo_textbox);
|
||||
}
|
||||
|
||||
function openTabSysinfo() {
|
||||
const sysinfo_textbox = gradioApp().querySelector('#internal-sysinfo-textbox textarea');
|
||||
const content = sysinfo_textbox.value;
|
||||
if (content.startsWith('file=')) {
|
||||
window.open(content, '_blank');
|
||||
} else {
|
||||
const blob = new Blob([content], {type: 'application/json'});
|
||||
const url = URL.createObjectURL(blob);
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
sysinfo_textbox.value = '';
|
||||
updateInput(sysinfo_textbox);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,6 @@ git = launch_utils.git
|
||||
index_url = launch_utils.index_url
|
||||
dir_repos = launch_utils.dir_repos
|
||||
|
||||
if args.uv:
|
||||
from modules.uv_hook import patch
|
||||
patch()
|
||||
|
||||
|
||||
commit_hash = launch_utils.commit_hash
|
||||
git_tag = launch_utils.git_tag
|
||||
|
||||
|
||||
+4
-1
@@ -17,7 +17,7 @@ from fastapi.encoders import jsonable_encoder
|
||||
from secrets import compare_digest
|
||||
|
||||
import modules.shared as shared
|
||||
from modules import sd_samplers, deepbooru, sd_hijack, images, scripts, ui, postprocessing, errors, restart, shared_items, script_callbacks, infotext_utils, sd_models, sd_schedulers
|
||||
from modules import sd_samplers, deepbooru, sd_hijack, images, scripts, ui, postprocessing, errors, restart, shared_items, script_callbacks, infotext_utils, sd_models, sd_schedulers, sysinfo
|
||||
from modules.api import models
|
||||
from modules.shared import opts
|
||||
from modules.processing import StableDiffusionProcessingTxt2Img, StableDiffusionProcessingImg2Img, process_images
|
||||
@@ -33,6 +33,7 @@ import piexif.helper
|
||||
from contextlib import closing
|
||||
from modules.progress import create_task_id, add_task_to_queue, start_task, finish_task, current_task
|
||||
|
||||
|
||||
def script_name_to_index(name, scripts):
|
||||
try:
|
||||
return [script.title().lower() for script in scripts].index(name.lower())
|
||||
@@ -244,6 +245,8 @@ class Api:
|
||||
self.add_api_route("/sdapi/v1/scripts", self.get_scripts_list, methods=["GET"], response_model=models.ScriptsList)
|
||||
self.add_api_route("/sdapi/v1/script-info", self.get_script_info, methods=["GET"], response_model=list[models.ScriptInfo])
|
||||
self.add_api_route("/sdapi/v1/extensions", self.get_extensions_list, methods=["GET"], response_model=list[models.ExtensionItem])
|
||||
self.add_api_route("/internal/sysinfo", sysinfo.download_sysinfo, methods=["GET"])
|
||||
self.add_api_route("/internal/sysinfo-download", lambda: sysinfo.download_sysinfo(attachment=True), methods=["GET"])
|
||||
|
||||
if shared.cmd_opts.api_server_stop:
|
||||
self.add_api_route("/sdapi/v1/server-kill", self.kill_webui, methods=["POST"])
|
||||
|
||||
@@ -126,4 +126,3 @@ parser.add_argument("--skip-load-model-at-start", action='store_true', help="if
|
||||
parser.add_argument("--unix-filenames-sanitization", action='store_true', help="allow any symbols except '/' in filenames. May conflict with your browser and file system")
|
||||
parser.add_argument("--filenames-max-length", type=int, default=128, help='maximal length of filenames of saved images. If you override it, it can conflict with your file system')
|
||||
parser.add_argument("--no-prompt-history", action='store_true', help="disable read prompt from last generation feature; settings this argument will not create '--data_path/params.txt' file")
|
||||
parser.add_argument("--uv", action='store_true', help="use the uv package manager")
|
||||
|
||||
+2
-30
@@ -1,7 +1,7 @@
|
||||
import hashlib
|
||||
import os.path
|
||||
|
||||
from modules import shared, errors
|
||||
from modules import shared
|
||||
import modules.cache
|
||||
|
||||
dump_cache = modules.cache.dump_cache
|
||||
@@ -32,7 +32,7 @@ def sha256_from_cache(filename, title, use_addnet_hash=False):
|
||||
cached_sha256 = hashes[title].get("sha256", None)
|
||||
cached_mtime = hashes[title].get("mtime", 0)
|
||||
|
||||
if ondisk_mtime != cached_mtime or cached_sha256 is None:
|
||||
if ondisk_mtime > cached_mtime or cached_sha256 is None:
|
||||
return None
|
||||
|
||||
return cached_sha256
|
||||
@@ -82,31 +82,3 @@ def addnet_hash_safetensors(b):
|
||||
|
||||
return hash_sha256.hexdigest()
|
||||
|
||||
|
||||
def partial_hash_from_cache(filename, *, ignore_cache: bool = False, digits: int = 8):
|
||||
"""old hash that only looks at a small part of the file and is prone to collisions
|
||||
kept for compatibility, don't use this for new things
|
||||
"""
|
||||
try:
|
||||
filename = str(filename)
|
||||
mtime = os.path.getmtime(filename)
|
||||
hashes = cache('partial-hash')
|
||||
cache_entry = hashes.get(filename, {})
|
||||
cache_mtime = cache_entry.get("mtime", 0)
|
||||
cache_hash = cache_entry.get("hash", None)
|
||||
if mtime == cache_mtime and cache_hash and not ignore_cache:
|
||||
return cache_hash[0:digits]
|
||||
|
||||
with open(filename, 'rb') as file:
|
||||
m = hashlib.sha256()
|
||||
file.seek(0x100000)
|
||||
m.update(file.read(0x10000))
|
||||
partial_hash = m.hexdigest()
|
||||
hashes[filename] = {'mtime': mtime, 'hash': partial_hash}
|
||||
return partial_hash[0:digits]
|
||||
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except Exception:
|
||||
errors.report(f'Error calculating partial hash for {filename}', exc_info=True)
|
||||
return 'NOFILE'
|
||||
|
||||
@@ -409,7 +409,6 @@ class FilenameGenerator:
|
||||
'generation_number': lambda self: NOTHING_AND_SKIP_PREVIOUS_TEXT if (self.p.n_iter == 1 and self.p.batch_size == 1) or self.zip else self.p.iteration * self.p.batch_size + self.p.batch_index + 1,
|
||||
'hasprompt': lambda self, *args: self.hasprompt(*args), # accepts formats:[hasprompt<prompt1|default><prompt2>..]
|
||||
'clip_skip': lambda self: opts.data["CLIP_stop_at_last_layers"],
|
||||
'randn_source': lambda self: opts.data["randn_source"],
|
||||
'denoising': lambda self: self.p.denoising_strength if self.p and self.p.denoising_strength else NOTHING_AND_SKIP_PREVIOUS_TEXT,
|
||||
'user': lambda self: self.p.user,
|
||||
'vae_filename': lambda self: self.get_vae_filename(),
|
||||
|
||||
+3
-50
@@ -313,56 +313,9 @@ def requirements_met(requirements_file):
|
||||
return True
|
||||
|
||||
|
||||
def get_cuda_comp_cap():
|
||||
"""
|
||||
Returns float of CUDA Compute Capability using nvidia-smi
|
||||
Returns 0.0 on error
|
||||
CUDA Compute Capability
|
||||
ref https://developer.nvidia.com/cuda-gpus
|
||||
ref https://en.wikipedia.org/wiki/CUDA
|
||||
Blackwell consumer GPUs should return 12.0 data-center GPUs should return 10.0
|
||||
"""
|
||||
try:
|
||||
return max(map(float, subprocess.check_output(['nvidia-smi', '--query-gpu=compute_cap', '--format=noheader,csv'], text=True).splitlines()))
|
||||
except Exception as _:
|
||||
return 0.0
|
||||
|
||||
|
||||
def early_access_blackwell_wheels():
|
||||
"""For Blackwell GPUs, use Early Access PyTorch Wheels provided by Nvidia"""
|
||||
print('deprecated early_access_blackwell_wheels')
|
||||
if all([
|
||||
os.environ.get('TORCH_INDEX_URL') is None,
|
||||
sys.version_info.major == 3,
|
||||
sys.version_info.minor in (10, 11, 12),
|
||||
platform.system() == "Windows",
|
||||
get_cuda_comp_cap() >= 10, # Blackwell
|
||||
]):
|
||||
base_repo = 'https://huggingface.co/w-e-w/torch-2.6.0-cu128.nv/resolve/main/'
|
||||
ea_whl = {
|
||||
10: f'{base_repo}torch-2.6.0+cu128.nv-cp310-cp310-win_amd64.whl#sha256=fef3de7ce8f4642e405576008f384304ad0e44f7b06cc1aa45e0ab4b6e70490d {base_repo}torchvision-0.20.0a0+cu128.nv-cp310-cp310-win_amd64.whl#sha256=50841254f59f1db750e7348b90a8f4cd6befec217ab53cbb03780490b225abef',
|
||||
11: f'{base_repo}torch-2.6.0+cu128.nv-cp311-cp311-win_amd64.whl#sha256=6665c36e6a7e79e7a2cb42bec190d376be9ca2859732ed29dd5b7b5a612d0d26 {base_repo}torchvision-0.20.0a0+cu128.nv-cp311-cp311-win_amd64.whl#sha256=bbc0ee4938e35fe5a30de3613bfcd2d8ef4eae334cf8d49db860668f0bb47083',
|
||||
12: f'{base_repo}torch-2.6.0+cu128.nv-cp312-cp312-win_amd64.whl#sha256=a3197f72379d34b08c4a4bcf49ea262544a484e8702b8c46cbcd66356c89def6 {base_repo}torchvision-0.20.0a0+cu128.nv-cp312-cp312-win_amd64.whl#sha256=235e7be71ac4e75b0f8e817bae4796d7bac8a67146d2037ab96394f2bdc63e6c'
|
||||
}
|
||||
return f'pip install {ea_whl.get(sys.version_info.minor)}'
|
||||
|
||||
|
||||
def get_default_torch_index_url():
|
||||
"""Choose default torch index url based on GPU CUDA Compute Capability (CC)
|
||||
Use cu126 for CC <= 7.2, cu128 for CC > 7.2
|
||||
PyTorch have dropped support for older GPUs on their cu128 and above wheels,
|
||||
For Nvidia 10 series and older GPUs (CC < 7.0) should use cu126 wheels
|
||||
Since GPUs with CC <= 7.2 are considered legacy by Nvidia
|
||||
ref 2025-11-07 https://developer.nvidia.com/cuda-legacy-gpus
|
||||
"""
|
||||
if get_cuda_comp_cap() <= 7.2:
|
||||
return "https://download.pytorch.org/whl/cu126"
|
||||
return "https://download.pytorch.org/whl/cu128"
|
||||
|
||||
|
||||
def prepare_environment():
|
||||
torch_index_url = os.environ.get('TORCH_INDEX_URL', get_default_torch_index_url())
|
||||
torch_command = os.environ.get('TORCH_COMMAND', f"pip install torch==2.7.0 torchvision==0.22.0 --extra-index-url {torch_index_url}")
|
||||
torch_index_url = os.environ.get('TORCH_INDEX_URL', "https://download.pytorch.org/whl/cu121")
|
||||
torch_command = os.environ.get('TORCH_COMMAND', f"pip install torch==2.1.2 torchvision==0.16.2 --extra-index-url {torch_index_url}")
|
||||
if args.use_ipex:
|
||||
if platform.system() == "Windows":
|
||||
# The "Nuullll/intel-extension-for-pytorch" wheels were built from IPEX source for Intel Arc GPU: https://github.com/intel/intel-extension-for-pytorch/tree/xpu-main
|
||||
@@ -386,7 +339,7 @@ def prepare_environment():
|
||||
requirements_file = os.environ.get('REQS_FILE', "requirements_versions.txt")
|
||||
requirements_file_for_npu = os.environ.get('REQS_FILE_FOR_NPU', "requirements_npu.txt")
|
||||
|
||||
xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.30')
|
||||
xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.23.post1')
|
||||
clip_package = os.environ.get('CLIP_PACKAGE', "https://github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip")
|
||||
openclip_package = os.environ.get('OPENCLIP_PACKAGE', "https://github.com/mlfoundations/open_clip/archive/bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b.zip")
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class SdOptimizationXformers(SdOptimization):
|
||||
priority = 100
|
||||
|
||||
def is_available(self):
|
||||
return shared.cmd_opts.force_enable_xformers or (shared.xformers_available and torch.cuda.is_available() and (6, 0) <= torch.cuda.get_device_capability(shared.device) <= (12, 0))
|
||||
return shared.cmd_opts.force_enable_xformers or (shared.xformers_available and torch.cuda.is_available() and (6, 0) <= torch.cuda.get_device_capability(shared.device) <= (9, 0))
|
||||
|
||||
def apply(self):
|
||||
ldm.modules.attention.CrossAttention.forward = xformers_attention_forward
|
||||
|
||||
+16
-2
@@ -13,7 +13,6 @@ from urllib import request
|
||||
import ldm.modules.midas as midas
|
||||
|
||||
from modules import paths, shared, modelloader, devices, script_callbacks, sd_vae, sd_disable_initialization, errors, hashes, sd_models_config, sd_unet, sd_models_xl, cache, extra_networks, processing, lowvram, sd_hijack, patches
|
||||
from modules.hashes import partial_hash_from_cache as model_hash # noqa: F401 for backwards compatibility
|
||||
from modules.timer import Timer
|
||||
from modules.shared import opts
|
||||
import tomesd
|
||||
@@ -88,7 +87,7 @@ class CheckpointInfo:
|
||||
self.name = name
|
||||
self.name_for_extra = os.path.splitext(os.path.basename(filename))[0]
|
||||
self.model_name = os.path.splitext(name.replace("/", "_").replace("\\", "_"))[0]
|
||||
self.hash = hashes.partial_hash_from_cache(filename)
|
||||
self.hash = model_hash(filename)
|
||||
|
||||
self.sha256 = hashes.sha256_from_cache(self.filename, f"checkpoint/{name}")
|
||||
self.shorthash = self.sha256[0:10] if self.sha256 else None
|
||||
@@ -201,6 +200,21 @@ def get_closet_checkpoint_match(search_string):
|
||||
return None
|
||||
|
||||
|
||||
def model_hash(filename):
|
||||
"""old hash that only looks at a small part of the file and is prone to collisions"""
|
||||
|
||||
try:
|
||||
with open(filename, "rb") as file:
|
||||
import hashlib
|
||||
m = hashlib.sha256()
|
||||
|
||||
file.seek(0x100000)
|
||||
m.update(file.read(0x10000))
|
||||
return m.hexdigest()[0:8]
|
||||
except FileNotFoundError:
|
||||
return 'NOFILE'
|
||||
|
||||
|
||||
def select_checkpoint():
|
||||
"""Raises `FileNotFoundError` if no checkpoints are found."""
|
||||
model_checkpoint = shared.opts.sd_model_checkpoint
|
||||
|
||||
@@ -117,15 +117,12 @@ def ddim_scheduler(n, sigma_min, sigma_max, inner_model, device):
|
||||
|
||||
|
||||
def beta_scheduler(n, sigma_min, sigma_max, inner_model, device):
|
||||
# From "Beta Sampling is All You Need" [arXiv:2407.12173] (Lee et. al, 2024)
|
||||
# From "Beta Sampling is All You Need" [arXiv:2407.12173] (Lee et. al, 2024) """
|
||||
alpha = shared.opts.beta_dist_alpha
|
||||
beta = shared.opts.beta_dist_beta
|
||||
curve = [stats.beta.ppf(x, alpha, beta) for x in np.linspace(1, 0, n)]
|
||||
|
||||
start = inner_model.sigma_to_t(torch.tensor(sigma_max))
|
||||
end = inner_model.sigma_to_t(torch.tensor(sigma_min))
|
||||
timesteps = [end + x * (start - end) for x in curve]
|
||||
sigmas = [inner_model.t_to_sigma(ts) for ts in timesteps]
|
||||
timesteps = 1 - np.linspace(0, 1, n)
|
||||
timesteps = [stats.beta.ppf(x, alpha, beta) for x in timesteps]
|
||||
sigmas = [sigma_min + (x * (sigma_max-sigma_min)) for x in timesteps]
|
||||
sigmas += [0.0]
|
||||
return torch.FloatTensor(sigmas).to(device)
|
||||
|
||||
|
||||
@@ -407,8 +407,8 @@ options_templates.update(options_section(('sampler-params', "Sampler parameters"
|
||||
'uni_pc_lower_order_final': OptionInfo(True, "UniPC lower order final", infotext='UniPC lower order final'),
|
||||
'sd_noise_schedule': OptionInfo("Default", "Noise schedule for sampling", gr.Radio, {"choices": ["Default", "Zero Terminal SNR"]}, infotext="Noise Schedule").info("for use with zero terminal SNR trained models"),
|
||||
'skip_early_cond': OptionInfo(0.0, "Ignore negative prompt during early sampling", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}, infotext="Skip Early CFG").info("disables CFG on a proportion of steps at the beginning of generation; 0=skip none; 1=skip all; can both improve sample diversity/quality and speed up sampling; XYZ plot: Skip Early CFG"),
|
||||
'beta_dist_alpha': OptionInfo(0.6, "Beta scheduler - alpha", gr.Slider, {"minimum": 0.01, "maximum": 5.0, "step": 0.01}, infotext='Beta scheduler alpha').info('Default = 0.6; the alpha parameter of the beta distribution used in Beta sampling'),
|
||||
'beta_dist_beta': OptionInfo(0.6, "Beta scheduler - beta", gr.Slider, {"minimum": 0.01, "maximum": 5.0, "step": 0.01}, infotext='Beta scheduler beta').info('Default = 0.6; the beta parameter of the beta distribution used in Beta sampling'),
|
||||
'beta_dist_alpha': OptionInfo(0.6, "Beta scheduler - alpha", gr.Slider, {"minimum": 0.01, "maximum": 1.0, "step": 0.01}, infotext='Beta scheduler alpha').info('Default = 0.6; the alpha parameter of the beta distribution used in Beta sampling'),
|
||||
'beta_dist_beta': OptionInfo(0.6, "Beta scheduler - beta", gr.Slider, {"minimum": 0.01, "maximum": 1.0, "step": 0.01}, infotext='Beta scheduler beta').info('Default = 0.6; the beta parameter of the beta distribution used in Beta sampling'),
|
||||
}))
|
||||
|
||||
options_templates.update(options_section(('postprocessing', "Postprocessing", "postprocessing"), {
|
||||
|
||||
@@ -213,3 +213,13 @@ def get_config():
|
||||
return json.load(f)
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
|
||||
|
||||
def download_sysinfo(attachment=False):
|
||||
from fastapi.responses import PlainTextResponse
|
||||
from datetime import datetime
|
||||
|
||||
text = get()
|
||||
filename = f"sysinfo-{datetime.utcnow().strftime('%Y-%m-%d-%H-%M')}.json"
|
||||
|
||||
return PlainTextResponse(text, headers={'Content-Disposition': f'{"attachment" if attachment else "inline"}; filename="{filename}"'})
|
||||
|
||||
+2
-14
@@ -1,4 +1,3 @@
|
||||
import datetime
|
||||
import mimetypes
|
||||
import os
|
||||
import sys
|
||||
@@ -10,10 +9,10 @@ import gradio as gr
|
||||
import gradio.utils
|
||||
import numpy as np
|
||||
from PIL import Image, PngImagePlugin # noqa: F401
|
||||
from modules.call_queue import wrap_gradio_gpu_call, wrap_queued_call, wrap_gradio_call, wrap_gradio_call_no_job # noqa: F401
|
||||
from modules.call_queue import wrap_gradio_gpu_call, wrap_queued_call, wrap_gradio_call, wrap_gradio_call_no_job # noqa: F401
|
||||
|
||||
from modules import gradio_extensons, sd_schedulers # noqa: F401
|
||||
from modules import sd_hijack, sd_models, script_callbacks, ui_extensions, deepbooru, extra_networks, ui_common, ui_postprocessing, progress, ui_loadsave, shared_items, ui_settings, timer, sysinfo, ui_checkpoint_merger, scripts, sd_samplers, processing, ui_extra_networks, ui_toprow, launch_utils
|
||||
from modules import sd_hijack, sd_models, script_callbacks, ui_extensions, deepbooru, extra_networks, ui_common, ui_postprocessing, progress, ui_loadsave, shared_items, ui_settings, timer, ui_checkpoint_merger, scripts, sd_samplers, processing, ui_extra_networks, ui_toprow, launch_utils
|
||||
from modules.ui_components import FormRow, FormGroup, ToolButton, FormHTML, InputAccordion, ResizeHandleRow
|
||||
from modules.paths import script_path
|
||||
from modules.ui_common import create_refresh_button
|
||||
@@ -1223,16 +1222,5 @@ def setup_ui_api(app):
|
||||
|
||||
app.add_api_route("/internal/profile-startup", lambda: timer.startup_record, methods=["GET"])
|
||||
|
||||
def download_sysinfo(attachment=False):
|
||||
from fastapi.responses import PlainTextResponse
|
||||
|
||||
text = sysinfo.get()
|
||||
filename = f"sysinfo-{datetime.datetime.utcnow().strftime('%Y-%m-%d-%H-%M')}.json"
|
||||
|
||||
return PlainTextResponse(text, headers={'Content-Disposition': f'{"attachment" if attachment else "inline"}; filename="{filename}"'})
|
||||
|
||||
app.add_api_route("/internal/sysinfo", download_sysinfo, methods=["GET"])
|
||||
app.add_api_route("/internal/sysinfo-download", lambda: download_sysinfo(attachment=True), methods=["GET"])
|
||||
|
||||
import fastapi.staticfiles
|
||||
app.mount("/webui-assets", fastapi.staticfiles.StaticFiles(directory=launch_utils.repo_dir('stable-diffusion-webui-assets')), name="webui-assets")
|
||||
|
||||
+25
-3
@@ -1,12 +1,13 @@
|
||||
import gradio as gr
|
||||
|
||||
from modules import ui_common, shared, script_callbacks, scripts, sd_models, sysinfo, timer, shared_items
|
||||
from modules import ui_common, shared, script_callbacks, scripts, sd_models, sysinfo, timer, shared_items, paths_internal, util
|
||||
from modules.call_queue import wrap_gradio_call_no_job
|
||||
from modules.options import options_section
|
||||
from modules.shared import opts
|
||||
from modules.ui_components import FormRow
|
||||
from modules.ui_gradio_extensions import reload_javascript
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def get_value_for_setting(key):
|
||||
@@ -170,7 +171,28 @@ class UiSettings:
|
||||
loadsave.create_ui()
|
||||
|
||||
with gr.TabItem("Sysinfo", id="sysinfo", elem_id="settings_tab_sysinfo"):
|
||||
gr.HTML('<a href="./internal/sysinfo-download" class="sysinfo_big_link" download>Download system info</a><br /><a href="./internal/sysinfo" target="_blank">(or open as text in a new page)</a>', elem_id="sysinfo_download")
|
||||
download_sysinfo = gr.Button(value='Download system info', elem_id="internal-download-sysinfo", visible=False)
|
||||
open_sysinfo = gr.Button(value='Open as text in a new page', elem_id="internal-open-sysinfo", visible=False)
|
||||
sysinfo_html = gr.HTML('''<a class="sysinfo_big_link" onclick="gradioApp().getElementById('internal-download-sysinfo').click();">Download system info</a><br/><a onclick="gradioApp().getElementById('internal-open-sysinfo').click();">(or open as text in a new page)</a>''', elem_id="sysinfo_download")
|
||||
sysinfo_textbox = gr.Textbox(label='Sysinfo textarea', elem_id="internal-sysinfo-textbox", visible=False)
|
||||
|
||||
def create_sysinfo():
|
||||
sysinfo_str = sysinfo.get()
|
||||
if len(sysinfo_utf8 := sysinfo_str.encode('utf8')) > 2 ** 20: # 1MB
|
||||
sysinfo_path = Path(paths_internal.script_path) / 'tmp' / 'sysinfo.json'
|
||||
sysinfo_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
sysinfo_path.write_bytes(sysinfo_utf8)
|
||||
return gr.update(), gr.update(value=f'file={util.truncate_path(sysinfo_path)}')
|
||||
return gr.update(), gr.update(value=sysinfo_str)
|
||||
|
||||
download_sysinfo.click(
|
||||
fn=create_sysinfo, outputs=[sysinfo_html, sysinfo_textbox], show_progress=True).success(
|
||||
fn=None, _js='downloadSysinfo'
|
||||
)
|
||||
open_sysinfo.click(
|
||||
fn=create_sysinfo, outputs=[sysinfo_html, sysinfo_textbox], show_progress=True).success(
|
||||
fn=None, _js='openTabSysinfo'
|
||||
)
|
||||
|
||||
with gr.Row():
|
||||
with gr.Column(scale=1):
|
||||
@@ -313,7 +335,7 @@ class UiSettings:
|
||||
|
||||
for method in methods:
|
||||
method(
|
||||
fn=lambda value, k=k: self.run_settings_single(value, key=k),
|
||||
fn=lambda value, key=k: self.run_settings_single(value, key=key),
|
||||
inputs=[component],
|
||||
outputs=[component, self.text_settings],
|
||||
show_progress=info.refresh is not None,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from __future__ import annotations
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
import sys
|
||||
import copy
|
||||
import shlex
|
||||
import subprocess
|
||||
from functools import wraps
|
||||
|
||||
BAD_FLAGS = ("--prefer-binary", '-I', '--ignore-installed')
|
||||
|
||||
|
||||
def patch():
|
||||
if hasattr(subprocess, "__original_run"):
|
||||
return
|
||||
|
||||
print("using uv")
|
||||
try:
|
||||
subprocess.run(['uv', '-V'])
|
||||
except FileNotFoundError:
|
||||
subprocess.run([sys.executable, '-m', 'pip', 'install', 'uv'])
|
||||
|
||||
subprocess.__original_run = subprocess.run
|
||||
|
||||
@wraps(subprocess.__original_run)
|
||||
def patched_run(*args, **kwargs):
|
||||
_kwargs = copy.copy(kwargs)
|
||||
if args:
|
||||
command, *_args = args
|
||||
else:
|
||||
command, _args = _kwargs.pop("args", ""), ()
|
||||
|
||||
if isinstance(command, str):
|
||||
command = shlex.split(command)
|
||||
else:
|
||||
command = [arg.strip() for arg in command]
|
||||
|
||||
if not isinstance(command, list) or "pip" not in command:
|
||||
return subprocess.__original_run(*args, **kwargs)
|
||||
|
||||
cmd = command[command.index("pip") + 1:]
|
||||
|
||||
cmd = [arg for arg in cmd if arg not in BAD_FLAGS]
|
||||
|
||||
modified_command = ["uv", "pip", *cmd]
|
||||
|
||||
cmd_str = shlex.join([*modified_command, *_args])
|
||||
result = subprocess.__original_run(cmd_str, **_kwargs)
|
||||
if result.returncode != 0:
|
||||
return subprocess.__original_run(*args, **kwargs)
|
||||
return result
|
||||
|
||||
subprocess.run = patched_run
|
||||
@@ -182,7 +182,7 @@ document.addEventListener('keydown', function(e) {
|
||||
const lightboxModal = document.querySelector('#lightboxModal');
|
||||
if (!globalPopup || globalPopup.style.display === 'none') {
|
||||
if (document.activeElement === lightboxModal) return;
|
||||
if (interruptButton?.style.display === 'block') {
|
||||
if (interruptButton.style.display === 'block') {
|
||||
interruptButton.click();
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
@@ -480,10 +480,8 @@ div.toprow-compact-tools{
|
||||
}
|
||||
|
||||
#settings_result{
|
||||
min-height: 1.4em;
|
||||
height: 1.4em;
|
||||
margin: 0 1.2em;
|
||||
max-height: calc(var(--text-md) * var(--line-sm) * 5);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
table.popup-table{
|
||||
@@ -602,7 +600,6 @@ table.popup-table .link{
|
||||
background: var(--background-fill-primary);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.livePreview img{
|
||||
|
||||
Reference in New Issue
Block a user