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

Why video is not generated #197

Open
innokria opened this issue Mar 6, 2025 · 1 comment
Open

Why video is not generated #197

innokria opened this issue Mar 6, 2025 · 1 comment

Comments

@innokria
Copy link

innokria commented Mar 6, 2025

``# Install dependencies
!pip install -q modelscope torch huggingface_hub
import os
import subprocess
import torch
from huggingface_hub import snapshot_download
from IPython.display import display, Video
import os
import subprocess
from huggingface_hub import snapshot_download

Define model and directories

MODEL_REPO = "Wan-AI/Wan2.1-T2V-1.3B"
MODEL_DIR = "./Wan2.1-T2V-1.3B"

Ensure model is downloaded

if not os.path.exists(MODEL_DIR):
print("🔄 Downloading WAN 2.1 - 1.3B model from Hugging Face...")
snapshot_download(repo_id=MODEL_REPO, local_dir=MODEL_DIR)
else:
print("✅ Model already exists!")

🔥 Create generate.py dynamically in Kaggle

generate_py_code = """
import argparse
import os
import torch
import time

Argument Parser

parser = argparse.ArgumentParser()
parser.add_argument("--task", type=str, default="t2v-1.3B")
parser.add_argument("--size", type=str, required=True)
parser.add_argument("--ckpt_dir", type=str, required=True)
parser.add_argument("--offload_model", type=str, required=True)
parser.add_argument("--t5_cpu", action='store_true')
parser.add_argument("--sample_shift", type=int, required=True)
parser.add_argument("--sample_guide_scale", type=int, required=True)
parser.add_argument("--prompt", type=str, required=True)
parser.add_argument("--frame_num", type=str, required=True)
parser.add_argument("--sample_steps", type=str, required=True)
args = parser.parse_args()

print(f"🔹 Running model: {args.task}")
print(f"🔹 Size: {args.size}")
print(f"🔹 Model Directory: {args.ckpt_dir}")
print(f"🔹 Offload Model: {args.offload_model}")
print(f"🔹 T5 CPU Mode: {args.t5_cpu}")
print(f"🔹 Sample Shift: {args.sample_shift}")
print(f"🔹 Sample Guide Scale: {args.sample_guide_scale}")
print(f"🔹 Prompt: {args.prompt}")
print(f"🔹 Prompt: {args.frame_num}")

Simulate video generation

"""

Save to generate.py

with open("generate.py", "w") as f:
f.write(generate_py_code)

print("✅ generate.py created successfully!")

Function to generate video

Function to generate video

def generate_video(prompt, size="480*832", sample_shift=8, sample_guide_scale=6, offload_model=True, t5_cpu=True,frame=30,sample_steps=30):
print(f"🔹 Generating video for prompt: {prompt}")

# Properly formatted command as a list
command = [
    "python3", "generate.py",
    "--task", "t2v-1.3B",
    "--size", size,
    "--ckpt_dir", MODEL_DIR,
    "--offload_model", str(offload_model),
    "--t5_cpu",
    "--sample_shift", str(sample_shift),
    "--sample_guide_scale", str(sample_guide_scale),
    "--frame_num", str(frame),
    "--sample_steps", str(sample_steps),
    "--prompt", prompt
]

process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()

print("🔹 Output:", stdout.decode())


if os.path.exists("output.mp4"):
    print("✅ Video generated successfully: output.mp4")
else:
    print("❌ Error: Video file not found!")

Run the video generation

PROMPT = "A walking cat."
target_path = "/kaggle/working/output.mp4"
generate_video(PROMPT)

Display the video if it exists

if os.path.exists(target_path):
display(Video(target_path))
else:
print("❌ Error: Video file not found!")

output

Model already exists!
✅ generate.py created successfully!
🔹 Generating video for prompt: A walking cat.
🔹 Output: 🔹 Running model: t2v-1.3B
🔹 Size: 480*832
🔹 Model Directory: ./Wan2.1-T2V-1.3B
🔹 Offload Model: True
🔹 T5 CPU Mode: True
🔹 Sample Shift: 8
🔹 Sample Guide Scale: 6
🔹 Prompt: A walking cat.
🔹 Prompt: 30

✅ Video generated successfully: output.mp4

But it has no video

@innokria
Copy link
Author

innokria commented Mar 7, 2025

Model already exists!
✅ generate.py created successfully!
🔹 Generating video for prompt: A walking cat.
🔹 Output: b"\xf0\x9f\x94\xb9 Running model: t2v-1.3B\n\xf0\x9f\x94\xb9 Size: 480*832\n\xf0\x9f\x94\xb9 Model Directory: /kaggle/working/Wan2.1-T2V-1.3B\n\xf0\x9f\x94\xb9 Offload Model: True\n\xf0\x9f\x94\xb9 T5 CPU Mode: True\n\xf0\x9f\x94\xb9 Sample Shift: 8\n\xf0\x9f\x94\xb9 Sample Guide Scale: 6\n\xf0\x9f\x94\xb9 Prompt: A walking cat.\n\xf0\x9f\x94\xb9 Frame Num: 30\n\xf0\x9f\x94\xb9 Sample Steps: 30\n\xf0\x9f\x94\xb9 Output: b''\n\xf0\x9f\x94\xba Error: \n\xe2\x9c\x85 Video generated successfully---: output.mp4\n<IPython.core.display.Video object>\n"
🔹 Error: b''
✅ Video generated successfully=====: output.mp4

Still no VDO

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

1 participant