|
|
@ -1119,30 +1119,31 @@ |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
" ### Turbo mode - skip some diffusions, use 3d morph for clarity and to save time\n", |
|
|
|
" ### Turbo mode - skip some diffusions, use 3d morph for clarity and to save time\n", |
|
|
|
" turbo_blend = False # default for non-turbo frame saving\n", |
|
|
|
" turbo_blend = False # default for non-turbo frame saving\n", |
|
|
|
" if turbo_mode == True and frame_num == turbo_preroll: #start tracking oldframe\n", |
|
|
|
" if turbo_mode:\n", |
|
|
|
" next_step_pil.save('oldFrameScaled.png')#stash for later blending \n", |
|
|
|
" if frame_num == turbo_preroll: #start tracking oldframe\n", |
|
|
|
" if turbo_mode == True and frame_num > turbo_preroll:\n", |
|
|
|
" next_step_pil.save('oldFrameScaled.png')#stash for later blending \n", |
|
|
|
" #set up 2 warped image sequences, old & new, to blend toward new diff image\n", |
|
|
|
" elif frame_num > turbo_preroll:\n", |
|
|
|
" old_frame = do_3d_step('oldFrameScaled.png', frame_num, midas_model, midas_transform)\n", |
|
|
|
" #set up 2 warped image sequences, old & new, to blend toward new diff image\n", |
|
|
|
" old_frame.save('oldFrameScaled.png')\n", |
|
|
|
" old_frame = do_3d_step('oldFrameScaled.png', frame_num, midas_model, midas_transform)\n", |
|
|
|
" if frame_num % int(turbo_steps) != 0: \n", |
|
|
|
" old_frame.save('oldFrameScaled.png')\n", |
|
|
|
" print('turbo skip this frame: skipping clip diffusion steps')\n", |
|
|
|
" if frame_num % int(turbo_steps) != 0: \n", |
|
|
|
" filename = f'{args.batch_name}({args.batchNum})_{frame_num:04}.png'\n", |
|
|
|
" print('turbo skip this frame: skipping clip diffusion steps')\n", |
|
|
|
" blend_factor = ((frame_num % int(turbo_steps))+1)/int(turbo_steps)\n", |
|
|
|
" filename = f'{args.batch_name}({args.batchNum})_{frame_num:04}.png'\n", |
|
|
|
" print('turbo skip this frame: skipping clip diffusion steps and saving blended frame')\n", |
|
|
|
" blend_factor = ((frame_num % int(turbo_steps))+1)/int(turbo_steps)\n", |
|
|
|
" newWarpedImg = cv2.imread('prevFrameScaled.png')#this is already updated..\n", |
|
|
|
" print('turbo skip this frame: skipping clip diffusion steps and saving blended frame')\n", |
|
|
|
" oldWarpedImg = cv2.imread('oldFrameScaled.png')\n", |
|
|
|
" newWarpedImg = cv2.imread('prevFrameScaled.png')#this is already updated..\n", |
|
|
|
" blendedImage = cv2.addWeighted(newWarpedImg, blend_factor, oldWarpedImg,1-blend_factor, 0.0)\n", |
|
|
|
" oldWarpedImg = cv2.imread('oldFrameScaled.png')\n", |
|
|
|
" cv2.imwrite(f'{batchFolder}/{filename}',blendedImage)\n", |
|
|
|
" blendedImage = cv2.addWeighted(newWarpedImg, blend_factor, oldWarpedImg,1-blend_factor, 0.0)\n", |
|
|
|
" next_step_pil.save(f'{img_filepath}') # save it also as prev_frame to feed next iteration\n", |
|
|
|
" cv2.imwrite(f'{batchFolder}/{filename}',blendedImage)\n", |
|
|
|
" turbo_blend = False\n", |
|
|
|
" next_step_pil.save(f'{img_filepath}') # save it also as prev_frame to feed next iteration\n", |
|
|
|
" continue\n", |
|
|
|
" turbo_blend = False\n", |
|
|
|
" else:\n", |
|
|
|
" continue\n", |
|
|
|
" #if not a skip frame, will run diffusion and need to blend.\n", |
|
|
|
" else:\n", |
|
|
|
" oldWarpedImg = cv2.imread('prevFrameScaled.png')\n", |
|
|
|
" #if not a skip frame, will run diffusion and need to blend.\n", |
|
|
|
" cv2.imwrite(f'oldFrameScaled.png',oldWarpedImg)#swap in for blending later \n", |
|
|
|
" oldWarpedImg = cv2.imread('prevFrameScaled.png')\n", |
|
|
|
" turbo_blend = True # flag to blend frames after diff generated...\n", |
|
|
|
" cv2.imwrite(f'oldFrameScaled.png',oldWarpedImg)#swap in for blending later \n", |
|
|
|
" print('clip/diff this frame - generate clip diff image')\n", |
|
|
|
" turbo_blend = True # flag to blend frames after diff generated...\n", |
|
|
|
|
|
|
|
" print('clip/diff this frame - generate clip diff image')\n", |
|
|
|
"\n", |
|
|
|
"\n", |
|
|
|
" init_image = 'prevFrameScaled.png'\n", |
|
|
|
" init_image = 'prevFrameScaled.png'\n", |
|
|
|
" init_scale = args.frames_scale\n", |
|
|
|
" init_scale = args.frames_scale\n", |
|
|
@ -3006,11 +3007,11 @@ |
|
|
|
" batchNum = int(run_to_resume)\n", |
|
|
|
" batchNum = int(run_to_resume)\n", |
|
|
|
" if resume_from_frame == 'latest':\n", |
|
|
|
" if resume_from_frame == 'latest':\n", |
|
|
|
" start_frame = len(glob(batchFolder+f\"/{batch_name}({batchNum})_*.png\"))\n", |
|
|
|
" start_frame = len(glob(batchFolder+f\"/{batch_name}({batchNum})_*.png\"))\n", |
|
|
|
" if turbo_mode == True and start_frame > turbo_preroll and start_frame % int(turbo_steps) != 0:\n", |
|
|
|
" if animation_mode != '3D' and turbo_mode == True and start_frame > turbo_preroll and start_frame % int(turbo_steps) != 0:\n", |
|
|
|
" start_frame = start_frame - (start_frame % int(turbo_steps))\n", |
|
|
|
" start_frame = start_frame - (start_frame % int(turbo_steps))\n", |
|
|
|
" else:\n", |
|
|
|
" else:\n", |
|
|
|
" start_frame = int(resume_from_frame)+1\n", |
|
|
|
" start_frame = int(resume_from_frame)+1\n", |
|
|
|
" if turbo_mode == True and start_frame > turbo_preroll and start_frame % int(turbo_steps) != 0:\n", |
|
|
|
" if animation_mode != '3D' and turbo_mode == True and start_frame > turbo_preroll and start_frame % int(turbo_steps) != 0:\n", |
|
|
|
" start_frame = start_frame - (start_frame % int(turbo_steps))\n", |
|
|
|
" start_frame = start_frame - (start_frame % int(turbo_steps))\n", |
|
|
|
" if retain_overwritten_frames is True:\n", |
|
|
|
" if retain_overwritten_frames is True:\n", |
|
|
|
" existing_frames = len(glob(batchFolder+f\"/{batch_name}({batchNum})_*.png\"))\n", |
|
|
|
" existing_frames = len(glob(batchFolder+f\"/{batch_name}({batchNum})_*.png\"))\n", |
|
|
|