From 4d8d8e250099f6ed45aed3e157909fe8ee28ec3c Mon Sep 17 00:00:00 2001 From: rodrigo araujo Date: Mon, 4 Sep 2023 20:56:44 -0300 Subject: [PATCH 1/4] Fix get_latents_path function frame counter --- run_tokenflow_pnp.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/run_tokenflow_pnp.py b/run_tokenflow_pnp.py index 037d4dc..4b9ace4 100644 --- a/run_tokenflow_pnp.py +++ b/run_tokenflow_pnp.py @@ -1,5 +1,6 @@ import glob import os +import re import numpy as np import cv2 from pathlib import Path @@ -115,7 +116,10 @@ def get_latents_path(self): latents_path = os.path.join(config["latents_path"], f'sd_{config["sd_version"]}', Path(config["data_path"]).stem, f'steps_{config["n_inversion_steps"]}') latents_path = [x for x in glob.glob(f'{latents_path}/*') if '.' not in Path(x).name] - n_frames = [int([x for x in latents_path[i].split('/') if 'nframes' in x][0].split('_')[1]) for i in range(len(latents_path))] + + pattern = re.compile(".*nframes_([0-9]+)") + n_frames = [int(g[1]) for g in [pattern.match(latents_path[i]) for i in range(len(latents_path))] if g] + latents_path = latents_path[np.argmax(n_frames)] self.config["n_frames"] = min(max(n_frames), config["n_frames"]) if self.config["n_frames"] % self.config["batch_size"] != 0: From cfcd844fe674bd1433eef5c0c5dda41550aaf00f Mon Sep 17 00:00:00 2001 From: rodrigo araujo Date: Mon, 4 Sep 2023 21:23:53 -0300 Subject: [PATCH 2/4] Add requirements and instructions to run on windows --- .gitignore | 8 ++++++++ README.md | 12 ++++++++++++ requirements-torch.txt | 2 ++ requirements.txt | 3 +++ 4 files changed, 25 insertions(+) create mode 100644 requirements-torch.txt diff --git a/.gitignore b/.gitignore index e43b0f9..27cd6cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,9 @@ .DS_Store +tokenflow-results*/** +venv/ +__pycache__/ +*.pyc +latents/ +data/** +!data/wolf.mp4 +!data/woman-running.mp4 \ No newline at end of file diff --git a/README.md b/README.md index 32359b1..c483235 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,23 @@ For more see the [project webpage](https://diffusion-tokenflow.github.io). ## Environment + +Using conda ``` conda create -n tokenflow python=3.9 conda activate tokenflow pip install -r requirements.txt ``` + +Using cpython Windows (powershell) +```powershell +python -m pip install virtualenv +python -m virtualenv venv +venv/Scripts/activate.ps1 +pip install -r requirements.txt +pip install -r requirements-torch.txt +``` + ## Preprocess Preprocess you video by running using the following command: diff --git a/requirements-torch.txt b/requirements-torch.txt new file mode 100644 index 0000000..2a87eef --- /dev/null +++ b/requirements-torch.txt @@ -0,0 +1,2 @@ +-i https://download.pytorch.org/whl/cu117 +torch==2.0.1+cu117 diff --git a/requirements.txt b/requirements.txt index 3be27ca..601e410 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,3 +9,6 @@ pyyaml accelerate xformers tensorboard +kornia +av + From 383808d35a0bca7667e9287286c6b57138df63ae Mon Sep 17 00:00:00 2001 From: rodrigo araujo Date: Tue, 5 Sep 2023 08:25:16 -0300 Subject: [PATCH 3/4] Add torchvision to requirements-torch.txt --- requirements-torch.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-torch.txt b/requirements-torch.txt index 2a87eef..224e56c 100644 --- a/requirements-torch.txt +++ b/requirements-torch.txt @@ -1,2 +1,3 @@ -i https://download.pytorch.org/whl/cu117 torch==2.0.1+cu117 +torchvision==0.15.2+cu117 \ No newline at end of file From 54a08a2152813e9c928c5f4790f99083f660c6f0 Mon Sep 17 00:00:00 2001 From: rodrigo araujo Date: Thu, 7 Sep 2023 11:27:51 -0300 Subject: [PATCH 4/4] Simplify frame counter in run_tokenflow_pnp --- run_tokenflow_pnp.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/run_tokenflow_pnp.py b/run_tokenflow_pnp.py index 4b9ace4..6c83010 100644 --- a/run_tokenflow_pnp.py +++ b/run_tokenflow_pnp.py @@ -1,6 +1,5 @@ import glob import os -import re import numpy as np import cv2 from pathlib import Path @@ -117,8 +116,7 @@ def get_latents_path(self): Path(config["data_path"]).stem, f'steps_{config["n_inversion_steps"]}') latents_path = [x for x in glob.glob(f'{latents_path}/*') if '.' not in Path(x).name] - pattern = re.compile(".*nframes_([0-9]+)") - n_frames = [int(g[1]) for g in [pattern.match(latents_path[i]) for i in range(len(latents_path))] if g] + n_frames = [int(os.path.basename(x).split('_')[1]) for x in latents_path if 'nframes_' in x] latents_path = latents_path[np.argmax(n_frames)] self.config["n_frames"] = min(max(n_frames), config["n_frames"])