Skip to content

Commit

Permalink
remove unneeded code for now
Browse files Browse the repository at this point in the history
  • Loading branch information
painebenjamin committed Jan 17, 2024
1 parent d57e3c7 commit 00da07b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 54 deletions.
25 changes: 1 addition & 24 deletions src/python/enfugue/diffusion/invocation/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class LayeredInvocation:
max_guidance_scale: float=3.0
# dragnuwa
motion_vectors: Optional[List[List[MotionVectorPointDict]]]=None
optical_flow: Optional[Dict[OPTICAL_FLOW_METHOD_LITERAL, Union[List[Image],List[List[Image]]]]]=None
motion_vector_repeat_window: bool=False
gaussian_sigma: int=20
# img2img
Expand Down Expand Up @@ -1766,32 +1765,10 @@ def execute_stable_video(
"motion_bucket_id": self.motion_bucket_id
}

if self.motion_vectors or self.optical_flow:
if self.motion_vectors:
svd_kwargs["motion_vectors"] = self.motion_vectors
svd_kwargs["motion_vector_repeat_window"] = self.motion_vector_repeat_window
svd_kwargs["gaussian_sigma"] = self.gaussian_sigma
if self.optical_flow:
optical_flow = {}
for method in self.optical_flow:
frame_lists = self.optical_flow[method]
if not frame_lists:
continue
if not isinstance(frame_lists[0], list):
frame_lists = [frame_lists]
optical_flow[method] = [
[
self.prepare_image(
width=self.width,
height=self.height,
image=frame,
animation_frames=self.animation_frames,
return_mask=False
)
for frame in frame_list
]
for frame_list in frame_lists
]
svd_kwargs["optical_flow"] = optical_flow
logger.debug(f"Calling DragNUWA pipeline with arguments {redact_for_log(svd_kwargs)}")
frames = pipeline.dragnuwa_img2vid(
task_callback=task_callback,
Expand Down
2 changes: 0 additions & 2 deletions src/python/enfugue/diffusion/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4823,7 +4823,6 @@ def dragnuwa_img2vid(
self,
image: Union[str, PIL.Image.Image],
motion_vectors: List[List[MotionVectorPointDict]],
optical_flow: Dict[OPTICAL_FLOW_METHOD_LITERAL, List[List[PIL.Image.Image]]]={},
motion_vector_repeat_window: bool=False,
decode_chunk_size: Optional[int]=1,
num_frames: int=14,
Expand Down Expand Up @@ -4929,7 +4928,6 @@ def decode_svd_latents(latents, iteration):
num_inference_steps=num_inference_steps,
min_guidance_scale=min_guidance_scale,
max_guidance_scale=max_guidance_scale,
optical_flow=optical_flow,
progress_callback=progress_callback,
latent_callback=latent_callback,
latent_callback_steps=image_callback_steps
Expand Down
29 changes: 1 addition & 28 deletions src/python/enfugue/diffusion/support/drag/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def __call__(
num_frames: int=14,
frame_window_size: int=14,
num_inference_steps: int=25,
optical_flow: Optional[Dict[OPTICAL_FLOW_METHOD_LITERAL, List[List[Image]]]] = None,
motion_vectors: List[List[MotionVectorPointDict]] = [],
motion_vector_repeat_window: bool = False,
progress_callback: Optional[Callable[[int, int, float], None]]=None,
Expand All @@ -57,15 +56,10 @@ def __call__(
Executes the network
"""
import torch
import numpy as np
from torchvision import transforms, utils
from PIL import Image
from einops import repeat, rearrange
from enfugue.diffusion.util import (
Video,
motion_vector_conditioning_tensor,
optical_flow_conditioning_tensor,
)
from enfugue.diffusion.util import motion_vector_conditioning_tensor

# Set args
self.network.args.width = width
Expand Down Expand Up @@ -94,25 +88,6 @@ def __call__(
# Repeat condition
condition = condition.repeat(num_iterations, 1, 1, 1)[:num_frames-num_zero_frames, :, :, :]

# Calculate optical flow and add to condition
if optical_flow:
for optical_flow_method in optical_flow:
for image_sequence in optical_flow[optical_flow_method]:
image_sequence = image_sequence[:condition_frames]
sequence_gaussian_sigma: Optional[int] = None
if optical_flow_method == "lucas-kanade":
flow = Video(image_sequence).sparse_flow()
sequence_gaussian_sigma = gaussian_sigma
else:
flow = Video(image_sequence).dense_flow(optical_flow_method)
sequence_condition = optical_flow_conditioning_tensor(
np.array([flow_frame for flow_frame in flow]),
gaussian_sigma=sequence_gaussian_sigma,
device=self.device,
dtype=self.dtype
)
condition[0:sequence_condition.shape[0]] += sequence_condition[:condition.shape[0]]

# Insert zero-frames
for i in range(num_zero_frames):
index = (i + 1) * frame_window_size
Expand Down Expand Up @@ -267,7 +242,6 @@ def __call__(
num_inference_steps: int=25,
min_guidance_scale: float=1.0,
max_guidance_scale: float=3.0,
optical_flow: Optional[Dict[OPTICAL_FLOW_METHOD_LITERAL, List[List[Image]]]] = None,
progress_callback: Optional[Callable[[int, int, float], None]]=None,
motion_vector_repeat_window: bool=False,
latent_callback: Optional[Callable[[Tensor, int], None]]=None,
Expand All @@ -288,7 +262,6 @@ def __call__(
num_inference_steps=num_inference_steps,
min_guidance_scale=min_guidance_scale,
max_guidance_scale=max_guidance_scale,
optical_flow=optical_flow,
motion_vectors=motion_vectors,
motion_bucket_id=motion_bucket_id,
batch_size=batch_size,
Expand Down

0 comments on commit 00da07b

Please sign in to comment.