diff --git a/diffsynth/pipelines/wan_video_new.py b/diffsynth/pipelines/wan_video_new.py index a93694c..a9d9ad1 100644 --- a/diffsynth/pipelines/wan_video_new.py +++ b/diffsynth/pipelines/wan_video_new.py @@ -169,7 +169,7 @@ class ModelConfig: def download_if_necessary(self, local_model_path="./models", skip_download=False, use_usp=False): if self.path is None: # Check model_id and origin_file_pattern - if self.model_id is None or self.origin_file_pattern is None: + if self.model_id is None: raise ValueError(f"""No valid model files. Please use `ModelConfig(path="xxx")` or `ModelConfig(model_id="xxx/yyy", origin_file_pattern="zzz")`.""") # Skip if not in rank 0 @@ -178,7 +178,11 @@ class ModelConfig: skip_download = dist.get_rank() != 0 # Check whether the origin path is a folder - if isinstance(self.origin_file_pattern, str) and self.origin_file_pattern.endswith("/"): + if self.origin_file_pattern is None: + self.origin_file_pattern = "" + allow_file_pattern = None + is_folder = True + elif isinstance(self.origin_file_pattern, str) and self.origin_file_pattern.endswith("/"): allow_file_pattern = self.origin_file_pattern + "*" is_folder = True else: diff --git a/examples/flux/flux_entity_control.py b/examples/flux/EliGen.py similarity index 100% rename from examples/flux/flux_entity_control.py rename to examples/flux/EliGen.py diff --git a/examples/flux/flux_ipadapter.py b/examples/flux/FLUX.1-dev-IP-Adapter.py similarity index 72% rename from examples/flux/flux_ipadapter.py rename to examples/flux/FLUX.1-dev-IP-Adapter.py index 6214e4d..e70301f 100644 --- a/examples/flux/flux_ipadapter.py +++ b/examples/flux/FLUX.1-dev-IP-Adapter.py @@ -1,10 +1,7 @@ import torch -from PIL import Image -from diffsynth import save_video, VideoData, download_models from diffsynth.pipelines.flux_image_new import FluxImagePipeline, ModelConfig -from modelscope import dataset_snapshot_download -#TODO: repalce the local path with model_id + pipe = FluxImagePipeline.from_pretrained( torch_dtype=torch.bfloat16, device="cuda", @@ -14,16 +11,14 @@ pipe = FluxImagePipeline.from_pretrained( ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="text_encoder_2/"), ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="ae.safetensors"), ModelConfig(model_id="InstantX/FLUX.1-dev-IP-Adapter", origin_file_pattern="ip-adapter.bin"), - ModelConfig(path="models/IpAdapter/InstantX/FLUX.1-dev-IP-Adapter/image_encoder") + ModelConfig(model_id="google/siglip-so400m-patch14-384"), ], ) -seed = 42 origin_prompt = "a rabbit in a garden, colorful flowers" -image = pipe(prompt=origin_prompt, height=1280, width=960, seed=seed) +image = pipe(prompt=origin_prompt, height=1280, width=960, seed=42) image.save("style image.jpg") -torch.manual_seed(seed) -image = pipe(prompt="A piggy", height=1280, width=960, seed=seed, +image = pipe(prompt="A piggy", height=1280, width=960, seed=42, ipadapter_images=[image], ipadapter_scale=0.7) image.save("A piggy.jpg") diff --git a/examples/flux/flux_teacache.py b/examples/flux/FLUX.1-dev-TeaCache.py similarity index 100% rename from examples/flux/flux_teacache.py rename to examples/flux/FLUX.1-dev-TeaCache.py diff --git a/examples/flux/flex_text_to_image.py b/examples/flux/Flex.2-preview.py similarity index 100% rename from examples/flux/flex_text_to_image.py rename to examples/flux/Flex.2-preview.py diff --git a/examples/flux/step1x.py b/examples/flux/Step1X-Edit.py similarity index 77% rename from examples/flux/step1x.py rename to examples/flux/Step1X-Edit.py index eca7605..33ee80d 100644 --- a/examples/flux/step1x.py +++ b/examples/flux/Step1X-Edit.py @@ -1,13 +1,9 @@ import torch from diffsynth.pipelines.flux_image_new import FluxImagePipeline, ModelConfig -from modelscope import snapshot_download from PIL import Image import numpy as np -snapshot_download("Qwen/Qwen2.5-VL-7B-Instruct", cache_dir="./models") -snapshot_download("stepfun-ai/Step1X-Edit", cache_dir="./models") - pipe = FluxImagePipeline.from_pretrained( torch_dtype=torch.bfloat16, device="cuda", @@ -18,27 +14,19 @@ pipe = FluxImagePipeline.from_pretrained( ], ) - -pipe.enable_vram_management() - image = Image.fromarray(np.zeros((1248, 832, 3), dtype=np.uint8) + 255) image = pipe( prompt="draw red flowers in Chinese ink painting style", step1x_reference_image=image, width=832, height=1248, cfg_scale=6, - seed=1, - rand_device='cuda' + seed=1, rand_device='cuda' ) image.save("image_1.jpg") - - image = pipe( prompt="add more flowers in Chinese ink painting style", step1x_reference_image=image, width=832, height=1248, cfg_scale=6, - seed=2, - rand_device='cuda' + seed=2, rand_device='cuda' ) image.save("image_2.jpg") - diff --git a/image_1.jpg b/image_1.jpg new file mode 100644 index 0000000..3b17e7a Binary files /dev/null and b/image_1.jpg differ diff --git a/image_2.jpg b/image_2.jpg new file mode 100644 index 0000000..03e645c Binary files /dev/null and b/image_2.jpg differ