AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
142.66k stars 26.91k forks source link

[Bug]: Upscaling takes very long on new webui #13431

Closed PixelGames987 closed 1 year ago

PixelGames987 commented 1 year ago

Is there an existing issue for this?

What happened?

I've recently updated to new version of the webui (v1.6.0). I noticed that the upscaling with SwinIR 4x takes very long to compute. On older versions of the webui the upscaling 4x took around 1 minute and around 6s/it, however on the newer version it takes around 4 minutes to compute at 30s/it speed.

Steps to reproduce the problem

  1. Go to Extras tab.
  2. Import image to upscale.
  3. Select SwinIR 4x upscaler.
  4. Click Generate.
  5. It takes 4 minutes for upscaling.

What should have happened?

It shoud only take less than 1 minute to upscale.

Sysinfo

{ "Platform": "Windows-10-10.0.19045-SP0", "Python": "3.10.6", "Version": "v1.6.0", "Commit": "5ef669de080814067961f28357256e8fe27544f4", "Script path": "D:\sd\stable-diffusion-webui", "Data path": "D:\sd\stable-diffusion-webui", "Extensions dir": "D:\sd\stable-diffusion-webui\extensions", "Checksum": "db43ba31f2b8e46f72c29e5f3cd81e7292eb393c5b91d677f0022fd46e996f7d", "Commandline": [ "launch.py", "--xformers", "--no-half", "--precision", "full" ], "Torch env info": { "torch_version": "2.0.1+cu118", "is_debug_build": "False", "cuda_compiled_version": "11.8", "gcc_version": null, "clang_version": null, "cmake_version": null, "os": "Microsoft Windows 10 Pro", "libc_version": "N/A", "python_version": "3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] (64-bit runtime)", "python_platform": "Windows-10-10.0.19045-SP0", "is_cuda_available": "True", "cuda_runtime_version": null, "cuda_module_loading": "LAZY", "nvidia_driver_version": "537.42", "nvidia_gpu_models": "GPU 0: NVIDIA GeForce GTX 1660 Ti", "cudnn_version": null, "pip_version": "pip3", "pip_packages": [ "numpy==1.23.5", "open-clip-torch==2.20.0", "pytorch-lightning==1.9.4", "torch==2.0.1+cu118", "torchdiffeq==0.2.3", "torchmetrics==1.2.0", "torchsde==0.2.5", "torchvision==0.15.2+cu118" ], "conda_packages": null, "hip_compiled_version": "N/A", "hip_runtime_version": "N/A", "miopen_runtime_version": "N/A", "caching_allocator_config": "", "is_xnnpack_available": "True", "cpu_info": [ "Architecture=9", "CurrentClockSpeed=2904", "DeviceID=CPU0", "Family=205", "L2CacheSize=1536", "L2CacheSpeed=", "Manufacturer=GenuineIntel", "MaxClockSpeed=2904", "Name=Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz", "ProcessorType=3", "Revision=" ] }, "Exceptions": [], "CPU": { "model": "Intel64 Family 6 Model 158 Stepping 10, GenuineIntel", "count logical": 6, "count physical": 6 }, "RAM": { "total": "16GB", "used": "10GB", "free": "6GB" }, "Extensions": [], "Inactive extensions": [], "Environment": { "COMMANDLINE_ARGS": " --xformers --no-half --precision full", "GRADIO_ANALYTICS_ENABLED": "False" }, "Config": { "samples_save": true, "samples_format": "png", "samples_filename_pattern": "", "save_images_add_number": true, "grid_save": true, "grid_format": "png", "grid_extended_filename": false, "grid_only_if_multiple": true, "grid_prevent_empty_spots": false, "grid_zip_filename_pattern": "", "n_rows": -1, "font": "", "grid_text_active_color": "#000000", "grid_text_inactive_color": "#999999", "grid_background_color": "#ffffff", "enable_pnginfo": true, "save_txt": false, "save_images_before_face_restoration": false, "save_images_before_highres_fix": false, "save_images_before_color_correction": false, "save_mask": false, "save_mask_composite": false, "jpeg_quality": 80, "webp_lossless": false, "export_for_4chan": true, "img_downscale_threshold": 4.0, "target_side_length": 4000, "img_max_size_mp": 200, "use_original_name_batch": true, "use_upscaler_name_as_suffix": false, "save_selected_only": true, "save_init_img": false, "temp_dir": "", "clean_temp_dir_at_start": false, "save_incomplete_images": false, "outdir_samples": "", "outdir_txt2img_samples": "outputs/txt2img-images", "outdir_img2img_samples": "outputs/img2img-images", "outdir_extras_samples": "outputs/extras-images", "outdir_grids": "", "outdir_txt2img_grids": "outputs/txt2img-grids", "outdir_img2img_grids": "outputs/img2img-grids", "outdir_save": "log/images", "outdir_init_images": "outputs/init-images", "save_to_dirs": true, "grid_save_to_dirs": true, "use_save_to_dirs_for_ui": false, "directories_filename_pattern": "[date]", "directories_max_prompt_words": 8, "ESRGAN_tile": 192, "ESRGAN_tile_overlap": 8, "realesrgan_enabled_models": [ "R-ESRGAN 4x+", "R-ESRGAN 4x+ Anime6B" ], "upscaler_for_img2img": null, "face_restoration": false, "face_restoration_model": "CodeFormer", "code_former_weight": 0.5, "face_restoration_unload": false, "auto_launch_browser": "Local", "show_warnings": false, "show_gradio_deprecation_warnings": true, "memmon_poll_rate": 8, "samples_log_stdout": false, "multiple_tqdm": true, "print_hypernet_extra": false, "list_hidden_files": true, "disable_mmap_load_safetensors": false, "hide_ldm_prints": true, "api_enable_requests": true, "api_forbid_local_requests": true, "api_useragent": "", "unload_models_when_training": false, "pin_memory": false, "save_optimizer_state": false, "save_training_settings_to_txt": true, "dataset_filename_word_regex": "", "dataset_filename_join_string": " ", "training_image_repeats_per_epoch": 1, "training_write_csv_every": 500, "training_xattention_optimizations": false, "training_enable_tensorboard": false, "training_tensorboard_save_images": false, "training_tensorboard_flush_every": 120, "sd_model_checkpoint": "(model K)deliberate_v3(portraiture, landscapes, fantastical topics).safetensors [aadddd3d75]", "sd_checkpoints_limit": 2, "sd_checkpoints_keep_in_cpu": true, "sd_checkpoint_cache": 0, "sd_unet": "Automatic", "enable_quantization": false, "enable_emphasis": true, "enable_batch_seeds": true, "comma_padding_backtrack": 20, "CLIP_stop_at_last_layers": 1, "upcast_attn": false, "randn_source": "GPU", "tiling": false, "hires_fix_refiner_pass": "second pass", "sdxl_crop_top": 0, "sdxl_crop_left": 0, "sdxl_refiner_low_aesthetic_score": 2.5, "sdxl_refiner_high_aesthetic_score": 6.0, "sd_vae_explanation": "VAE is a neural network that transforms a standard RGB\nimage into latent space representation and back. Latent space representation is what stable diffusion is working on during sampling\n(i.e. when the progress bar is between empty and full). For txt2img, VAE is used to create a resulting image after the sampling is finished.\nFor img2img, VAE is used to process user's input image before the sampling, and to create an image after sampling.", "sd_vae_checkpoint_cache": 0, "sd_vae": "Automatic", "sd_vae_overrides_per_model_preferences": true, "auto_vae_precision": true, "sd_vae_encode_method": "Full", "sd_vae_decode_method": "Full", "inpainting_mask_weight": 1.0, "initial_noise_multiplier": 1.0, "img2img_extra_noise": 0.0, "img2img_color_correction": false, "img2img_fix_steps": false, "img2img_background_color": "#ffffff", "img2img_editor_height": 720, "img2img_sketch_default_brush_color": "#ffffff", "img2img_inpaint_mask_brush_color": "#ffffff", "img2img_inpaint_sketch_default_brush_color": "#ffffff", "return_mask": false, "return_mask_composite": false, "cross_attention_optimization": "Automatic", "s_min_uncond": 3, "token_merging_ratio": 0.2, "token_merging_ratio_img2img": 0.0, "token_merging_ratio_hr": 0.0, "pad_cond_uncond": false, "persistent_cond_cache": true, "batch_cond_uncond": true, "use_old_emphasis_implementation": false, "use_old_karras_scheduler_sigmas": false, "no_dpmpp_sde_batch_determinism": false, "use_old_hires_fix_width_height": false, "dont_fix_second_order_samplers_schedule": false, "hires_fix_use_firstpass_conds": false, "use_old_scheduling": false, "interrogate_keep_models_in_memory": false, "interrogate_return_ranks": false, "interrogate_clip_num_beams": 1, "interrogate_clip_min_length": 24, "interrogate_clip_max_length": 48, "interrogate_clip_dict_limit": 1500, "interrogate_clip_skip_categories": [], "interrogate_deepbooru_score_threshold": 0.5, "deepbooru_sort_alpha": true, "deepbooru_use_spaces": true, "deepbooru_escape": true, "deepbooru_filter_tags": "", "extra_networks_show_hidden_directories": true, "extra_networks_hidden_models": "When searched", "extra_networks_default_multiplier": 1.0, "extra_networks_card_width": 0, "extra_networks_card_height": 0, "extra_networks_card_text_scale": 1.0, "extra_networks_card_show_desc": true, "extra_networks_add_text_separator": " ", "ui_extra_networks_tab_reorder": "", "textual_inversion_print_at_load": false, "textual_inversion_add_hashes_to_infotext": true, "sd_hypernetwork": "None", "localization": "None", "gradio_theme": "Default", "gradio_themes_cache": true, "gallery_height": "", "return_grid": true, "do_not_show_images": false, "send_seed": true, "send_size": true, "js_modal_lightbox": true, "js_modal_lightbox_initially_zoomed": true, "js_modal_lightbox_gamepad": false, "js_modal_lightbox_gamepad_repeat": 250, "show_progress_in_title": true, "samplers_in_dropdown": true, "dimensions_and_batch_together": true, "keyedit_precision_attention": 0.1, "keyedit_precision_extra": 0.05, "keyedit_delimiters": ".,\/!?%^*;:{}=`~()", "keyedit_move": true, "quicksettings_list": [ "sd_model_checkpoint" ], "ui_tab_order": [], "hidden_tabs": [], "ui_reorder_list": [], "hires_fix_show_sampler": false, "hires_fix_show_prompts": false, "disable_token_counters": false, "add_model_hash_to_info": true, "add_model_name_to_info": true, "add_user_name_to_info": false, "add_version_to_infotext": true, "disable_weights_auto_swap": true, "infotext_styles": "Apply if any", "show_progressbar": true, "live_previews_enable": true, "live_previews_image_format": "png", "show_progress_grid": true, "show_progress_every_n_steps": 10, "show_progress_type": "Approx NN", "live_preview_allow_lowvram_full": false, "live_preview_content": "Prompt", "live_preview_refresh_period": 1000, "live_preview_fast_interrupt": false, "hide_samplers": [], "eta_ddim": 0.0, "eta_ancestral": 1.0, "ddim_discretize": "uniform", "s_churn": 0.0, "s_tmin": 0.0, "s_tmax": 0.0, "s_noise": 1.0, "k_sched_type": "Automatic", "sigma_min": 0.0, "sigma_max": 0.0, "rho": 0.0, "eta_noise_seed_delta": 0, "always_discard_next_to_last_sigma": false, "sgm_noise_multiplier": false, "uni_pc_variant": "bh1", "uni_pc_skip_type": "time_uniform", "uni_pc_order": 3, "uni_pc_lower_order_final": true, "postprocessing_enable_in_main_ui": [], "postprocessing_operation_order": [], "upscaling_max_images_in_cache": 5, "disabled_extensions": [], "disable_all_extensions": "none", "restore_config_state_file": "", "sd_checkpoint_hash": "aadddd3d7579de79db91f4ac03f2fbad4e9b71216bbebb50c338cae74b77cb27", "ldsr_steps": 100, "ldsr_cached": false, "SCUNET_tile": 256, "SCUNET_tile_overlap": 8, "SWIN_tile": 192, "SWIN_tile_overlap": 8, "lora_functional": false, "sd_lora": "None", "lora_preferred_name": "Alias from file", "lora_add_hashes_to_infotext": true, "lora_show_all": false, "lora_hide_unknown_for_versions": [], "lora_in_memory_limit": 0, "extra_options_txt2img": [], "extra_options_img2img": [], "extra_options_cols": 1, "extra_options_accordion": false, "canvas_hotkey_zoom": "Alt", "canvas_hotkey_adjust": "Ctrl", "canvas_hotkey_move": "F", "canvas_hotkey_fullscreen": "S", "canvas_hotkey_reset": "R", "canvas_hotkey_overlap": "O", "canvas_show_tooltip": true, "canvas_auto_expand": true, "canvas_blur_prompt": false, "canvas_disabled_functions": [ "Overlap" ] }, "Startup": { "total": 53.94842529296875, "records": { "initial startup": 0.0015540122985839844, "prepare environment/checks": 0.027957677841186523, "prepare environment/git version info": 0.6847691535949707, "prepare environment/torch GPU test": 14.831487894058228, "prepare environment/clone repositores": 0.6099388599395752, "prepare environment/run extensions installers": 0.0359797477722168, "prepare environment": 16.317123889923096, "launcher": 0.03930330276489258, "import torch": 12.420854806900024, "import gradio": 4.365011692047119, "setup paths": 6.033649444580078, "import ldm": 0.1042473316192627, "import sgm": 0.0, "initialize shared": 0.7441427707672119, "other imports": 4.763035774230957, "opts onchange": 0.001008749008178711, "setup SD model": 0.005956172943115234, "setup codeformer": 0.7016701698303223, "setup gfpgan": 0.08949589729309082, "set samplers": 0.0, "list extensions": 0.001996278762817383, "restore config state file": 0.0, "list SD models": 0.28972411155700684, "list localizations": 0.005984067916870117, "load scripts/custom_code.py": 0.05230259895324707, "load scripts/img2imgalt.py": 0.001993894577026367, "load scripts/loopback.py": 0.0024106502532958984, "load scripts/outpainting_mk_2.py": 0.002080202102661133, "load scripts/poor_mans_outpainting.py": 0.0005669593811035156, "load scripts/postprocessing_codeformer.py": 0.0010013580322265625, "load scripts/postprocessing_gfpgan.py": 0.0019948482513427734, "load scripts/postprocessing_upscale.py": 0.0010187625885009766, "load scripts/prompt_matrix.py": 0.0010008811950683594, "load scripts/prompts_from_file.py": 0.0009708404541015625, "load scripts/refiner.py": 0.0015902519226074219, "load scripts/sd_upscale.py": 0.001462697982788086, "load scripts/seed.py": 0.0009021759033203125, "load scripts/xyz_grid.py": 0.001972198486328125, "load scripts/ldsr_model.py": 3.0265650749206543, "load scripts/lora_script.py": 0.23017525672912598, "load scripts/scunet_model.py": 0.05402112007141113, "load scripts/swinir_model.py": 0.0359041690826416, "load scripts/hotkey_config.py": 0.0019669532775878906, "load scripts/extra_options_section.py": 0.0, "load scripts": 3.419900894165039, "load upscalers": 0.05032491683959961, "refresh VAE": 0.0019948482513427734, "refresh textual inversion templates": 0.0009968280792236328, "scripts list_optimizers": 0.003020763397216797, "scripts list_unets": 0.0, "reload hypernetworks": 0.0019676685333251953, "initialize extra networks": 0.4604055881500244, "scripts before_ui_callback": 0.05289268493652344, "create ui": 3.436349630355835, "gradio launch": 0.7496864795684814, "add APIs": 0.031106948852539062, "app_started_callback/lora_script.py": 0.0, "app_started_callback": 0.0 } }, "Packages": [ "absl-py==2.0.0", "accelerate==0.21.0", "addict==2.4.0", "aenum==3.1.15", "aiofiles==23.2.1", "aiohttp==3.8.5", "aiosignal==1.3.1", "altair==5.1.1", "antlr4-python3-runtime==4.9.3", "anyio==3.7.1", "async-timeout==4.0.3", "attrs==23.1.0", "basicsr==1.4.2", "beautifulsoup4==4.12.2", "blendmodes==2022", "boltons==23.0.0", "cachetools==5.3.1", "certifi==2023.7.22", "charset-normalizer==3.2.0", "clean-fid==0.1.35", "click==8.1.7", "clip==1.0", "colorama==0.4.6", "contourpy==1.1.1", "cycler==0.11.0", "deprecation==2.1.0", "einops==0.4.1", "exceptiongroup==1.1.3", "facexlib==0.3.0", "fastapi==0.94.0", "ffmpy==0.3.1", "filelock==3.12.4", "filterpy==1.4.5", "fonttools==4.42.1", "frozenlist==1.4.0", "fsspec==2023.9.2", "ftfy==6.1.1", "future==0.18.3", "gdown==4.7.1", "gfpgan==1.3.8", "gitdb==4.0.10", "gitpython==3.1.32", "google-auth-oauthlib==1.0.0", "google-auth==2.23.1", "gradio-client==0.5.0", "gradio==3.41.2", "grpcio==1.58.0", "h11==0.12.0", "httpcore==0.15.0", "httpx==0.24.1", "huggingface-hub==0.17.3", "idna==3.4", "imageio==2.31.4", "importlib-metadata==6.8.0", "importlib-resources==6.1.0", "inflection==0.5.1", "jinja2==3.1.2", "jsonmerge==1.8.0", "jsonschema-specifications==2023.7.1", "jsonschema==4.19.1", "kiwisolver==1.4.5", "kornia==0.6.7", "lark==1.1.2", "lazy-loader==0.3", "lightning-utilities==0.9.0", "llvmlite==0.41.0", "lmdb==1.4.1", "lpips==0.1.4", "markdown==3.4.4", "markupsafe==2.1.3", "matplotlib==3.8.0", "mpmath==1.3.0", "multidict==6.0.4", "networkx==3.1", "numba==0.58.0", "numpy==1.23.5", "oauthlib==3.2.2", "omegaconf==2.2.3", "open-clip-torch==2.20.0", "opencv-python==4.8.0.76", "orjson==3.9.7", "packaging==23.1", "pandas==2.1.1", "piexif==1.1.3", "pillow==9.5.0", "pip==22.2.1", "platformdirs==3.10.0", "protobuf==3.20.0", "psutil==5.9.5", "pyasn1-modules==0.3.0", "pyasn1==0.5.0", "pydantic==1.10.12", "pydub==0.25.1", "pyparsing==3.1.1", "pysocks==1.7.1", "python-dateutil==2.8.2", "python-multipart==0.0.6", "pytorch-lightning==1.9.4", "pytz==2023.3.post1", "pywavelets==1.4.1", "pyyaml==6.0.1", "realesrgan==0.3.0", "referencing==0.30.2", "regex==2023.8.8", "requests-oauthlib==1.3.1", "requests==2.31.0", "resize-right==0.0.2", "rpds-py==0.10.3", "rsa==4.9", "safetensors==0.3.1", "scikit-image==0.21.0", "scipy==1.11.2", "semantic-version==2.10.0", "sentencepiece==0.1.99", "setuptools==63.2.0", "six==1.16.0", "smmap==5.0.1", "sniffio==1.3.0", "soupsieve==2.5", "starlette==0.26.1", "sympy==1.12", "tb-nightly==2.15.0a20230927", "tensorboard-data-server==0.7.1", "tifffile==2023.9.26", "timm==0.9.2", "tokenizers==0.13.3", "tomesd==0.1.3", "tomli==2.0.1", "toolz==0.12.0", "torch==2.0.1+cu118", "torchdiffeq==0.2.3", "torchmetrics==1.2.0", "torchsde==0.2.5", "torchvision==0.15.2+cu118", "tqdm==4.66.1", "trampoline==0.1.2", "transformers==4.30.2", "typing-extensions==4.8.0", "tzdata==2023.3", "urllib3==2.0.5", "uvicorn==0.23.2", "wcwidth==0.2.6", "websockets==11.0.3", "werkzeug==2.3.7", "wheel==0.41.2", "xformers==0.0.20", "yapf==0.40.2", "yarl==1.9.2", "zipp==3.17.0" ] }

What browsers do you use to access the UI ?

Google Chrome, Other

Console logs

venv "D:\sd\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: v1.6.0
Commit hash: 5ef669de080814067961f28357256e8fe27544f4
Launching Web UI with arguments: --xformers --no-half --precision full
Loading weights [aadddd3d75] from D:\sd\stable-diffusion-webui\models\Stable-diffusion\(model K)deliberate_v3(portraiture, landscapes, fantastical topics).safetensors
Creating model from config: D:\sd\stable-diffusion-webui\configs\v1-inference.yaml
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 53.9s (prepare environment: 16.3s, import torch: 12.4s, import gradio: 4.4s, setup paths: 6.0s, import ldm: 0.1s, initialize shared: 0.7s, other imports: 4.8s, setup codeformer: 0.7s, list SD models: 0.3s, load scripts: 3.4s, initialize extra networks: 0.5s, create ui: 3.4s, gradio launch: 0.7s).
Applying attention optimization: xformers... done.
Model loaded in 46.4s (load weights from disk: 3.8s, create model: 0.8s, apply weights to model: 21.1s, apply float(): 11.0s, load VAE: 0.3s, calculate empty prompt: 9.3s).
SwinIR tiles: 100%|██████████████████████████████████████████████████████████████████████| 9/9 [03:58<00:00, 26.48s/it]

Additional information

No response

angryptonX commented 1 year ago

Try with --opt-sdp-attention --opt-channelslast, with my 3090 it is much faster than xformers. but anyway u are right, since 1.6.0 the performance break in.

joyoungzhang commented 1 year ago

Try with ESRGAN_tile = 0.

image
PixelGames987 commented 1 year ago

Try with ESRGAN_tile = 0. image

Doesn't work, it just slows down.

PixelGames987 commented 1 year ago

I don't know if the tile size fixed it or there was a new version that fixed it, but it is now working properly.