mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-05-01 03:31:21 +00:00
feat: change unsafe pickling
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from contextlib import contextmanager
|
||||
from copy import copy
|
||||
from typing import TYPE_CHECKING, Any, Union
|
||||
from unittest.mock import patch
|
||||
|
||||
import torch
|
||||
from PIL import Image
|
||||
from typing_extensions import Protocol
|
||||
|
||||
from modules import safe
|
||||
from modules.shared import opts
|
||||
from modules.shared import cmd_opts, opts
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# 타입 체커가 빨간 줄을 긋지 않게 하는 편법
|
||||
@@ -36,6 +38,15 @@ def change_torch_load():
|
||||
torch.load = orig
|
||||
|
||||
|
||||
@contextmanager
|
||||
def disable_safe_unpickle():
|
||||
with (
|
||||
patch.dict(os.environ, {"TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD": "1"}, clear=False),
|
||||
patch.object(cmd_opts, "disable_safe_unpickle", True),
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@contextmanager
|
||||
def pause_total_tqdm():
|
||||
orig = opts.data.get("multiple_tqdm", True)
|
||||
|
||||
Reference in New Issue
Block a user