Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation issue on Windows - decord #6

Open
anwoflow opened this issue Apr 2, 2023 · 2 comments
Open

Installation issue on Windows - decord #6

anwoflow opened this issue Apr 2, 2023 · 2 comments

Comments

@anwoflow
Copy link

anwoflow commented Apr 2, 2023

I see the extension in the Extension tab, but it isn't loading.
The only error I see during the launch of webui is one related to decord.

File "\stable-diffusion-webui\extensions\Text2Video-Zero-sd-webui\scripts\main.py", line 5, in
from model import Model, ModelType
File "
\stable-diffusion-webui\extensions\Text2Video-Zero-sd-webui\model.py", line 6, in
import decord
ModuleNotFoundError: No module named 'decord'

the only line referencing decord was commented out, so I also commented out the import decordpart.
in model.py, but it is also used in utils.py
could be replaced with opencv

Here's the updated function

def prepare_video(video_path:str, resolution:int, device, dtype, normalize=True, start_t:float=0, end_t:float=-1, output_fps:int=-1):
    vr = cv2.VideoCapture(video_path)
    initial_fps = vr.get(cv2.CAP_PROP_FPS)
    if output_fps == -1:
        output_fps = int(initial_fps)
    if end_t == -1:
        end_t = vr.get(cv2.CAP_PROP_FRAME_COUNT) / initial_fps
    else:
        end_t = min(vr.get(cv2.CAP_PROP_FRAME_COUNT) / initial_fps, end_t)
    assert 0 <= start_t < end_t
    assert output_fps > 0
    start_f_ind = int(start_t * initial_fps)
    end_f_ind = int(end_t * initial_fps)
    num_f = int((end_t - start_t) * output_fps)
    sample_idx = np.linspace(start_f_ind, end_f_ind, num_f, endpoint=False).astype(int)
    video = []
    for idx in sample_idx:
        vr.set(cv2.CAP_PROP_POS_FRAMES, idx)
        ret, frame = vr.read()
        if not ret:
            break
        video.append(frame)
    video = np.stack(video)
    video = rearrange(video, "f h w c -> f c h w")
    video = torch.Tensor(video).to(device).to(dtype)
    h, w, _ = video.shape[1:] + (3,)
    if h > w:
        w = int(w * resolution / h)
        w = w - w % 8
        h = resolution - resolution % 8
    else:
        h = int(h * resolution / w)
        h = h - h % 8
        w = resolution - resolution % 8
    video = Resize((h, w), interpolation=InterpolationMode.BILINEAR, antialias=True)(video)
    if normalize:
        video = video / 127.5 - 1.0
    return video, output_fps

After that change the extension shows up in WebUI

@jackylee1
Copy link

i still can not see the tab after trying many times,so tired

@ericlormul
Copy link
Collaborator

installation dependencies have been updated. Let me know if it works on your side. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants