专栏名称: GitHubStore
分享有意思的开源项目
目录
相关文章推荐
DeepTech深科技  ·  AI仅用两天攻克超级细菌“十年难题”,内含六 ... ·  3 天前  
爱范儿  ·  OPPO Find N5 ... ·  4 天前  
51好读  ›  专栏  ›  GitHubStore

视频内容智能检测VideoAI

GitHubStore  · 公众号  ·  · 2024-09-09 08:37

正文

项目简介

这个小型工具库的初次发布允许您提出在处理视频内容时最常见的问题——视频中是否包含您关心的内容

现在,你可以让 AI 与你一起观看,并使用简单的英语句子自动截取关键时刻的屏幕截图,就像它是你的朋友一样解释你想要的内容

即使更好,这一切都在客户端的网络浏览器中工作,因为我正在使用#WebAI 运行 AI 模型,这意味着一旦网页下载完成,这可以完全离线工作 - 保护您的隐私,并且无需支付昂贵的 API 费用!

此外,由于您正在处理从未上传到云服务器的本地文件,这意味着您甚至可以在硬盘上观看那 100G

你怎么使用它?

由于这是我一天内制作的,所以它不是一个完美的界面,我的重点只是让最小可行产品(MVP)运行起来,因此我欢迎反馈,并且很可能会在未来改进这个产品。不过目前,它非常简单:

在您的 HTML 文件中使用模块脚本包含:

<script type="module" src="YOUR/PATH/TO/doesVideoContain.js">script>

然后在你的 JavaScript(也设置为模块)中:

// Import this library - host the doesVideoContain.js file from this repo// on your own server on the same domain (or enable CORS headers if not)import {doesVideoContain} from "https://YOUR_PATH_TO/doesVideoContain.js";

/** * Now define 4 key DOM element IDs from your HTML it needs to work with: **/
// ID of an input box element that user will type what to search for.const SEARCH_BOX = 'searchbox';
// ID of an input file picker element that user will use to select a video.const UPLOADER = 'videoUpload';
// ID of a HTML element that this library will render the video into (e.g a DIV container).const VIDEO_CONTAINER_ELEMENT = 'videoRenderer';
// ID of a HTML element where found results will be rendered to (e.g. a DIV container element).const RESULTS_RENDER_ELEMENT = 'output';

// Advanced configuration object (optional):const CONFIG = { task: '', // Select one of . videoMuted: false, // Mute video boolean. videoDisableAutoplay: false, // Disable autoplay boolean. debugLogs: true, // Log debug messages. minSimilarity: 0.35 // Minimum cosine similarity for screenshot to be captured.};

// Alright, now just initialize the library and once loaded, // tell your user to select a video and it will automatically start capturing screenshots for matches.doesVideoContain.init(SEARCH_BOX, UPLOADER, VIDEO_CONTAINER_ELEMENT, RESULTS_RENDER_ELEMENT, CONFIG, loaded);
// An example callback function to know when the library is loaded and ready to do work.function loaded() { // This is where you can now do things and write your custom code.}


这怎么可能?

这得益于令人惊叹的 Web AI 生态系统,它将许多流行的 AI 模型带到了网络浏览器。我计划在未来利用更广泛的生态系统来进一步提升这一功能,但最初版本之所以可能,得益于 Transformers.js 和 ONNX Runtime Web 的结合,以及我自己的定制逻辑,用于从 AI 模型生成的嵌入中执行余弦相似性计算,并与各种 DOM 处理/渲染相结合。


项目链接







请到「今天看啥」查看全文