multi trans with new branching setup

This commit is contained in:
lugo 2022-11-28 16:16:19 +01:00
parent 162bc1e516
commit 9085d01dc7
2 changed files with 8 additions and 48 deletions

View File

@ -32,47 +32,28 @@ torch.set_grad_enabled(False)
#%% First let us spawn a stable diffusion holder #%% First let us spawn a stable diffusion holder
device = "cuda:0" device = "cuda:0"
num_inference_steps = 20 # Number of diffusion interations
fp_ckpt = "../stable_diffusion_models/ckpt/768-v-ema.ckpt" fp_ckpt = "../stable_diffusion_models/ckpt/768-v-ema.ckpt"
fp_config = '../stablediffusion/configs/stable-diffusion/v2-inference-v.yaml' fp_config = '../stablediffusion/configs/stable-diffusion/v2-inference-v.yaml'
sdh = StableDiffusionHolder(fp_ckpt, fp_config, device)
sdh = StableDiffusionHolder(fp_ckpt, fp_config, device, num_inference_steps=num_inference_steps)
#%% MULTITRANS #%% MULTITRANS
num_inference_steps = 30 # Number of diffusion interations
list_nmb_branches = [2, 10, 50, 100, 200] #
list_injection_strength = list(np.linspace(0.5, 0.95, 4)) # Branching structure: how deep is the blending
list_injection_strength.insert(0, 0.0)
guidance_scale = 5
fps = 30 fps = 30
duration_single_trans = 20 duration_single_trans = 15
width = 768 quality = 'high'
height = 768 deepth_strength = 0.55
lb = LatentBlending(sdh)
lb = LatentBlending(sdh, num_inference_steps, guidance_scale) lb.autosetup_branching(quality=quality, deepth_strength=deepth_strength)
# deepth_strength = 0.5
# num_inference_steps, list_injection_idx, list_nmb_branches = lb.get_branching('medium', deepth_strength, fps*duration_single_trans)
list_prompts = [] list_prompts = []
list_prompts.append("surrealistic statue made of glitter and dirt, standing in a lake, atmospheric light, strange glow") list_prompts.append("surrealistic statue made of glitter and dirt, standing in a lake, atmospheric light, strange glow")
list_prompts.append("statue of a mix between a tree and human, made of marble, incredibly detailed") list_prompts.append("statue of a mix between a tree and human, made of marble, incredibly detailed")
list_prompts.append("weird statue of a frog monkey, many colors, standing next to the ruins of an ancient city") list_prompts.append("weird statue of a frog monkey, many colors, standing next to the ruins of an ancient city")
list_prompts.append("statue made of hot metal, bizzarre, dark clouds in the sky")
list_prompts.append("statue of a spider that looked like a human") list_prompts.append("statue of a spider that looked like a human")
list_prompts.append("statue of a bird that looked like a scorpion") list_prompts.append("statue of a bird that looked like a scorpion")
list_prompts.append("statue of an ancient cybernetic messenger annoucing good news, golden, futuristic") list_prompts.append("statue of an ancient cybernetic messenger annoucing good news, golden, futuristic")
list_seeds = [954375479, 332539350, 956051013, 408831845, 250009012, 675588737]
list_seeds = [234187386, 422209351, 241845736, 28652396, 783279867, 831049796, 234903931]
fp_movie = "movie_example3.mp4" fp_movie = "movie_example3.mp4"
ms = MovieSaver(fp_movie, fps=fps) ms = MovieSaver(fp_movie, fps=fps)
@ -80,19 +61,9 @@ ms = MovieSaver(fp_movie, fps=fps)
lb.run_multi_transition( lb.run_multi_transition(
list_prompts, list_prompts,
list_seeds, list_seeds,
list_nmb_branches,
# list_injection_idx=list_injection_idx,
list_injection_strength=list_injection_strength,
ms=ms, ms=ms,
fps=fps, fps=fps,
duration_single_trans=duration_single_trans duration_single_trans=duration_single_trans
) )
#%%
#for img in lb.tree_final_imgs:
# if img is not None:
# ms.write_frame(img)
#
#ms.finalize()

View File

@ -454,9 +454,6 @@ class LatentBlending():
self, self,
list_prompts: List[str], list_prompts: List[str],
list_seeds: List[int] = None, list_seeds: List[int] = None,
list_nmb_branches: List[int] = None,
list_injection_strength: List[float] = None,
list_injection_idx: List[int] = None,
ms: MovieSaver = None, ms: MovieSaver = None,
fps: float = 24, fps: float = 24,
duration_single_trans: float = 15, duration_single_trans: float = 15,
@ -468,14 +465,6 @@ class LatentBlending():
list of the prompts. There will be a transition starting from the first to the last. list of the prompts. There will be a transition starting from the first to the last.
list_seeds: List[int] = None: list_seeds: List[int] = None:
Random Seeds for each prompt. Random Seeds for each prompt.
list_nmb_branches: List[int]:
list of the number of branches for each injection.
list_injection_strength: List[float]:
list of injection strengths within interval [0, 1), values need to be increasing.
Alternatively you can direclty specify the list_injection_idx.
list_injection_idx: List[int]:
list of injection strengths within interval [0, 1), values need to be increasing.
Alternatively you can specify the list_injection_strength.
ms: MovieSaver ms: MovieSaver
You need to spawn a moviesaver instance. You need to spawn a moviesaver instance.
fps: float: fps: float:
@ -505,7 +494,7 @@ class LatentBlending():
recycle_img1 = True recycle_img1 = True
local_seeds = [list_seeds[i], list_seeds[i+1]] local_seeds = [list_seeds[i], list_seeds[i+1]]
list_imgs = self.run_transition(list_nmb_branches, list_injection_strength=list_injection_strength, list_injection_idx=list_injection_idx, recycle_img1=recycle_img1, fixed_seeds=local_seeds) list_imgs = self.run_transition(recycle_img1=recycle_img1, fixed_seeds=local_seeds)
list_imgs_interp = add_frames_linear_interp(list_imgs, fps, duration_single_trans) list_imgs_interp = add_frames_linear_interp(list_imgs, fps, duration_single_trans)
# Save movie frame # Save movie frame