mirror of
https://github.com/hzwer/Practical-RIFE.git
synced 2026-11-29 20:25:40 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6913ad3691
|
@@ -43,6 +43,10 @@ cd Practical-RIFE
|
|||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
```
|
```
|
||||||
Download a model from the model list and put *.py and flownet.pkl on train_log/
|
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
|
### Run
|
||||||
|
|
||||||
You can use our [demo video](https://drive.google.com/file/d/1i3xlKb7ax7Y70khcTcuePi6E7crO_dFc/view?usp=sharing) or your video.
|
You can use our [demo video](https://drive.google.com/file/d/1i3xlKb7ax7Y70khcTcuePi6E7crO_dFc/view?usp=sharing) or your video.
|
||||||
|
|||||||
+10
-3
@@ -7,15 +7,22 @@ from tqdm import tqdm
|
|||||||
from torch.nn import functional as F
|
from torch.nn import functional as F
|
||||||
import warnings
|
import warnings
|
||||||
import _thread
|
import _thread
|
||||||
import skvideo.io
|
|
||||||
from queue import Queue, Empty
|
from queue import Queue, Empty
|
||||||
from model.pytorch_msssim import ssim_matlab
|
from model.pytorch_msssim import ssim_matlab
|
||||||
|
|
||||||
warnings.filterwarnings("ignore")
|
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):
|
def transferAudio(sourceVideo, targetVideo):
|
||||||
import shutil
|
import shutil
|
||||||
import moviepy.editor
|
|
||||||
tempAudioFileName = "./temp/audio.mkv"
|
tempAudioFileName = "./temp/audio.mkv"
|
||||||
|
|
||||||
# split audio from original video file and store in "temp" directory
|
# 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
|
args.fps = fps * args.multi
|
||||||
else:
|
else:
|
||||||
fpsNotAssigned = False
|
fpsNotAssigned = False
|
||||||
videogen = skvideo.io.vreader(args.video)
|
videogen = video_frames(args.video)
|
||||||
lastframe = next(videogen)
|
lastframe = next(videogen)
|
||||||
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
|
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
|
||||||
video_path_wo_ext, ext = os.path.splitext(args.video)
|
video_path_wo_ext, ext = os.path.splitext(args.video)
|
||||||
|
|||||||
@@ -7,15 +7,22 @@ from tqdm import tqdm
|
|||||||
from torch.nn import functional as F
|
from torch.nn import functional as F
|
||||||
import warnings
|
import warnings
|
||||||
import _thread
|
import _thread
|
||||||
import skvideo.io
|
|
||||||
from queue import Queue, Empty
|
from queue import Queue, Empty
|
||||||
from model.pytorch_msssim import ssim_matlab
|
from model.pytorch_msssim import ssim_matlab
|
||||||
|
|
||||||
warnings.filterwarnings("ignore")
|
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):
|
def transferAudio(sourceVideo, targetVideo):
|
||||||
import shutil
|
import shutil
|
||||||
import moviepy.editor
|
|
||||||
tempAudioFileName = "./temp/audio.mkv"
|
tempAudioFileName = "./temp/audio.mkv"
|
||||||
|
|
||||||
# split audio from original video file and store in "temp" directory
|
# 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)
|
tot_frame = videoCapture.get(cv2.CAP_PROP_FRAME_COUNT)
|
||||||
videoCapture.release()
|
videoCapture.release()
|
||||||
fpsNotAssigned = True
|
fpsNotAssigned = True
|
||||||
videogen = skvideo.io.vreader(args.video)
|
videogen = video_frames(args.video)
|
||||||
lastframe = next(videogen)
|
lastframe = next(videogen)
|
||||||
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
|
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
|
||||||
video_path_wo_ext, ext = os.path.splitext(args.video)
|
video_path_wo_ext, ext = os.path.splitext(args.video)
|
||||||
|
|||||||
+2
-3
@@ -1,7 +1,6 @@
|
|||||||
numpy>=1.16, <=1.23.5
|
numpy>=1.16
|
||||||
|
pillow>=13.0.0
|
||||||
tqdm>=4.35.0
|
tqdm>=4.35.0
|
||||||
sk-video>=1.1.10
|
|
||||||
torch>=1.3.0
|
torch>=1.3.0
|
||||||
opencv-python>=4.1.2
|
opencv-python>=4.1.2
|
||||||
moviepy>=1.0.3
|
|
||||||
torchvision>=0.7.0
|
torchvision>=0.7.0
|
||||||
|
|||||||
Reference in New Issue
Block a user