major requirements refactor

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-07-01 13:12:21 -04:00
parent 4c43c1cc5e
commit 7736382028
18 changed files with 99 additions and 51 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ def get_app(mp_name, threshold=0.5, resolution=640):
from installer import install, installed, reload
if not installed('insightface', reload=False, quiet=True):
install('insightface==0.7.3', ignore=False)
install('git+https://github.com/deepinsight/insightface@554a05561cb71cfebb4e012dfea48807f845a0c2#subdirectory=python-package', 'insightface') # insightface==0.7.3 with patches
install('albumentations==1.4.3', ignore=False, reinstall=True)
install('pydantic==1.10.21', ignore=False, reinstall=True, force=True)
reload('pydantic')
+19 -3
View File
@@ -14,7 +14,22 @@ errors.install()
logging.getLogger("DeepSpeed").disabled = True
# os.environ.setdefault('TORCH_LOGS', '-all')
np = None
try:
import numpy as np # pylint: disable=W0611,C0411
import numpy.random # pylint: disable=W0611,C0411 # this causes failure if numpy version changed
except Exception as e:
errors.log.error(f'Loader: numpy=={np.__version__ if np is not None else None} {e}')
errors.log.error('Please restart the app to fix this issue')
sys.exit(1)
try:
import scipy # pylint: disable=W0611,C0411
except Exception as e:
errors.log.error(f'Loader: scipy=={np.__version__ if np is not None else None} {e}')
errors.log.error('Please restart the app to fix this issue')
sys.exit(1)
import torch # pylint: disable=C0411
if torch.__version__.startswith('2.5.0'):
errors.log.warning(f'Disabling cuDNN for SDP on torch={torch.__version__}')
@@ -34,6 +49,7 @@ logging.getLogger("pytorch_lightning").disabled = True
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
warnings.filterwarnings(action="ignore", category=FutureWarning)
warnings.filterwarnings(action="ignore", category=UserWarning, module="torchvision")
warnings.filterwarnings(action="ignore", message="numpy.dtype size changed")
try:
import torch._logging # pylint: disable=ungrouped-imports
torch._logging._internal.DEFAULT_LOG_LEVEL = logging.ERROR # pylint: disable=protected-access
@@ -139,7 +155,7 @@ try:
except Exception:
pass
try: # fix changed import in torchvision 0.17+, which breaks basicsr
try:
import torchvision.transforms.functional_tensor # pylint: disable=unused-import, ungrouped-imports
except ImportError:
try:
@@ -160,4 +176,4 @@ diffusers.utils.deprecate = deprecate_warn
errors.log.info(f'Torch: torch=={torch.__version__} torchvision=={torchvision.__version__}')
errors.log.info(f'Packages: diffusers=={diffusers.__version__} transformers=={transformers.__version__} accelerate=={accelerate.__version__} gradio=={gradio.__version__} pydantic=={pydantic.__version__}')
errors.log.info(f'Packages: diffusers=={diffusers.__version__} transformers=={transformers.__version__} accelerate=={accelerate.__version__} gradio=={gradio.__version__} pydantic=={pydantic.__version__} numpy=={np.__version__}')
+12 -4
View File
@@ -4,8 +4,16 @@ Credit and original implementation: <https://github.com/ToTheBeginning/PuLID>
import os
import sys
from modules.errors import log
sys.path.append(os.path.dirname(__file__))
from pulid_sdxl import StableDiffusionXLPuLIDPipeline, StableDiffusionXLPuLIDPipelineImage, StableDiffusionXLPuLIDPipelineInpaint
from pulid_utils import resize_numpy_image_long as resize
import attention_processor as attention
import pulid_sampling as sampling
try:
from pulid_sdxl import StableDiffusionXLPuLIDPipeline, StableDiffusionXLPuLIDPipelineImage, StableDiffusionXLPuLIDPipelineInpaint
from pulid_utils import resize_numpy_image_long as resize
import attention_processor as attention
import pulid_sampling as sampling
except Exception as e:
import traceback
log.error(f'PuLID import error: {e}')
print(traceback.format_exc())
print(sys.exc_info()[0])
raise ImportError(f'PuLID import error: {e}') from e
+1 -1
View File
@@ -1,7 +1,6 @@
from typing import Union
import os
import cv2
import insightface
import numpy as np
import torch
import torch.nn as nn
@@ -14,6 +13,7 @@ from safetensors.torch import load_file
from torchvision.transforms import InterpolationMode
from torchvision.transforms.functional import normalize, resize
import insightface
from basicsr.utils import img2tensor, tensor2img
from facexlib.parsing import init_parsing_model
from facexlib.utils.face_restoration_helper import FaceRestoreHelper
+1 -4
View File
@@ -308,10 +308,7 @@ def temp_disable_extensions():
modules.shared.opts.data['theme_type'] = 'Modern'
modules.shared.opts.data['gradio_theme'] = theme_name[7:]
disable_themes.remove('sdnext-modernui')
elif theme_name.lower().startswith('gradio'):
modules.shared.opts.data['theme_type'] = 'None'
modules.shared.opts.data['gradio_theme'] = theme_name
elif theme_name.lower().startswith('huggingface'):
elif theme_name.lower().startswith('huggingface') or theme_name.lower().startswith('gradio') or theme_name.lower().startswith('none'):
modules.shared.opts.data['theme_type'] = 'None'
modules.shared.opts.data['gradio_theme'] = theme_name
else:
+2
View File
@@ -99,6 +99,8 @@ def reload_gradio_theme():
theme_name = 'black-teal'
elif modules.shared.opts.theme_type == 'Modern':
theme_name = 'Default'
elif modules.shared.opts.theme_type == 'None':
theme_name = 'gradio/default'
else:
modules.shared.opts.theme_type = 'Standard'
theme_name = 'black-teal'