Skip to content

Commit

Permalink
Merge pull request #17 from zyj-2000/main
Browse files Browse the repository at this point in the history
Fix the BUG: Video Quality Scorer -> Python API: Missing the "load_video"
  • Loading branch information
teowu authored Apr 5, 2024
2 parents 3e134a1 + 5e1a80e commit d9c382d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion q_align/__init__.py
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
13 changes: 13 additions & 0 deletions q_align/load_video.py
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))]

0 comments on commit d9c382d

Please sign in to comment.