Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8786102

Browse files
committed
add import & stype
missing copied from
1 parent a55dfc1 commit 8786102

File tree

5 files changed

+80
-6
lines changed

5 files changed

+80
-6
lines changed

‎src/diffusers/__init__.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@
495495
"LTXImageToVideoPipeline",
496496
"LTXLatentUpsamplePipeline",
497497
"LTXPipeline",
498+
"LucyEditPipeline",
498499
"Lumina2Pipeline",
499500
"Lumina2Text2ImgPipeline",
500501
"LuminaPipeline",
@@ -1149,6 +1150,7 @@
11491150
LTXImageToVideoPipeline,
11501151
LTXLatentUpsamplePipeline,
11511152
LTXPipeline,
1153+
LucyEditPipeline,
11521154
Lumina2Pipeline,
11531155
Lumina2Text2ImgPipeline,
11541156
LuminaPipeline,

‎src/diffusers/pipelines/__init__.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@
285285
]
286286
_import_structure["lumina"] = ["LuminaPipeline", "LuminaText2ImgPipeline"]
287287
_import_structure["lumina2"] = ["Lumina2Pipeline", "Lumina2Text2ImgPipeline"]
288+
_import_structure["lucy"] = ["LucyEditPipeline"]
288289
_import_structure["marigold"].extend(
289290
[
290291
"MarigoldDepthPipeline",
@@ -682,6 +683,7 @@
682683
LEditsPPPipelineStableDiffusionXL,
683684
)
684685
from .ltx import LTXConditionPipeline, LTXImageToVideoPipeline, LTXLatentUpsamplePipeline, LTXPipeline
686+
from .lucy import LucyEditPipeline
685687
from .lumina import LuminaPipeline, LuminaText2ImgPipeline
686688
from .lumina2 import Lumina2Pipeline, Lumina2Text2ImgPipeline
687689
from .marigold import (
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,47 @@
1+
from typing import TYPE_CHECKING
12

3+
from ...utils import (
4+
DIFFUSERS_SLOW_IMPORT,
5+
OptionalDependencyNotAvailable,
6+
_LazyModule,
7+
get_objects_from_module,
8+
is_torch_available,
9+
is_transformers_available,
10+
)
11+
12+
13+
_dummy_objects = {}
14+
_import_structure = {}
15+
16+
17+
try:
18+
if not (is_transformers_available() and is_torch_available()):
19+
raise OptionalDependencyNotAvailable()
20+
except OptionalDependencyNotAvailable:
21+
from ...utils import dummy_torch_and_transformers_objects # noqa F403
22+
23+
_dummy_objects.update(get_objects_from_module(dummy_torch_and_transformers_objects))
24+
else:
25+
_import_structure["pipeline_lucy_edit"] = ["LucyEditPipeline"]
26+
if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT:
27+
try:
28+
if not (is_transformers_available() and is_torch_available()):
29+
raise OptionalDependencyNotAvailable()
30+
31+
except OptionalDependencyNotAvailable:
32+
from ...utils.dummy_torch_and_transformers_objects import *
33+
else:
34+
from .pipeline_lucy_edit import LucyEditPipeline
35+
36+
else:
37+
import sys
38+
39+
sys.modules[__name__] = _LazyModule(
40+
__name__,
41+
globals()["__file__"],
42+
_import_structure,
43+
module_spec=__spec__,
44+
)
45+
46+
for name, value in _dummy_objects.items():
47+
setattr(sys.modules[__name__], name, value)

‎src/diffusers/pipelines/lucy/pipeline_lucy_edit.py‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@
6868
>>> height = 480
6969
>>> width = 832
7070
71+
7172
>>> # Load video
7273
>>> def convert_video(video: List[Image.Image]) -> List[Image.Image]:
7374
... video = load_video(url)[:num_frames]
7475
... video = [video[i].resize((width, height)) for i in range(num_frames)]
7576
... return video
7677
78+
7779
>>> video = load_video(url, convert_method=convert_video)
7880
7981
>>> # Load model
@@ -90,7 +92,7 @@
9092
... height=480,
9193
... width=832,
9294
... num_frames=81,
93-
... guidance_scale=5.0
95+
... guidance_scale=5.0,
9496
... ).frames[0]
9597
9698
>>> # Export video
@@ -115,6 +117,7 @@ def prompt_clean(text):
115117
text = whitespace_clean(basic_clean(text))
116118
return text
117119

120+
118121
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_img2img.retrieve_latents
119122
def retrieve_latents(
120123
encoder_output: torch.Tensor, generator: Optional[torch.Generator] = None, sample_mode: str = "sample"
@@ -191,6 +194,7 @@ def __init__(
191194
self.vae_scale_factor_spatial = self.vae.config.scale_factor_spatial if getattr(self, "vae", None) else 8
192195
self.video_processor = VideoProcessor(vae_scale_factor=self.vae_scale_factor_spatial)
193196

197+
# Copied from diffusers.pipelines.wan.pipeline_wan.WanPipeline._get_t5_prompt_embeds
194198
def _get_t5_prompt_embeds(
195199
self,
196200
prompt: Union[str, List[str]] = None,
@@ -232,6 +236,7 @@ def _get_t5_prompt_embeds(
232236

233237
return prompt_embeds
234238

239+
# Copied from diffusers.pipelines.wan.pipeline_wan.WanPipeline.encode_prompt
235240
def encode_prompt(
236241
self,
237242
prompt: Union[str, List[str]],
@@ -358,7 +363,7 @@ def check_inputs(
358363

359364
if self.config.boundary_ratio is None and guidance_scale_2 is not None:
360365
raise ValueError("`guidance_scale_2` is only supported when the pipeline's `boundary_ratio` is not None.")
361-
366+
362367
if video is None:
363368
raise ValueError("`video` is required, received None.")
364369

@@ -397,7 +402,9 @@ def prepare_latents(
397402
latents = latents.to(device)
398403

399404
# Prepare condition latents
400-
condition_latents = [retrieve_latents(self.vae.encode(vid.unsqueeze(0)), sample_mode="argmax") for vid in video]
405+
condition_latents = [
406+
retrieve_latents(self.vae.encode(vid.unsqueeze(0)), sample_mode="argmax") for vid in video
407+
]
401408

402409
condition_latents = torch.cat(condition_latents, dim=0).to(dtype)
403410

@@ -411,9 +418,12 @@ def prepare_latents(
411418
condition_latents = (condition_latents - latents_mean) * latents_std
412419

413420
# Check shapes
414-
assert latents.shape == condition_latents.shape, f"Latents shape {latents.shape} does not match expected shape {condition_latents.shape}. Please check the input."
421+
assert latents.shape == condition_latents.shape, (
422+
f"Latents shape {latents.shape} does not match expected shape {condition_latents.shape}. Please check the input."
423+
)
415424

416425
return latents, condition_latents
426+
417427
@property
418428
def guidance_scale(self):
419429
return self._guidance_scale
@@ -469,7 +479,7 @@ def __call__(
469479
The call function to the pipeline for generation.
470480
471481
Args:
472-
video (`List[Image.Image]`):
482+
video (`List[Image.Image]`):
473483
The video to use as the condition for the video generation.
474484
prompt (`str` or `List[str]`, *optional*):
475485
The prompt or prompts to guide the image generation. If not defined, pass `prompt_embeds` instead.
@@ -621,7 +631,6 @@ def __call__(
621631
latents,
622632
)
623633

624-
625634
mask = torch.ones(latents.shape, dtype=torch.float32, device=device)
626635

627636
# 6. Denoising loop

‎src/diffusers/utils/dummy_torch_and_transformers_objects.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,21 @@ def from_pretrained(cls, *args, **kwargs):
15921592
requires_backends(cls, ["torch", "transformers"])
15931593

15941594

1595+
class LucyEditPipeline(metaclass=DummyObject):
1596+
_backends = ["torch", "transformers"]
1597+
1598+
def __init__(self, *args, **kwargs):
1599+
requires_backends(self, ["torch", "transformers"])
1600+
1601+
@classmethod
1602+
def from_config(cls, *args, **kwargs):
1603+
requires_backends(cls, ["torch", "transformers"])
1604+
1605+
@classmethod
1606+
def from_pretrained(cls, *args, **kwargs):
1607+
requires_backends(cls, ["torch", "transformers"])
1608+
1609+
15951610
class Lumina2Pipeline(metaclass=DummyObject):
15961611
_backends = ["torch", "transformers"]
15971612

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /