Merge branch 'main' into cross-platofrm

pull/27/head
Adam Letts 3 years ago committed by GitHub
commit f662775b7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      Disco_Diffusion.ipynb
  2. 11
      disco.py

@ -1102,9 +1102,7 @@
" skip_steps = args.calc_frames_skip_steps\n", " skip_steps = args.calc_frames_skip_steps\n",
"\n", "\n",
" if args.animation_mode == \"3D\":\n", " if args.animation_mode == \"3D\":\n",
" if frame_num == 0:\n", " if frame_num > 0:\n",
" pass\n",
" else:\n",
" seed += 1 \n", " seed += 1 \n",
" if resume_run and frame_num == start_frame:\n", " if resume_run and frame_num == start_frame:\n",
" img_filepath = batchFolder+f\"/{batch_name}({batchNum})_{start_frame-1:04}.png\"\n", " img_filepath = batchFolder+f\"/{batch_name}({batchNum})_{start_frame-1:04}.png\"\n",
@ -1409,7 +1407,7 @@
" image.save(f'{batchFolder}/{filename}')\n", " image.save(f'{batchFolder}/{filename}')\n",
" if args.animation_mode == \"3D\":\n", " if args.animation_mode == \"3D\":\n",
" # If turbo, save a blended image\n", " # If turbo, save a blended image\n",
" if turbo_mode:\n", " if turbo_mode and frame_num > 0:\n",
" # Mix new image with prevFrameScaled\n", " # Mix new image with prevFrameScaled\n",
" blend_factor = (1)/int(turbo_steps)\n", " blend_factor = (1)/int(turbo_steps)\n",
" newFrame = cv2.imread('prevFrame.png') # This is already updated..\n", " newFrame = cv2.imread('prevFrame.png') # This is already updated..\n",
@ -1820,15 +1818,14 @@
" 'use_scale_shift_norm': True,\n", " 'use_scale_shift_norm': True,\n",
" })\n", " })\n",
"\n", "\n",
"secondary_model_ver = 2\n",
"model_default = model_config['image_size']\n", "model_default = model_config['image_size']\n",
"\n", "\n",
"\n", "\n",
"\n", "\n",
"if secondary_model_ver == 2:\n", "if use_secondary_model:\n",
" secondary_model = SecondaryDiffusionImageNet2()\n", " secondary_model = SecondaryDiffusionImageNet2()\n",
" secondary_model.load_state_dict(torch.load(f'{model_path}/secondary_model_imagenet_2.pth', map_location='cpu'))\n", " secondary_model.load_state_dict(torch.load(f'{model_path}/secondary_model_imagenet_2.pth', map_location='cpu'))\n",
"secondary_model.eval().requires_grad_(False).to(device)\n", " secondary_model.eval().requires_grad_(False).to(device)\n",
"\n", "\n",
"clip_models = []\n", "clip_models = []\n",
"if ViTB32 is True: clip_models.append(clip.load('ViT-B/32', jit=False)[0].eval().requires_grad_(False).to(device)) \n", "if ViTB32 is True: clip_models.append(clip.load('ViT-B/32', jit=False)[0].eval().requires_grad_(False).to(device)) \n",
@ -2688,4 +2685,4 @@
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 4 "nbformat_minor": 4
} }

@ -1066,9 +1066,7 @@ def do_run():
skip_steps = args.calc_frames_skip_steps skip_steps = args.calc_frames_skip_steps
if args.animation_mode == "3D": if args.animation_mode == "3D":
if frame_num == 0: if frame_num > 0:
pass
else:
seed += 1 seed += 1
if resume_run and frame_num == start_frame: if resume_run and frame_num == start_frame:
img_filepath = batchFolder+f"/{batch_name}({batchNum})_{start_frame-1:04}.png" img_filepath = batchFolder+f"/{batch_name}({batchNum})_{start_frame-1:04}.png"
@ -1373,7 +1371,7 @@ def do_run():
image.save(f'{batchFolder}/{filename}') image.save(f'{batchFolder}/{filename}')
if args.animation_mode == "3D": if args.animation_mode == "3D":
# If turbo, save a blended image # If turbo, save a blended image
if turbo_mode: if turbo_mode and frame_num > 0:
# Mix new image with prevFrameScaled # Mix new image with prevFrameScaled
blend_factor = (1)/int(turbo_steps) blend_factor = (1)/int(turbo_steps)
newFrame = cv2.imread('prevFrame.png') # This is already updated.. newFrame = cv2.imread('prevFrame.png') # This is already updated..
@ -1774,15 +1772,14 @@ elif diffusion_model == '256x256_diffusion_uncond':
'use_scale_shift_norm': True, 'use_scale_shift_norm': True,
}) })
secondary_model_ver = 2
model_default = model_config['image_size'] model_default = model_config['image_size']
if secondary_model_ver == 2: if use_secondary_model:
secondary_model = SecondaryDiffusionImageNet2() secondary_model = SecondaryDiffusionImageNet2()
secondary_model.load_state_dict(torch.load(f'{model_path}/secondary_model_imagenet_2.pth', map_location='cpu')) secondary_model.load_state_dict(torch.load(f'{model_path}/secondary_model_imagenet_2.pth', map_location='cpu'))
secondary_model.eval().requires_grad_(False).to(device) secondary_model.eval().requires_grad_(False).to(device)
clip_models = [] clip_models = []
if ViTB32 is True: clip_models.append(clip.load('ViT-B/32', jit=False)[0].eval().requires_grad_(False).to(device)) if ViTB32 is True: clip_models.append(clip.load('ViT-B/32', jit=False)[0].eval().requires_grad_(False).to(device))

Loading…
Cancel
Save