Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug checkbox #28

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions demo/animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __init__(self, config="configs/prompts/animation.yaml") -> None:

print("Initialization Done!")

def __call__(self, source_image, motion_sequence, random_seed, step, guidance_scale, size=512):
def __call__(self, source_image, motion_sequence, random_seed, step, guidance_scale, debug, size=512):
prompt = n_prompt = ""
random_seed = int(random_seed)
step = int(step)
Expand Down Expand Up @@ -171,17 +171,17 @@ def __call__(self, source_image, motion_sequence, random_seed, step, guidance_sc
source_image = source_image,
).videos

source_images = np.array([source_image] * original_length)
source_images = rearrange(torch.from_numpy(source_images), "t h w c -> 1 c t h w") / 255.0
samples_per_video.append(source_images)

control = control / 255.0
control = rearrange(control, "t h w c -> 1 c t h w")
control = torch.from_numpy(control)
samples_per_video.append(control[:, :, :original_length])
if debug:
source_images = np.array([source_image] * original_length)
source_images = rearrange(torch.from_numpy(source_images), "t h w c -> 1 c t h w") / 255.0
samples_per_video.append(source_images)

control = control / 255.0
control = rearrange(control, "t h w c -> 1 c t h w")
control = torch.from_numpy(control)
samples_per_video.append(control[:, :, :original_length])

samples_per_video.append(sample[:, :, :original_length])

samples_per_video = torch.cat(samples_per_video)

time_str = datetime.datetime.now().strftime("%Y-%m-%dT%H-%M-%S")
Expand All @@ -192,4 +192,4 @@ def __call__(self, source_image, motion_sequence, random_seed, step, guidance_sc
save_videos_grid(samples_per_video, animation_path)

return animation_path


9 changes: 5 additions & 4 deletions demo/gradio_animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

animator = MagicAnimate()

def animate(reference_image, motion_sequence_state, seed, steps, guidance_scale):
return animator(reference_image, motion_sequence_state, seed, steps, guidance_scale)
def animate(reference_image, motion_sequence_state, seed, steps, guidance_scale, debug):
return animator(reference_image, motion_sequence_state, seed, steps, guidance_scale, debug)

with gr.Blocks() as demo:

Expand Down Expand Up @@ -49,6 +49,7 @@ def animate(reference_image, motion_sequence_state, seed, steps, guidance_scale)
random_seed = gr.Textbox(label="Random seed", value=1, info="default: -1")
sampling_steps = gr.Textbox(label="Sampling steps", value=25, info="default: 25")
guidance_scale = gr.Textbox(label="Guidance scale", value=7.5, info="default: 7.5")
debug = gr.Checkbox(label="Debug", value=True)
submit = gr.Button("Animate")

def read_video(video):
Expand All @@ -74,7 +75,7 @@ def read_image(image, size=512):
# when the `submit` button is clicked
submit.click(
animate,
[reference_image, motion_sequence, random_seed, sampling_steps, guidance_scale],
[reference_image, motion_sequence, random_seed, sampling_steps, guidance_scale, debug],
animation
)

Expand All @@ -94,4 +95,4 @@ def read_image(image, size=512):
)


demo.launch(share=True)
demo.launch()
2 changes: 1 addition & 1 deletion demo/gradio_animate_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ def read_image(image, size=512):
)

demo.queue(max_size=10)
demo.launch(share=True)
demo.launch()