|
|
|
@ -478,52 +478,49 @@ |
|
|
|
|
"try:\n", |
|
|
|
|
" from CLIP import clip\n", |
|
|
|
|
"except:\n", |
|
|
|
|
" if os.path.exists(\"CLIP\") is not True:\n", |
|
|
|
|
" if not os.path.exists(\"CLIP\"):\n", |
|
|
|
|
" gitclone(\"https://github.com/openai/CLIP\")\n", |
|
|
|
|
" sys.path.append(f'{PROJECT_DIR}/CLIP')\n", |
|
|
|
|
"\n", |
|
|
|
|
"try:\n", |
|
|
|
|
" from guided_diffusion.script_util import create_model_and_diffusion\n", |
|
|
|
|
"except:\n", |
|
|
|
|
" if os.path.exists(\"guided-diffusion\") is not True:\n", |
|
|
|
|
" if not os.path.exists(\"guided-diffusion\"):\n", |
|
|
|
|
" gitclone(\"https://github.com/crowsonkb/guided-diffusion\")\n", |
|
|
|
|
" sys.path.append(f'{PROJECT_DIR}/guided-diffusion')\n", |
|
|
|
|
"\n", |
|
|
|
|
"try:\n", |
|
|
|
|
" from resize_right import resize\n", |
|
|
|
|
"except:\n", |
|
|
|
|
" if os.path.exists(\"resize_right\") is not True:\n", |
|
|
|
|
" if not os.path.exists(\"ResizeRight\"):\n", |
|
|
|
|
" gitclone(\"https://github.com/assafshocher/ResizeRight.git\")\n", |
|
|
|
|
" sys.path.append(f'{PROJECT_DIR}/ResizeRight')\n", |
|
|
|
|
"\n", |
|
|
|
|
"try:\n", |
|
|
|
|
" import py3d_tools\n", |
|
|
|
|
"except:\n", |
|
|
|
|
" if os.path.exists('pytorch3d-lite') is not True:\n", |
|
|
|
|
" if not os.path.exists('pytorch3d-lite'):\n", |
|
|
|
|
" gitclone(\"https://github.com/MSFTserver/pytorch3d-lite.git\")\n", |
|
|
|
|
" sys.path.append(f'{PROJECT_DIR}/pytorch3d-lite')\n", |
|
|
|
|
"\n", |
|
|
|
|
"try:\n", |
|
|
|
|
" from midas.dpt_depth import DPTDepthModel\n", |
|
|
|
|
"except:\n", |
|
|
|
|
" if os.path.exists('MiDaS') is not True:\n", |
|
|
|
|
" if not os.path.exists('MiDaS'):\n", |
|
|
|
|
" gitclone(\"https://github.com/isl-org/MiDaS.git\")\n", |
|
|
|
|
" if os.path.exists('MiDaS/midas_utils.py') is not True:\n", |
|
|
|
|
" if not os.path.exists('MiDaS/midas_utils.py'):\n", |
|
|
|
|
" shutil.move('MiDaS/utils.py', 'MiDaS/midas_utils.py')\n", |
|
|
|
|
" if not os.path.exists(f'{model_path}/dpt_large-midas-2f21e586.pt'):\n", |
|
|
|
|
" wget(\"https://github.com/intel-isl/DPT/releases/download/1_0/dpt_large-midas-2f21e586.pt\", model_path)\n", |
|
|
|
|
" sys.path.append(f'{PROJECT_DIR}/MiDaS')\n", |
|
|
|
|
"\n", |
|
|
|
|
"try:\n", |
|
|
|
|
" sys.path.append(PROJECT_DIR)\n", |
|
|
|
|
" sys.path.append(f'{PROJECT_DIR}/disco-diffusion')\n", |
|
|
|
|
" import disco_xform_utils as dxf\n", |
|
|
|
|
"except:\n", |
|
|
|
|
" if os.path.exists(\"disco-diffusion\") is not True:\n", |
|
|
|
|
" if not os.path.exists(\"disco-diffusion\"):\n", |
|
|
|
|
" gitclone(\"https://github.com/alembics/disco-diffusion.git\")\n", |
|
|
|
|
" # Rename a file to avoid a name conflict..\n", |
|
|
|
|
" if os.path.exists('disco_xform_utils.py') is not True:\n", |
|
|
|
|
" shutil.move('disco-diffusion/disco_xform_utils.py', 'disco_xform_utils.py')\n", |
|
|
|
|
" sys.path.append(PROJECT_DIR)\n", |
|
|
|
|
" sys.path.append(f'{PROJECT_DIR}/disco-diffusion')\n", |
|
|
|
|
"\n", |
|
|
|
|
"import torch\n", |
|
|
|
|
"from dataclasses import dataclass\n", |
|
|
|
@ -1672,7 +1669,7 @@ |
|
|
|
|
" alphas, sigmas = map(partial(append_dims, n=v.ndim), t_to_alpha_sigma(t))\n", |
|
|
|
|
" pred = input * alphas - v * sigmas\n", |
|
|
|
|
" eps = input * sigmas + v * alphas\n", |
|
|
|
|
" return DiffusionOutput(v, pred, eps)" |
|
|
|
|
" return DiffusionOutput(v, pred, eps)\n" |
|
|
|
|
], |
|
|
|
|
"outputs": [], |
|
|
|
|
"execution_count": null |
|
|
|
@ -1895,7 +1892,7 @@ |
|
|
|
|
"\n", |
|
|
|
|
"#Make folder for batch\n", |
|
|
|
|
"batchFolder = f'{outDirPath}/{batch_name}'\n", |
|
|
|
|
"createPath(batchFolder)" |
|
|
|
|
"createPath(batchFolder)\n" |
|
|
|
|
], |
|
|
|
|
"outputs": [], |
|
|
|
|
"execution_count": null |
|
|
|
@ -1942,7 +1939,7 @@ |
|
|
|
|
" f.unlink()\n", |
|
|
|
|
" except:\n", |
|
|
|
|
" print('')\n", |
|
|
|
|
" vf = f'\"select=not(mod(n\\,{extract_nth_frame}))\"'\n", |
|
|
|
|
" vf = f'select=not(mod(n\\,{extract_nth_frame}))'\n", |
|
|
|
|
" subprocess.run(['ffmpeg', '-i', f'{video_init_path}', '-vf', f'{vf}', '-vsync', 'vfr', '-q:v', '2', '-loglevel', 'error', '-stats', f'{videoFramesFolder}/%04d.jpg'], stdout=subprocess.PIPE).stdout.decode('utf-8')\n", |
|
|
|
|
" #!ffmpeg -i {video_init_path} -vf {vf} -vsync vfr -q:v 2 -loglevel error -stats {videoFramesFolder}/%04d.jpg\n", |
|
|
|
|
"\n", |
|
|
|
|