diff --git a/CHANGELOG.md b/CHANGELOG.md index c0f4ebabe..aff2c5db9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,16 @@ # Change Log for SD.Next +## TODO + +- EDM samplers for Playground require diffusers==0.27.0 +- StableCascade requires diffuers side-branch + ## Update for 2024-02-26 +- [Playground v2.5](https://huggingface.co/playgroundai/playground-v2.5-1024px-aesthetic) + - new model version from Playground: based on SDXL, but with some cool new concepts + - download using networks -> reference + - set sampler to DPM++ 2M EDM or Euler EDM - **Image2Video** - new module for creating videos from images - simply enable from *img2img -> scripts -> image2video* diff --git a/html/reference.json b/html/reference.json index f05fee1fe..c0d84b466 100644 --- a/html/reference.json +++ b/html/reference.json @@ -169,6 +169,11 @@ "desc": "Playground v2 is a diffusion-based text-to-image generative model. The model was trained from scratch by the research team at Playground. Images generated by Playground v2 are favored 2.5 times more than those produced by Stable Diffusion XL, according to Playground’s user study.", "preview": "playgroundai--playground-v2-1024px-aesthetic.jpg" }, + "Playground v2.5": { + "path": "playground-v2.5-1024px-aesthetic.fp16.safetensors@https://huggingface.co/playgroundai/playground-v2.5-1024px-aesthetic/resolve/main/playground-v2.5-1024px-aesthetic.fp16.safetensors?download=true", + "desc": "Playground v2.5 is a diffusion-based text-to-image generative model, and a successor to Playground v2. Playground v2.5 is the state-of-the-art open-source model in aesthetic quality. Our user studies demonstrate that our model outperforms SDXL, Playground v2, PixArt-α, DALL-E 3, and Midjourney 5.2.", + "preview": "playgroundai--playground-v2-1024px-aesthetic.jpg" + }, "DeepFloyd IF Medium": { "path": "DeepFloyd/IF-I-M-v1.0", "desc": "DeepFloyd-IF is a pixel-based text-to-image triple-cascaded diffusion model, that can generate pictures with new state-of-the-art for photorealism and language understanding. The result is a highly efficient model that outperforms current state-of-the-art models, achieving a zero-shot FID-30K score of 6.66 on the COCO dataset. It is modular and composed of frozen text mode and three pixel cascaded diffusion modules, each designed to generate images of increasing resolution: 64x64, 256x256, and 1024x1024.", diff --git a/models/Reference/playgroundai--playground-v2.5-1024px-aesthetic.jpg b/models/Reference/playgroundai--playground-v2.5-1024px-aesthetic.jpg new file mode 100644 index 000000000..c2c46bbb5 Binary files /dev/null and b/models/Reference/playgroundai--playground-v2.5-1024px-aesthetic.jpg differ diff --git a/modules/sd_models.py b/modules/sd_models.py index 90fb37449..6e9e96fcf 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -323,37 +323,40 @@ def read_metadata_from_safetensors(filename): # try: t0 = time.time() with open(filename, mode="rb") as file: - metadata_len = file.read(8) - metadata_len = int.from_bytes(metadata_len, "little") - json_start = file.read(2) - if metadata_len <= 2 or json_start not in (b'{"', b"{'"): - shared.log.error(f"Not a valid safetensors file: {filename}") - json_data = json_start + file.read(metadata_len-2) - json_obj = json.loads(json_data) - for k, v in json_obj.get("__metadata__", {}).items(): - if v.startswith("data:"): - v = 'data' - if k == 'format' and v == 'pt': - continue - large = True if len(v) > 2048 else False - if large and k == 'ss_datasets': - continue - if large and k == 'workflow': - continue - if large and k == 'prompt': - continue - if large and k == 'ss_bucket_info': - continue - if v[0:1] == '{': - try: - v = json.loads(v) - if large and k == 'ss_tag_frequency': - v = { i: len(j) for i, j in v.items() } - if large and k == 'sd_merge_models': - scrub_dict(v, ['sd_merge_recipe']) - except Exception: - pass - res[k] = v + try: + metadata_len = file.read(8) + metadata_len = int.from_bytes(metadata_len, "little") + json_start = file.read(2) + if metadata_len <= 2 or json_start not in (b'{"', b"{'"): + shared.log.error(f"Model metadata invalid: fn={filename}") + json_data = json_start + file.read(metadata_len-2) + json_obj = json.loads(json_data) + for k, v in json_obj.get("__metadata__", {}).items(): + if v.startswith("data:"): + v = 'data' + if k == 'format' and v == 'pt': + continue + large = True if len(v) > 2048 else False + if large and k == 'ss_datasets': + continue + if large and k == 'workflow': + continue + if large and k == 'prompt': + continue + if large and k == 'ss_bucket_info': + continue + if v[0:1] == '{': + try: + v = json.loads(v) + if large and k == 'ss_tag_frequency': + v = { i: len(j) for i, j in v.items() } + if large and k == 'sd_merge_models': + scrub_dict(v, ['sd_merge_recipe']) + except Exception: + pass + res[k] = v + except Exception as e: + shared.log.error(f"Model metadata: fn={filename} {e}") sd_metadata[filename] = res global sd_metadata_pending # pylint: disable=global-statement sd_metadata_pending += 1 diff --git a/modules/sd_samplers_diffusers.py b/modules/sd_samplers_diffusers.py index eb2742210..8299ea567 100644 --- a/modules/sd_samplers_diffusers.py +++ b/modules/sd_samplers_diffusers.py @@ -72,6 +72,14 @@ samplers_data_diffusers = [ sd_samplers_common.SamplerData('SA Solver', lambda model: DiffusionSampler('SA Solver', SASolverScheduler, model), [], {}), ] +try: # diffusers==0.27.0 + from diffusers import EDMDPMSolverMultistepScheduler, EDMEulerScheduler + config['DPM++ 2M EDM'] = { 'solver_order': 2, 'solver_type': 'midpoint', 'final_sigmas_type': 'zero' } # 'algorithm_type': 'dpmsolver++' + config['Euler EDM'] = { } + samplers_data_diffusers.append(sd_samplers_common.SamplerData('DPM++ 2M EDM', lambda model: DiffusionSampler('DPM++ 2M EDM', EDMDPMSolverMultistepScheduler, model), [], {})) + samplers_data_diffusers.append(sd_samplers_common.SamplerData('Euler EDM', lambda model: DiffusionSampler('Euler EDM', EDMEulerScheduler, model), [], {})) +except Exception: + pass class DiffusionSampler: def __init__(self, name, constructor, model, **kwargs): @@ -126,6 +134,10 @@ class DiffusionSampler: self.config['algorithm_type'] = shared.opts.schedulers_dpm_solver if name == 'DEIS': self.config['algorithm_type'] = 'deis' + if 'EDM' in name: + del self.config['beta_start'] + del self.config['beta_end'] + del self.config['beta_schedule'] # validate all config params signature = inspect.signature(constructor, follow_wrapped=True) possible = signature.parameters.keys()