five

hf-internal-testing/spaghetti-video-8-frames

收藏
Hugging Face2022-08-25 更新2024-03-04 收录
下载链接:
https://hf-mirror.com/datasets/hf-internal-testing/spaghetti-video-8-frames
下载链接
链接失效反馈
官方服务:
资源简介:
--- --- This is the code that was used to generate this video: ``` from decord import VideoReader, cpu from huggingface_hub import hf_hub_download import numpy as np np.random.seed(0) def sample_frame_indices(clip_len, frame_sample_rate, seg_len): converted_len = int(clip_len * frame_sample_rate) end_idx = np.random.randint(converted_len, seg_len) start_idx = end_idx - converted_len indices = np.linspace(start_idx, end_idx, num=clip_len) indices = np.clip(indices, start_idx, end_idx - 1).astype(np.int64) return indices file_path = hf_hub_download( repo_id="nielsr/video-demo", filename="eating_spaghetti.mp4", repo_type="dataset" ) vr = VideoReader(file_path, num_threads=1, ctx=cpu(0)) # sample 8 frames vr.seek(0) indices = sample_frame_indices(clip_len=8, frame_sample_rate=1, seg_len=len(vr)) buffer = vr.get_batch(indices).asnumpy() # create a list of NumPy arrays video = [buffer[i] for i in range(buffer.shape[0])] video_numpy = np.array(video) with open('spaghetti_video_8_frames.npy', 'wb') as f: np.save(f, video_numpy) ```
提供机构:
hf-internal-testing
原始信息汇总

数据集概述

数据集内容

  • 数据集包含一个名为 "eating_spaghetti.mp4" 的视频文件。
  • 该视频文件被用于生成一个包含8帧的NumPy数组,存储在 "spaghetti_video_8_frames.npy" 文件中。

数据处理方法

  • 使用 decord 库读取视频文件。
  • 通过 huggingface_hub 库从 "nielsr/video-demo" 仓库下载视频文件。
  • 使用随机种子 0 生成帧索引。
  • 从视频中采样8帧,并将这些帧存储为NumPy数组。

代码示例

python from decord import VideoReader, cpu from huggingface_hub import hf_hub_download import numpy as np

np.random.seed(0)

def sample_frame_indices(clip_len, frame_sample_rate, seg_len): converted_len = int(clip_len * frame_sample_rate) end_idx = np.random.randint(converted_len, seg_len) start_idx = end_idx - converted_len indices = np.linspace(start_idx, end_idx, num=clip_len) indices = np.clip(indices, start_idx, end_idx - 1).astype(np.int64) return indices

file_path = hf_hub_download( repo_id="nielsr/video-demo", filename="eating_spaghetti.mp4", repo_type="dataset" ) vr = VideoReader(file_path, num_threads=1, ctx=cpu(0))

sample 8 frames

vr.seek(0) indices = sample_frame_indices(clip_len=8, frame_sample_rate=1, seg_len=len(vr)) buffer = vr.get_batch(indices).asnumpy()

create a list of NumPy arrays

video = [buffer[i] for i in range(buffer.shape[0])]

video_numpy = np.array(video) with open(spaghetti_video_8_frames.npy, wb) as f: np.save(f, video_numpy)

5,000+
优质数据集
54 个
任务类型
进入经典数据集
二维码
社区交流群

面向社区/商业的数据集话题

二维码
科研交流群

面向高校/科研机构的开源数据集话题

数据驱动未来

携手共赢发展

商业合作