Adds basic/original zippy turbo mode - with working resume functionality

pull/14/head
Adam Letts 3 years ago
parent 92d90c0666
commit 9e3d032e50
  1. 26
      Disco_Diffusion.ipynb
  2. 26
      disco.py

@ -1110,6 +1110,18 @@
" args.fov, padding_mode=args.padding_mode,\n",
" sampling_mode=args.sampling_mode, midas_weight=args.midas_weight)\n",
" next_step_pil.save('prevFrameScaled.png')\n",
"\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",
" print('turbo mode is on this frame: skipping clip diffusion steps')\n",
" filename = f'{args.batch_name}({args.batchNum})_{frame_num:04}.png'\n",
" next_step_pil.save(f'{batchFolder}/{filename}') #save it as this frame\n",
" next_step_pil.save(f'{img_filepath}') # save it also as prev_frame for next iteration\n",
" continue\n",
" elif turbo_mode == True:\n",
" print('turbo mode is OFF this frame')\n",
" #else: no turbo\n",
"\n",
" init_image = 'prevFrameScaled.png'\n",
" init_scale = args.frames_scale\n",
" skip_steps = args.calc_frames_skip_steps\n",
@ -1460,6 +1472,8 @@
" 'sampling_mode': sampling_mode,\n",
" 'video_init_path':video_init_path,\n",
" 'extract_nth_frame':extract_nth_frame,\n",
" 'turbo_mode':turbo_mode,\n",
" 'turbo_steps':turbo_steps,\n",
" }\n",
" # print('Settings:', setting_list)\n",
" with open(f\"{batchFolder}/{batch_name}({batchNum})_settings.txt\", \"w+\") as f: #save settings\n",
@ -2504,6 +2518,14 @@
"padding_mode = 'border'#@param {type:\"string\"}\n",
"sampling_mode = 'bicubic'#@param {type:\"string\"}\n",
"\n",
"#======= TURBO MODE\n",
"#@markdown ---\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 Speeds up rendering by 2x-4x, and may improve image coherence between frames.\n",
"\n",
"turbo_mode = True #@param {type:\"boolean\"}\n",
"turbo_steps = \"3\" #@param [\"2\",\"3\",\"4\"] {type:'string'}\n",
"#@markdown ---\n",
"\n",
"#@markdown ####**Coherency Settings:**\n",
@ -2939,8 +2961,12 @@
" batchNum = int(run_to_resume)\n",
" if resume_from_frame == 'latest':\n",
" start_frame = len(glob(batchFolder+f\"/{batch_name}({batchNum})_*.png\"))\n",
" if turbo_mode == True and start_frame > 10 and start_frame % int(turbo_steps) != 0:\n",
" start_frame = start_frame - (start_frame % int(turbo_steps))\n",
" else:\n",
" start_frame = int(resume_from_frame)+1\n",
" if turbo_mode == True and start_frame > 10 and start_frame % int(turbo_steps) != 0:\n",
" start_frame = start_frame - (start_frame % int(turbo_steps))\n",
" if retain_overwritten_frames is True:\n",
" existing_frames = len(glob(batchFolder+f\"/{batch_name}({batchNum})_*.png\"))\n",
" frames_to_save = existing_frames - start_frame\n",

@ -1017,6 +1017,18 @@ def do_run():
args.fov, padding_mode=args.padding_mode,
sampling_mode=args.sampling_mode, midas_weight=args.midas_weight)
next_step_pil.save('prevFrameScaled.png')
### Turbo mode - skip some diffusions to save time
if turbo_mode == True and frame_num > 10 and frame_num % int(turbo_steps) != 0:
print('turbo mode is on this frame: skipping clip diffusion steps')
filename = f'{args.batch_name}({args.batchNum})_{frame_num:04}.png'
next_step_pil.save(f'{batchFolder}/{filename}') #save it as this frame
next_step_pil.save(f'{img_filepath}') # save it also as prev_frame for next iteration
continue
elif turbo_mode == True:
print('turbo mode is OFF this frame')
#else: no turbo
init_image = 'prevFrameScaled.png'
init_scale = args.frames_scale
skip_steps = args.calc_frames_skip_steps
@ -1367,6 +1379,8 @@ def save_settings():
'sampling_mode': sampling_mode,
'video_init_path':video_init_path,
'extract_nth_frame':extract_nth_frame,
'turbo_mode':turbo_mode,
'turbo_steps':turbo_steps,
}
# print('Settings:', setting_list)
with open(f"{batchFolder}/{batch_name}({batchNum})_settings.txt", "w+") as f: #save settings
@ -2360,6 +2374,14 @@ fov = 40#@param {type:"number"}
padding_mode = 'border'#@param {type:"string"}
sampling_mode = 'bicubic'#@param {type:"string"}
#======= TURBO MODE
#@markdown ---
#@markdown ####**Turbo Mode (3D anim only):**
#@markdown (Starts after frame 10,) skips diffusion steps and just uses MIDAS depth map to warp images for skipped frames.
#@markdown Speeds up rendering by 2x-4x, and may improve image coherence between frames.
turbo_mode = True #@param {type:"boolean"}
turbo_steps = "3" #@param ["2","3","4"] {type:'string'}
#@markdown ---
#@markdown ####**Coherency Settings:**
@ -2762,8 +2784,12 @@ if resume_run:
batchNum = int(run_to_resume)
if resume_from_frame == 'latest':
start_frame = len(glob(batchFolder+f"/{batch_name}({batchNum})_*.png"))
if turbo_mode == True and start_frame > 10 and start_frame % int(turbo_steps) != 0:
start_frame = start_frame - (start_frame % int(turbo_steps))
else:
start_frame = int(resume_from_frame)+1
if turbo_mode == True and start_frame > 10 and start_frame % int(turbo_steps) != 0:
start_frame = start_frame - (start_frame % int(turbo_steps))
if retain_overwritten_frames is True:
existing_frames = len(glob(batchFolder+f"/{batch_name}({batchNum})_*.png"))
frames_to_save = existing_frames - start_frame

Loading…
Cancel
Save