omerbt / TokenFlow

Official Pytorch Implementation for "TokenFlow: Consistent Diffusion Features for Consistent Video Editing" presenting "TokenFlow" (ICLR 2024)
https://diffusion-tokenflow.github.io
MIT License
1.58k stars 137 forks source link

Fix get_latents_path to run on windows too #10

Open rodjjo opened 1 year ago

rodjjo commented 1 year ago

What

Why

I was getting an error when the function tried to get the number of frames.

Description

Traceback (most recent call last):
  File "C:\Projetos\TokenFlow\run_tokenflow_pnp.py", line 304, in <module>
    run(config)
  File "C:\Projetos\TokenFlow\run_tokenflow_pnp.py", line 283, in run
    editor = TokenFlow(config)
  File "C:\Projetos\TokenFlow\run_tokenflow_pnp.py", line 61, in __init__
    self.latents_path = self.get_latents_path()
  File "C:\Projetos\TokenFlow\run_tokenflow_pnp.py", line 122, in get_latents_path
    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))]
  File "C:\Projetos\TokenFlow\run_tokenflow_pnp.py", line 122, in <listcomp>
    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))]
ValueError: invalid literal for int() with base 10: '2.1\\woman-running\\steps'
argentinox commented 1 year ago

This is the corrected code for Windows OS in "run_tokenflow_pnp.py" instead of n_frames = [int([x for x in latentspath[i].split('/') if 'nframes' in x][0].split('')[1]) for i in range(len(latents_path))] write this: nframes = [int(os.path.basename(x).split('')[1]) for x in latents_path if 'nframes' in x]

rodjjo commented 1 year ago

This is the corrected code for Windows OS in "run_tokenflow_pnp.py" instead of n_frames = [int([x for x in latentspath[i].split('/') if 'nframes' in x][0].split('')[1]) for i in range(len(latents_path))] write this: nframes = [int(os.path.basename(x).split('')[1]) for x in latents_path if 'nframes' in x]

Thanks, That works. I guess I can remove regular expressions to make it simple.

nikopueringer commented 1 year ago

still receiving an error in the new code.

Traceback (most recent call last): File "D:\TokenFlow\run_tokenflow_pnp.py", line 302, in run(config) File "D:\TokenFlow\run_tokenflow_pnp.py", line 281, in run editor = TokenFlow(config) File "D:\TokenFlow\run_tokenflow_pnp.py", line 60, in init self.latents_path = self.get_latents_path() File "D:\TokenFlow\run_tokenflow_pnp.py", line 119, in get_latents_path n_frames = [int(os.path.basename(x).split('')[1]) for x in latents_path if 'nframes' in x] File "D:\TokenFlow\run_tokenflow_pnp.py", line 119, in n_frames = [int(os.path.basename(x).split('')[1]) for x in latents_path if 'nframes' in x] ValueError: empty separator

rodjjo commented 1 year ago

ValueError: empty separator

Try again, I changed argentinox suggestion a little bit.