From 6913ad3691ef54841ac5e3324b7812853143e76d Mon Sep 17 00:00:00 2001 From: Xiao Xiong Date: Sun, 29 Nov 2026 17:45:31 -0500 Subject: [PATCH] remove workaround and add actual (maybe working) solution --- README.md | 4 ++++ inference_video.py | 13 ++++++++++--- inference_video_enhance.py | 13 ++++++++++--- requirements.txt | 5 ++--- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2a69748..a85e326 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,10 @@ cd Practical-RIFE pip3 install -r requirements.txt ``` Download a model from the model list and put *.py and flownet.pkl on train_log/ + +### Video frame reading +Video frames are read with OpenCV (`cv2.VideoCapture`) instead of `skvideo`, and audio is handled with `ffmpeg` directly instead of `moviepy`. Both packages are no longer required, so the old numpy incompatibility (`module 'numpy' has no attribute 'float'`) no longer applies and a newer numpy can be used freely. + ### Run You can use our [demo video](https://drive.google.com/file/d/1i3xlKb7ax7Y70khcTcuePi6E7crO_dFc/view?usp=sharing) or your video. diff --git a/inference_video.py b/inference_video.py index 1069fc1..fb74773 100644 --- a/inference_video.py +++ b/inference_video.py @@ -7,15 +7,22 @@ from tqdm import tqdm from torch.nn import functional as F import warnings import _thread -import skvideo.io from queue import Queue, Empty from model.pytorch_msssim import ssim_matlab warnings.filterwarnings("ignore") +def video_frames(video_path): + videoCapture = cv2.VideoCapture(video_path) + while True: + ret, frame = videoCapture.read() + if not ret: + break + yield frame + videoCapture.release() + def transferAudio(sourceVideo, targetVideo): import shutil - import moviepy.editor tempAudioFileName = "./temp/audio.mkv" # split audio from original video file and store in "temp" directory @@ -108,7 +115,7 @@ if not args.video is None: args.fps = fps * args.multi else: fpsNotAssigned = False - videogen = skvideo.io.vreader(args.video) + videogen = video_frames(args.video) lastframe = next(videogen) fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v') video_path_wo_ext, ext = os.path.splitext(args.video) diff --git a/inference_video_enhance.py b/inference_video_enhance.py index d3076cd..cf56794 100644 --- a/inference_video_enhance.py +++ b/inference_video_enhance.py @@ -7,15 +7,22 @@ from tqdm import tqdm from torch.nn import functional as F import warnings import _thread -import skvideo.io from queue import Queue, Empty from model.pytorch_msssim import ssim_matlab warnings.filterwarnings("ignore") +def video_frames(video_path): + videoCapture = cv2.VideoCapture(video_path) + while True: + ret, frame = videoCapture.read() + if not ret: + break + yield frame + videoCapture.release() + def transferAudio(sourceVideo, targetVideo): import shutil - import moviepy.editor tempAudioFileName = "./temp/audio.mkv" # split audio from original video file and store in "temp" directory @@ -92,7 +99,7 @@ if not args.video is None: tot_frame = videoCapture.get(cv2.CAP_PROP_FRAME_COUNT) videoCapture.release() fpsNotAssigned = True - videogen = skvideo.io.vreader(args.video) + videogen = video_frames(args.video) lastframe = next(videogen) fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v') video_path_wo_ext, ext = os.path.splitext(args.video) diff --git a/requirements.txt b/requirements.txt index f405577..d3920b6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ -numpy>=1.16, <=1.23.5 +numpy>=1.16 +pillow>=13.0.0 tqdm>=4.35.0 -sk-video>=1.1.10 torch>=1.3.0 opencv-python>=4.1.2 -moviepy>=1.0.3 torchvision>=0.7.0