2025年4月19日 星期六

Stable Diffusion 學習筆記 (十三) : 安裝 Ultimate upscale 外掛

Ultimate upscale 外掛主要功能是用來對圖片進行高品質的放大 (Upscale) 重繪, 它的特點在於採取邊放大邊用模型補細節的作法, 而不是簡單地將尺寸直接拉大. 其次是它支援分塊 (tile) 處理, 亦即將圖片切成多塊後再重建, 適合大尺寸輸出之應用, 可搭配 LoRA, ControlNet, Prompt 等條件進行二次生成. 

在 "Extensions (擴充功能)/Installed (已安裝套件)/Install from URL (從網址安裝)" 頁籤的 "URL  for extension's git repository(擴充功能的 git 儲存庫網址)" 框中輸入如下網址 : 

https://github.com/Coyote-A/ultimate-upscale-for-automatic1111.git

然後按底下的 "Install(安裝)" 鈕 : 




然後到 "Install (已安裝)" 頁籤按下 "安裝並重新更新使用者介面" 鈕即可. 

此外掛於安裝與更新介面後在底下微調區不會出現獨立的選單, 因為 Ultimate SD Upscale 本身不屬於微調模型, 但它可以與微調模型 (例如 LoRA, Textual Inversion, yCORIS 等) 一起使用. 

至此含繁體中文共 10 個外掛就全部安裝完成了. 

但是按 Ctrl+C 關閉 Stable Diffusion 重開卻出現如下錯誤訊息 :

Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: v1.10.1
Commit hash: 82a973c04367123ae98bd9abdf80d9eda9b910e2
Installing sd-webui-controlnet requirement: handrefinerportable
Couldn't install sd-webui-controlnet requirement: handrefinerportable.
Command: "C:\Users\USER\Downloads\sd.webui\system\python\python.exe" -m pip install -U https://github.com/huchenlei/HandRefinerPortable/releases/download/v1.0.1/handrefinerportable-2024.2.12.0-py2.py3-none-any.whl --prefer-binary
Error code: 2
stdout: Collecting handrefinerportable==2024.2.12.0
  Downloading https://github.com/huchenlei/HandRefinerPortable/releases/download/v1.0.1/handrefinerportable-2024.2.12.0-py2.py3-none-any.whl (13.1 MB)
     ---------------------------------------- 13.1/13.1 MB 4.5 MB/s eta 0:00:00
Requirement already satisfied: mediapipe in c:\users\user\downloads\sd.webui\system\python\lib\site-packages (from handrefinerportable==2024.2.12.0) (0.10.14)
Collecting rtree (from handrefinerportable==2024.2.12.0)
  Using cached rtree-1.4.0-py3-none-win_amd64.whl.metadata (2.1 kB)
Collecting trimesh[easy] (from handrefinerportable==2024.2.12.0)
  Using cached trimesh-4.6.8-py3-none-any.whl.metadata (18 kB)
Requirement already satisfied: absl-py in c:\users\user\appdata\roaming\python\python310\site-packages (from mediapipe->handrefinerportable==2024.2.12.0) (2.1.0)
Requirement already satisfied: attrs>=19.1.0 in c:\users\user\appdata\roaming\python\python310\site-packages (from mediapipe->handrefinerportable==2024.2.12.0) (23.2.0)
Requirement already satisfied: flatbuffers>=2.0 in c:\users\user\appdata\roaming\python\python310\site-packages (from mediapipe->handrefinerportable==2024.2.12.0) (24.3.25)
Requirement already satisfied: jax in c:\users\user\downloads\sd.webui\system\python\lib\site-packages (from mediapipe->handrefinerportable==2024.2.12.0) (0.6.0)
Requirement already satisfied: jaxlib in c:\users\user\downloads\sd.webui\system\python\lib\site-packages (from mediapipe->handrefinerportable==2024.2.12.0) (0.6.0)
Requirement already satisfied: matplotlib in c:\users\user\appdata\roaming\python\python310\site-packages (from mediapipe->handrefinerportable==2024.2.12.0) (3.8.3)
Requirement already satisfied: numpy in c:\users\user\downloads\sd.webui\system\python\lib\site-packages (from mediapipe->handrefinerportable==2024.2.12.0) (1.26.2)
Requirement already satisfied: opencv-contrib-python in c:\users\user\downloads\sd.webui\system\python\lib\site-packages (from mediapipe->handrefinerportable==2024.2.12.0) (4.11.0.86)
Collecting protobuf<5,>=4.25.3 (from mediapipe->handrefinerportable==2024.2.12.0)
  Using cached protobuf-4.25.6-cp310-abi3-win_amd64.whl.metadata (541 bytes)
Requirement already satisfied: sounddevice>=0.4.4 in c:\users\user\downloads\sd.webui\system\python\lib\site-packages (from mediapipe->handrefinerportable==2024.2.12.0) (0.5.1)
Collecting colorlog (from trimesh[easy]->handrefinerportable==2024.2.12.0)
  Using cached colorlog-6.9.0-py3-none-any.whl.metadata (10 kB)
Collecting manifold3d>=2.3.0 (from trimesh[easy]->handrefinerportable==2024.2.12.0)
  Using cached manifold3d-3.0.1-cp310-cp310-win_amd64.whl.metadata (17 kB)
Requirement already satisfied: charset-normalizer in c:\users\user\appdata\roaming\python\python310\site-packages (from trimesh[easy]->handrefinerportable==2024.2.12.0) (3.3.2)
Requirement already satisfied: lxml in c:\users\user\appdata\roaming\python\python310\site-packages (from trimesh[easy]->handrefinerportable==2024.2.12.0) (5.2.0)
Requirement already satisfied: jsonschema in c:\users\user\appdata\roaming\python\python310\site-packages (from trimesh[easy]->handrefinerportable==2024.2.12.0) (4.21.1)
Requirement already satisfied: networkx in c:\users\user\downloads\sd.webui\system\python\lib\site-packages (from trimesh[easy]->handrefinerportable==2024.2.12.0) (3.4.2)
Collecting svg.path (from trimesh[easy]->handrefinerportable==2024.2.12.0)
  Using cached svg.path-6.3-py2.py3-none-any.whl.metadata (13 kB)
Collecting pycollada (from trimesh[easy]->handrefinerportable==2024.2.12.0)
  Using cached pycollada-0.9.tar.gz (109 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'

stderr: ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\cli\base_command.py", line 106, in _run_wrapper
    status = _inner_run()
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\cli\base_command.py", line 97, in _inner_run
    return self.run(options, args)
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\cli\req_command.py", line 67, in wrapper
    return func(self, options, args)
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\commands\install.py", line 386, in run
    requirement_set = resolver.resolve(
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 95, in resolve
    result = self._result = resolver.resolve(
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 427, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 239, in _attempt_to_pin_criterion
    criteria = self._get_updated_criteria(candidate)
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 230, in _get_updated_criteria
    self._add_to_criteria(criteria, requirement, parent=candidate)
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 173, in _add_to_criteria
    if not criterion.candidates:
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 156, in __bool__
    return bool(self._sequence)
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 174, in __bool__
    return any(self)
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 162, in <genexpr>
    return (c for c in iterator if id(c) not in self._incompatible_ids)
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 53, in _iter_built
    candidate = func()
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 187, in _make_candidate_from_link
    base: Optional[BaseCandidate] = self._make_base_candidate_from_link(
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 233, in _make_base_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 304, in __init__
    super().__init__(
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 159, in __init__
    self.dist = self._prepare()
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 236, in _prepare
    dist = self._prepare_distribution()
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 315, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\operations\prepare.py", line 527, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\operations\prepare.py", line 642, in _prepare_linked_requirement
    dist = _get_prepared_distribution(
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\operations\prepare.py", line 72, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\distributions\sdist.py", line 56, in prepare_distribution_metadata
    self._install_build_reqs(finder)
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\distributions\sdist.py", line 126, in _install_build_reqs
    build_reqs = self._get_build_requires_wheel()
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\distributions\sdist.py", line 103, in _get_build_requires_wheel
    return backend.get_requires_for_build_wheel()
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_internal\utils\misc.py", line 702, in get_requires_for_build_wheel
    return super().get_requires_for_build_wheel(config_settings=cs)
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_vendor\pyproject_hooks\_impl.py", line 196, in get_requires_for_build_wheel
    return self._call_hook(
  File "C:\Users\USER\Downloads\sd.webui\system\python\lib\site-packages\pip\_vendor\pyproject_hooks\_impl.py", line 402, in _call_hook
    raise BackendUnavailable(
pip._vendor.pyproject_hooks._impl.BackendUnavailable: Cannot import 'setuptools.build_meta'

Warning: Failed to install handrefinerportable. Some processors will not work.
Launching Web UI with arguments: --xformers --share
2025-04-19 16:10:03.341027: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
Tag Autocomplete: Could not locate model-keyword extension, Lora trigger word completion will be limited to those added through the extra networks menu.
[-] ADetailer initialized. version: 25.3.0, num models: 10
ControlNet preprocessor location: C:\Users\USER\Downloads\sd.webui\webui\extensions\sd-webui-controlnet\annotator\downloads
2025-04-19 16:10:06,752 - ControlNet - INFO - ControlNet v1.1.455
[sd-webui-freeu] Controlnet support: *enabled*
sd-webui-prompt-all-in-one background API service started successfully.
Loading weights [7c819b6d13] from C:\Users\USER\Downloads\sd.webui\webui\models\Stable-diffusion\majicmixRealistic_v7.safetensors
Creating model from config: C:\Users\USER\Downloads\sd.webui\webui\configs\v1-inference.yaml
2025-04-19 16:10:07,604 - ControlNet - INFO - ControlNet UI callback registered.
Running on local URL:  http://127.0.0.1:7860
Applying attention optimization: xformers... done.
Model loaded in 4.2s (load weights from disk: 0.2s, create model: 1.0s, apply weights to model: 2.7s, calculate empty prompt: 0.1s).

我將這些訊息交給 ChatGPT 分析, WebUI 啟動錯誤主要是因為 handrefinerportable 這個模組在安裝時失敗了, 且它的依賴模組中有一部分尚未安裝或安裝失敗, 它建議手動安裝下列模組 :

pip install --upgrade setuptools
pip install "protobuf>=4.25.3,<5"
pip install rtree libspatialindex
pip install colorlog manifold3d svg.path pycollada
pip install "trimesh[easy]"

先在檔案總管切換路徑到 sd.webui\webui\python 下, 在空白處按滑鼠右鍵點選 "在終端中開啟", 這樣會開啟一個路徑在 sd.webui\webui\python 的命令提示字元視窗, 然後把上面 5 個指令丟進去執行安裝, 完成後再次執行 run.bat 即可. 

沒有留言 :