我们在这里选用了 MSR-VTT (Microsoft Research Video to Text)[7] 数据集的部分数据(1000个)。MSR-VTT[8] 是一个公开的视频描述数据集,由 10000 个视频片段与对应的文本描述组成。你可以选择从 google drive 或者通过以下代码下载和解压数据,解压后的数据包括了以下几个部分:
sample_num = 1000 # you can change this sample_num to be smaller, so that this notebook will be faster. test_df = pd.read_csv(test_csv_path) print('length of all test set is {}'.format(len(test_df))) sample_df = test_df.sample(sample_num, random_state=42)
from IPython import display from pathlib import Path import towhee from PIL import Image
def display_gif(video_path_list, text_list): html = '' for video_path, text in zip(video_path_list, text_list): html_line = '<img src="{}"> {} <br/>'.format(video_path, text) html += html_line return display.HTML(html)
# For the first time you run this line, # it will take some time # because towhee will download operator with weights on backend. dc = ( towhee.read_csv(test_sample_csv_path).unstream() .runas_op['video_id', 'id'](func=lambda x: int(x[-4:] "'video_id', 'id'")) .video_decode.ffmpeg['video_path', 'frames'](sample_type='uniform_temporal_subsample', args={'num_samples': 12} "'video_path', 'frames'") \ .runas_op['frames', 'frames'](func=lambda x: [y for y in x] "'frames', 'frames'") \ .video_text_embedding.clip4clip['frames', 'vec'](model_name='clip_vit_b32', modality='video', device=device "'frames', 'vec'") \ .to_milvus['id', 'vec'](collection=collection, batch=30 "'id', 'vec'") )
Recall@topk 是在 top k 个结果的“查全率”。比如,共有 5 个目标结果,Recall@top10 为 40% 则表示前十个结果中找到了 2(5*40%)个目标结果。本案例中每次只有一个目标结果,因此 Recall@topk 同时也意味着准确率(Accuracy)。
dc = ( towhee.read_csv(test_sample_csv_path).unstream() .video_text_embedding.clip4clip['sentence','text_vec'](model_name='clip_vit_b32', modality='text', device=device "'sentence','text_vec'") .milvus_search['text_vec', 'top10_raw_res'](collection=collection, limit=10 "'text_vec', 'top10_raw_res'") .runas_op['video_id', 'ground_truth'](func=lambda x : [int(x[-4:] "'video_id', 'ground_truth'")]) .runas_op['top10_raw_res', 'top1'](func=lambda res: [x.id for i, x in enumerate(res "'top10_raw_res', 'top1'") if i < 1]) .runas_op['top10_raw_res', 'top5'](func=lambda res: [x.id for i, x in enumerate(res "'top10_raw_res', 'top5'") if i < 5]) .runas_op['top10_raw_res', 'top10'](func=lambda res: [x.id for i, x in enumerate(res "'top10_raw_res', 'top10'") if i < 10]) )
我们分别返回 top 1 个、top 5 个和 top 10 个预测结果,并查看分别对应的评估结果:
MSR-VTT (Microsoft Research Video to Text): https://www.microsoft.com/en-us/research/publication/msr-vtt-a-large-video-description-dataset-for-bridging-video-and-language/
Zilliz 是向量数据库系统领域的开拓者和全球领先者,研发面向 AI 生产系统的向量数据库系统。Zilliz 以发掘非结构化数据价值为使命,致力于打造面向 AI 应用的新一代数据库技术,帮助企业便捷地开发 AI 应用。Zilliz 的产品能显著降低管理 AI 数据基础设施的成本,帮助 AI 技术赋能更多的企业、组织和个人。
Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。
Sublime Text
Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。