@ -1111,16 +1111,20 @@
" sampling_mode=args.sampling_mode, midas_weight=args.midas_weight)\n",
" sampling_mode=args.sampling_mode, midas_weight=args.midas_weight)\n",
" next_step_pil.save('prevFrameScaled.png')\n",
" next_step_pil.save('prevFrameScaled.png')\n",
"\n",
"\n",
" ### Turbo mode - skip some diffusions to save time \n",
" ### Turbo mode - skip some diffusions to save time\n",
" if turbo_mode == True and frame_num > 10 and frame_num % int(turbo_steps) != 0:\n",
" turbo_blend = False # default to normal frame saving later\n",
" print('turbo mode is on this frame: skipping clip diffusion steps')\n",
" if turbo_mode and frame_num > 10: #preroll is 10 frames\n",
" filename = f'{args.batch_name}({args.batchNum})_{frame_num:04}.png'\n",
" if frame_num % int(turbo_steps) != 0:\n",
" next_step_pil.save(f'{batchFolder}/{filename}') #save it as this frame\n",
" print('turbo skip this frame: skipping clip diffusion steps')\n",
" next_step_pil.save(f'{img_filepath}') # save it also as prev_frame for next iteration\n",
" filename = f'{args.batch_name}({args.batchNum})_{frame_num:04}.png'\n",
" continue\n",
" next_step_pil.save(f'{batchFolder}/{filename}') #save it as this frame. done.\n",
" elif turbo_mode == True:\n",
" next_step_pil.save(f'{img_filepath}') # save it also as prev_frame to feed next iteration\n",
" print('turbo mode is OFF this frame')\n",
" turbo_blend = False # default to normal-frame-saving later\n",
" #else: no turbo\n",
" continue\n",
" else:\n",
" if turbo_frame_blend:\n",
" turbo_blend = True # blend frames for smoothness..\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",
@ -1393,6 +1397,17 @@
" image.save(f'{unsharpenFolder}/{filename}')\n",
" image.save(f'{unsharpenFolder}/{filename}')\n",
" else:\n",
" else:\n",
" image.save(f'{batchFolder}/{filename}')\n",
" image.save(f'{batchFolder}/{filename}')\n",
" if args.animation_mode == \"3D\":\n",
" # If turbo_blend, save a blended image\n",
" if turbo_mode and turbo_blend:\n",
" # Mix new image with prevFrameScaled\n",
" newFrame = cv2.imread('prevFrame.png') # This is already updated..\n",
" prev_frame_warped = cv2.imread('prevFrameScaled.png')\n",
" blendedImage = cv2.addWeighted(newFrame, 0.5, prev_frame_warped, 0.5, 0.0)\n",
" cv2.imwrite(f'{batchFolder}/{filename}',blendedImage)\n",
" turbo_blend = False # reset to false\n",
" else:\n",
" image.save(f'{batchFolder}/{filename}')\n",
" # if frame_num != args.max_frames-1:\n",
" # if frame_num != args.max_frames-1:\n",
" # display.clear_output()\n",
" # display.clear_output()\n",
"\n",
"\n",
@ -1474,6 +1489,7 @@
" 'extract_nth_frame':extract_nth_frame,\n",
" 'extract_nth_frame':extract_nth_frame,\n",
" 'turbo_mode':turbo_mode,\n",
" 'turbo_mode':turbo_mode,\n",
" 'turbo_steps':turbo_steps,\n",
" 'turbo_steps':turbo_steps,\n",
" 'turbo_frame_blend':turbo_frame_blend,\n",
" }\n",
" }\n",
" # print('Settings:', setting_list)\n",
" # print('Settings:', setting_list)\n",
" with open(f\"{batchFolder}/{batch_name}({batchNum})_settings.txt\", \"w+\") as f: #save settings\n",
" with open(f\"{batchFolder}/{batch_name}({batchNum})_settings.txt\", \"w+\") as f: #save settings\n",
@ -2521,11 +2537,12 @@
"#======= TURBO MODE\n",
"#======= TURBO MODE\n",
"#@markdown ---\n",
"#@markdown ---\n",
"#@markdown ####**Turbo Mode (3D anim only):**\n",
"#@markdown ####**Turbo Mode (3D anim only):**\n",
"#@markdown (Starts after frame 10,) skips diffusion steps and just uses MIDAS depth map to warp images for skipped frames.\n",
"#@markdown (Starts after frame 10,) skips diffusion steps and just uses depth map to warp images for skipped frames.\n",
"#@markdown Speeds up rendering by 2x-4x, and may improve image coherence between frames.\n",
"#@markdown Speeds up rendering by 2x-4x, and may improve image coherence between frames. frame_blend_mode smooths abrupt texture changes across 2 frames. \n",
"\n",
"\n",
"turbo_mode = True #@param {type:\"boolean\"}\n",
"turbo_mode = True #@param {type:\"boolean\"}\n",
"turbo_steps = \"3\" #@param [\"2\",\"3\",\"4\"] {type:'string'}\n",
"turbo_steps = \"3\" #@param [\"2\",\"3\",\"4\",\"5\",\"6\"] {type:\"string\"}\n",
"turbo_frame_blend = True #@param {type:\"boolean\"}\n",
"#@markdown ---\n",
"#@markdown ---\n",
"\n",
"\n",
"#@markdown ####**Coherency Settings:**\n",
"#@markdown ####**Coherency Settings:**\n",