Update README.md
Browse files
README.md
CHANGED
@@ -106,6 +106,24 @@ query = f'<image>\n{text}'
|
|
106 |
# text = 'Describe each image.'
|
107 |
# query = '\n'.join([f'Image {i+1}: <image>' for i in range(len(images))]) + '\n' + text
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
## text-only input
|
110 |
# images = []
|
111 |
# max_partition = None
|
|
|
106 |
# text = 'Describe each image.'
|
107 |
# query = '\n'.join([f'Image {i+1}: <image>' for i in range(len(images))]) + '\n' + text
|
108 |
|
109 |
+
## video input (require `pip install moviepy==1.0.3`)
|
110 |
+
# from moviepy.editor import VideoFileClip
|
111 |
+
# video_path = '/data/videos/example_1.mp4'
|
112 |
+
# num_frames = 12
|
113 |
+
# max_partition = 1
|
114 |
+
# text = 'Describe the video.'
|
115 |
+
# with VideoFileClip(video_path) as clip:
|
116 |
+
# total_frames = int(clip.fps * clip.duration)
|
117 |
+
# if total_frames <= num_frames:
|
118 |
+
# sampled_indices = range(total_frames)
|
119 |
+
# else:
|
120 |
+
# stride = total_frames / num_frames
|
121 |
+
# sampled_indices = [min(total_frames - 1, int((stride * i + stride * (i + 1)) / 2)) for i in range(num_frames)]
|
122 |
+
# frames = [clip.get_frame(index / clip.fps) for index in sampled_indices]
|
123 |
+
# frames = [Image.fromarray(frame, mode='RGB') for frame in frames]
|
124 |
+
# images = frames
|
125 |
+
# query = '\n'.join(['<image>'] * len(images)) + '\n' + text
|
126 |
+
|
127 |
## text-only input
|
128 |
# images = []
|
129 |
# max_partition = None
|