cleanup
This commit is contained in:
parent
9085d01dc7
commit
58cadd23d5
|
@ -32,23 +32,24 @@ torch.set_grad_enabled(False)
|
||||||
|
|
||||||
|
|
||||||
#%% First let us spawn a stable diffusion holder
|
#%% First let us spawn a stable diffusion holder
|
||||||
device = "cuda:0"
|
use_inpaint = True
|
||||||
num_inference_steps = 20 # Number of diffusion interations
|
|
||||||
fp_ckpt = "../stable_diffusion_models/ckpt/768-v-ema.ckpt"
|
device = "cuda"
|
||||||
fp_config = '../stablediffusion/configs/stable-diffusion/v2-inference-v.yaml'
|
fp_ckpt= "../stable_diffusion_models/ckpt/512-inpainting-ema.ckpt"
|
||||||
|
fp_config = '../stablediffusion/configs//stable-diffusion/v2-inpainting-inference.yaml'
|
||||||
|
|
||||||
|
|
||||||
|
# fp_ckpt = "../stable_diffusion_models/ckpt/768-v-ema.ckpt"
|
||||||
|
# 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)
|
|
||||||
|
|
||||||
#%% Next let's set up all parameters
|
#%% Next let's set up all parameters
|
||||||
num_inference_steps = 30 # Number of diffusion interations
|
num_inference_steps = 30 # Number of diffusion interations
|
||||||
list_nmb_branches = [2, 3, 10, 24]#, 50] # Branching structure: how many branches
|
|
||||||
list_injection_strength = [0.0, 0.6, 0.8, 0.9]#, 0.95] # Branching structure: how deep is the blending
|
|
||||||
|
|
||||||
guidance_scale = 5
|
guidance_scale = 5
|
||||||
fps = 30
|
|
||||||
duration_target = 10
|
|
||||||
width = 512
|
|
||||||
height = 512
|
|
||||||
|
|
||||||
lb = LatentBlending(sdh, num_inference_steps, guidance_scale)
|
lb = LatentBlending(sdh, num_inference_steps, guidance_scale)
|
||||||
|
|
||||||
|
@ -71,6 +72,32 @@ for k, prompt in enumerate(list_prompts):
|
||||||
plt.show()
|
plt.show()
|
||||||
print(f"prompt {k} seed {seed} trial {i}")
|
print(f"prompt {k} seed {seed} trial {i}")
|
||||||
|
|
||||||
|
#%%
|
||||||
|
#%% Let's make a source image and mask.
|
||||||
|
k=0
|
||||||
|
for i in range(10):
|
||||||
|
seed = 190791709# np.random.randint(999999999)
|
||||||
|
# seed0 = 629575320
|
||||||
|
|
||||||
|
lb = LatentBlending(sdh)
|
||||||
|
lb.autosetup_branching(quality='medium', deepth_strength=0.65)
|
||||||
|
|
||||||
|
prompt1 = "photo of a futuristic alien temple in a desert, mystic, glowing, organic, intricate, sci-fi movie, mesmerizing, scary"
|
||||||
|
lb.set_prompt1(prompt1)
|
||||||
|
lb.init_inpainting(init_empty=True)
|
||||||
|
lb.set_seed(seed)
|
||||||
|
plt.imshow(lb.run_diffusion(lb.text_embedding1, return_image=True))
|
||||||
|
plt.title(f"prompt1 {k}, seed {i} {seed}")
|
||||||
|
plt.show()
|
||||||
|
print(f"prompt1 {k} seed {seed} trial {i}")
|
||||||
|
|
||||||
|
xx
|
||||||
|
|
||||||
|
#%%
|
||||||
|
mask_image = 255*np.ones([512,512], dtype=np.uint8)
|
||||||
|
mask_image[340:420, 170:280, ] = 0
|
||||||
|
mask_image = Image.fromarray(mask_image)
|
||||||
|
|
||||||
#%%
|
#%%
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -40,15 +40,17 @@ sdh = StableDiffusionHolder(fp_ckpt, fp_config, device)
|
||||||
|
|
||||||
#%% Next let's set up all parameters
|
#%% Next let's set up all parameters
|
||||||
quality = 'medium'
|
quality = 'medium'
|
||||||
|
deepth_strength = 0.65
|
||||||
fixed_seeds = [69731932, 504430820]
|
fixed_seeds = [69731932, 504430820]
|
||||||
|
|
||||||
lb = LatentBlending(sdh)
|
|
||||||
prompt1 = "photo of a beautiful forest covered in white flowers, ambient light, very detailed, magic"
|
prompt1 = "photo of a beautiful forest covered in white flowers, ambient light, very detailed, magic"
|
||||||
prompt2 = "photo of an golden statue with a funny hat, surrounded by ferns and vines, grainy analog photograph, mystical ambience, incredible detail"
|
prompt2 = "photo of an golden statue with a funny hat, surrounded by ferns and vines, grainy analog photograph, mystical ambience, incredible detail"
|
||||||
|
|
||||||
|
lb = LatentBlending(sdh)
|
||||||
|
lb.autosetup_branching(quality=quality, deepth_strength=deepth_strength)
|
||||||
lb.set_prompt1(prompt1)
|
lb.set_prompt1(prompt1)
|
||||||
lb.set_prompt2(prompt2)
|
lb.set_prompt2(prompt2)
|
||||||
|
|
||||||
lb.autosetup_branching(quality=quality)
|
|
||||||
|
|
||||||
imgs_transition = lb.run_transition(fixed_seeds=fixed_seeds)
|
imgs_transition = lb.run_transition(fixed_seeds=fixed_seeds)
|
||||||
|
|
||||||
|
@ -58,7 +60,7 @@ fps = 60
|
||||||
imgs_transition_ext = add_frames_linear_interp(imgs_transition, duration_transition, fps)
|
imgs_transition_ext = add_frames_linear_interp(imgs_transition, duration_transition, fps)
|
||||||
|
|
||||||
# movie saving
|
# movie saving
|
||||||
fp_movie = f"movie_example1.mp4"
|
fp_movie = "movie_example1.mp4"
|
||||||
if os.path.isfile(fp_movie):
|
if os.path.isfile(fp_movie):
|
||||||
os.remove(fp_movie)
|
os.remove(fp_movie)
|
||||||
ms = MovieSaver(fp_movie, fps=fps, shape_hw=[sdh.height, sdh.width])
|
ms = MovieSaver(fp_movie, fps=fps, shape_hw=[sdh.height, sdh.width])
|
||||||
|
|
|
@ -34,40 +34,32 @@ from stable_diffusion_holder import StableDiffusionHolder
|
||||||
torch.set_grad_enabled(False)
|
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"
|
||||||
num_inference_steps = 20 # Number of diffusion interations
|
quality = 'medium'
|
||||||
|
deepth_strength = 0.65
|
||||||
fp_ckpt= "../stable_diffusion_models/ckpt/512-inpainting-ema.ckpt"
|
fp_ckpt= "../stable_diffusion_models/ckpt/512-inpainting-ema.ckpt"
|
||||||
fp_config = '../stablediffusion/configs//stable-diffusion/v2-inpainting-inference.yaml'
|
fp_config = '../stablediffusion/configs//stable-diffusion/v2-inpainting-inference.yaml'
|
||||||
|
|
||||||
sdh = StableDiffusionHolder(fp_ckpt, fp_config, device, num_inference_steps=num_inference_steps)
|
sdh = StableDiffusionHolder(fp_ckpt, fp_config, device)
|
||||||
|
|
||||||
|
|
||||||
#%% Let's make a source image and mask.
|
#%% Let's make a source image and mask.
|
||||||
height = 512
|
seed0 = 190791709
|
||||||
width = 512
|
|
||||||
num_inference_steps = 30
|
|
||||||
guidance_scale = 5
|
|
||||||
fixed_seeds = [629575320, 670154945]
|
|
||||||
|
|
||||||
lb = LatentBlending(sdh)
|
lb = LatentBlending(sdh)
|
||||||
lb.autosetup_branching("low")
|
lb.autosetup_branching(quality=quality, deepth_strength=deepth_strength)
|
||||||
prompt1 = "photo of a futuristic alien temple in a desert, mystic, glowing, organic, intricate, sci-fi movie, mesmerizing, scary"
|
prompt1 = "photo of a futuristic alien temple in a desert, mystic, glowing, organic, intricate, sci-fi movie, mesmerizing, scary"
|
||||||
lb.set_prompt1(prompt1)
|
lb.set_prompt1(prompt1)
|
||||||
lb.init_inpainting(init_empty=True)
|
lb.init_inpainting(init_empty=True)
|
||||||
lb.set_seed(fixed_seeds[0])
|
lb.set_seed(seed0)
|
||||||
image_source = lb.run_diffusion(lb.text_embedding1, return_image=True)
|
image_source = lb.run_diffusion(lb.text_embedding1, return_image=True)
|
||||||
mask_image = 255*np.ones([512,512], dtype=np.uint8)
|
mask_image = 255*np.ones([512,512], dtype=np.uint8)
|
||||||
mask_image[160:250, 200:320] = 0
|
mask_image[340:420, 170:280, ] = 0
|
||||||
mask_image = Image.fromarray(mask_image)
|
mask_image = Image.fromarray(mask_image)
|
||||||
|
|
||||||
|
|
||||||
#%% Next let's set up all parameters
|
#%% Next let's set up all parameters
|
||||||
# FIXME below fix numbers
|
fixed_seeds = [seed0, 280335986]
|
||||||
# We want 20 diffusion steps, begin with 2 branches, have 3 branches at step 12 (=0.6*20)
|
|
||||||
# 10 branches at step 16 (=0.8*20) and 24 branches at step 18 (=0.9*20)
|
|
||||||
# Furthermore we want seed 993621550 for keyframeA and seed 54878562 for keyframeB ()
|
|
||||||
|
|
||||||
fixed_seeds = [993621550, 280335986]
|
|
||||||
|
|
||||||
prompt1 = "photo of a futuristic alien temple in a desert, mystic, glowing, organic, intricate, sci-fi movie, mesmerizing, scary"
|
prompt1 = "photo of a futuristic alien temple in a desert, mystic, glowing, organic, intricate, sci-fi movie, mesmerizing, scary"
|
||||||
prompt2 = "aerial photo of a futuristic alien temple in a coastal area, waves clashing"
|
prompt2 = "aerial photo of a futuristic alien temple in a coastal area, waves clashing"
|
||||||
|
|
Loading…
Reference in New Issue