diff --git a/CHANGELOG.md b/CHANGELOG.md index 8749f1a0a..9e58981e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,9 @@ - [GLM-Image](https://huggingface.co/zai-org/GLM-Image) GLM-image is a new image generation model that adopts a hybrid autoregressive with diffusion decoder architecture available in both *original* and *sdnq-dynamic prequantized* variants, thanks @CalamitousFelicitousness - *note*: model requires usage of `--new` flag to install pre-release versions of required package + *note*: model requires pre-release versions of `transformers` package: + > pip install --upgrade git+https://github.com/huggingface/transformers.git + > ./webui.sh --experimental - [Nunchaku Z-Image Turbo](https://huggingface.co/nunchaku-tech/nunchaku-z-image-turbo) - **Feaures** - **SDNQ**: add *dynamic* quantization method diff --git a/modules/loader.py b/modules/loader.py index cbd000987..c6e25a1d3 100644 --- a/modules/loader.py +++ b/modules/loader.py @@ -99,14 +99,23 @@ except Exception: _bnb = False timer.startup.record("bnb") +import huggingface_hub # pylint: disable=W0611,C0411 +logging.getLogger("huggingface_hub.file_download").setLevel(logging.ERROR) +if huggingface_hub.__version__.startswith('0.'): + huggingface_hub.is_offline_mode = lambda: False +timer.startup.record("hfhub") + +import accelerate # pylint: disable=W0611,C0411 +timer.startup.record("accelerate") + +import pydantic # pylint: disable=W0611,C0411 +timer.startup.record("pydantic") + import transformers # pylint: disable=W0611,C0411 from transformers import logging as transformers_logging # pylint: disable=W0611,C0411 transformers_logging.set_verbosity_error() timer.startup.record("transformers") -import accelerate # pylint: disable=W0611,C0411 -timer.startup.record("accelerate") - try: import onnxruntime # pylint: disable=W0611,C0411 onnxruntime.set_default_logger_severity(4) @@ -121,9 +130,6 @@ import gradio # pylint: disable=W0611,C0411 timer.startup.record("gradio") errors.install([gradio]) -import pydantic # pylint: disable=W0611,C0411 -timer.startup.record("pydantic") - # patch different progress bars import tqdm as tqdm_lib # pylint: disable=C0411 from tqdm.rich import tqdm # pylint: disable=W0611,C0411 @@ -145,10 +151,6 @@ except Exception as e: errors.log.error('Please restart re-run the installer') sys.exit(1) -import huggingface_hub # pylint: disable=W0611,C0411 -logging.getLogger("huggingface_hub.file_download").setLevel(logging.ERROR) -timer.startup.record("hfhub") - try: import pillow_jxl # pylint: disable=W0611,C0411 except Exception: @@ -185,6 +187,7 @@ def get_packages(): "gradio": gradio.__version__, "transformers": transformers.__version__, "accelerate": accelerate.__version__, + "hub": huggingface_hub.__version__, } try: diff --git a/modules/modelloader.py b/modules/modelloader.py index 9edf51a9d..81138aebb 100644 --- a/modules/modelloader.py +++ b/modules/modelloader.py @@ -45,7 +45,7 @@ def hf_login(token=None): except Exception: pass with contextlib.redirect_stdout(stdout): - hf.login(token=token, add_to_git_credential=False, write_permission=False) + hf.login(token=token, add_to_git_credential=False) os.environ['HF_TOKEN'] = token text = stdout.getvalue() or '' obfuscated_token = 'hf_...' + token[-4:] diff --git a/modules/ui_extra_networks.py b/modules/ui_extra_networks.py index 981490b89..90d056a04 100644 --- a/modules/ui_extra_networks.py +++ b/modules/ui_extra_networks.py @@ -326,6 +326,7 @@ class ExtraNetworksPage: else: style = 'network-folder' subdirs_html += f'
' + self.html = '' self.create_items(tabname) versions = sorted({item.get("version", "") for item in self.items if item.get("version")}) diff --git a/modules/ui_extra_networks_checkpoints.py b/modules/ui_extra_networks_checkpoints.py index 52f9ece26..df6681bca 100644 --- a/modules/ui_extra_networks_checkpoints.py +++ b/modules/ui_extra_networks_checkpoints.py @@ -19,6 +19,8 @@ version_map = { "StableDiffusionXL": "SD XL", "WanToVideo": "Wan", "WanVACE": "Wan", + "Z": "Z-Image", + "Glm": "GLM-Image", } class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage): @@ -91,7 +93,7 @@ class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage): ready = reference_downloaded(url) version = "ready" if ready else "download" if tag == 'cloud': - version = 'cloud' + version = 'Cloud' if not ready and shared.opts.offline_mode: count['hidden'] += 1 continue diff --git a/scripts/differential_diffusion.py b/scripts/differential_diffusion.py index db67e8e00..889c3a33a 100644 --- a/scripts/differential_diffusion.py +++ b/scripts/differential_diffusion.py @@ -15,7 +15,7 @@ import PIL.Image import numpy as np import torch import torchvision -from transformers import CLIPFeatureExtractor, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer +from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers.image_processor import VaeImageProcessor from diffusers.loaders import FromSingleFileMixin, LoraLoaderMixin, TextualInversionLoaderMixin from diffusers.models import AutoencoderKL, UNet2DConditionModel @@ -1059,7 +1059,7 @@ class StableDiffusionDiffImg2ImgPipeline(DiffusionPipeline): unet: UNet2DConditionModel, scheduler: KarrasDiffusionSchedulers, safety_checker: StableDiffusionSafetyChecker, - feature_extractor: CLIPFeatureExtractor, + feature_extractor: CLIPImageProcessor, requires_safety_checker: bool = False, ): super().__init__() @@ -1353,17 +1353,6 @@ class StableDiffusionDiffImg2ImgPipeline(DiffusionPipeline): return prompt_embeds - # Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.run_safety_checker - def run_safety_checker(self, image, device, dtype): - if self.safety_checker is not None: - safety_checker_input = self.feature_extractor(self.numpy_to_pil(image), return_tensors="pt").to(device) - image, has_nsfw_concept = self.safety_checker( - images=image, clip_input=safety_checker_input.pixel_values.to(dtype) - ) - else: - has_nsfw_concept = None - return image, has_nsfw_concept - # Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.decode_latents def decode_latents(self, latents): latents = 1 / self.vae.config.scaling_factor * latents