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

Update code and requirements to support Moviepy v2 #652

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inference/gradio_composite_demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pip install -r requirements.txt
## Running the code

```bash
python gradio_web_demo.py
python app.py
```


8 changes: 4 additions & 4 deletions inference/gradio_composite_demo/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from diffusers.image_processor import VaeImageProcessor
from openai import OpenAI
import moviepy.editor as mp
from moviepy import VideoFileClip
import utils
from rife_model import load_rife_model, rife_inference_with_latents
from huggingface_hub import hf_hub_download, snapshot_download
Expand Down Expand Up @@ -271,9 +271,9 @@ def infer(


def convert_to_gif(video_path):
clip = mp.VideoFileClip(video_path)
clip = clip.set_fps(8)
clip = clip.resize(height=240)
clip = VideoFileClip(video_path)
clip = clip.with_fps(8)
clip = clip.resized(height=240)
gif_path = video_path.replace(".mp4", ".gif")
clip.write_gif(gif_path, fps=8)
return gif_path
Expand Down
2 changes: 1 addition & 1 deletion inference/gradio_composite_demo/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ gradio>=5.4.0
imageio>=2.34.2
imageio-ffmpeg>=0.5.1
openai>=1.45.0
moviepy>=1.0.3
moviepy>=2.0.0
pillow==9.5.0
8 changes: 4 additions & 4 deletions inference/gradio_web_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from diffusers.utils import export_to_video
from datetime import datetime, timedelta
from openai import OpenAI
import moviepy.editor as mp
from moviepy import VideoFileClip

pipe = CogVideoXPipeline.from_pretrained("THUDM/CogVideoX-5b", torch_dtype=torch.bfloat16).to("cuda")

Expand Down Expand Up @@ -117,9 +117,9 @@ def save_video(tensor):


def convert_to_gif(video_path):
clip = mp.VideoFileClip(video_path)
clip = clip.set_fps(8)
clip = clip.resize(height=240)
clip = VideoFileClip(video_path)
clip = clip.with_fps(8)
clip = clip.resized(height=240)
gif_path = video_path.replace(".mp4", ".gif")
clip.write_gif(gif_path, fps=8)
return gif_path
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ gradio>=5.5.0
imageio>=2.35.1
imageio-ffmpeg>=0.5.1
openai>=1.54.0
moviepy>=1.0.3
moviepy>=2.0.0
scikit-video>=1.1.11
pydantic>=2.10.3
pydantic>=2.10.3
8 changes: 4 additions & 4 deletions tools/llm_flux_cogvideox/gradio_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from datetime import datetime, timedelta
import threading
import time
import moviepy.editor as mp
from moviepy import VideoFileClip

torch.set_float32_matmul_precision("high")

Expand Down Expand Up @@ -140,9 +140,9 @@ def save_video(tensor):


def convert_to_gif(video_path):
clip = mp.VideoFileClip(video_path)
clip = clip.set_fps(8)
clip = clip.resize(height=240)
clip = VideoFileClip(video_path)
clip = clip.with_fps(8)
clip = clip.resized(height=240)
gif_path = video_path.replace(".mp4", ".gif")
clip.write_gif(gif_path, fps=8)
return gif_path
Expand Down
2 changes: 1 addition & 1 deletion tools/replicate/cog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ build:
- imageio>=2.35.1
- imageio-ffmpeg>=0.5.1
- openai>=1.45.0
- moviepy>=1.0.3
- moviepy>=2.0.0
- pillow==9.5.0
- pydantic==1.10.7
run:
Expand Down