-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from zyj-2000/main
Fix the BUG: Video Quality Scorer -> Python API: Missing the "load_video"
- Loading branch information
Showing
2 changed files
with
15 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .model import MPLUGOwl2LlamaForCausalLM | ||
from .evaluate import QAlignScorer, QAlignAestheticScorer, QAlignVideoScorer | ||
from .evaluate import QAlignScorer, QAlignAestheticScorer, QAlignVideoScorer | ||
from .load_video import load_video |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from PIL import Image | ||
|
||
def load_video(video_file): | ||
from decord import VideoReader | ||
vr = VideoReader(video_file) | ||
|
||
# Get video frame rate | ||
fps = vr.get_avg_fps() | ||
|
||
# Calculate frame indices for 1fps | ||
frame_indices = [int(fps * i) for i in range(int(len(vr) / fps))] | ||
frames = vr.get_batch(frame_indices).asnumpy() | ||
return [Image.fromarray(frames[i]) for i in range(int(len(vr) / fps))] |