@ 沙漠- ant- labs/ 眼睛
在浏览器和节点运行的JavaScript的在线解析相片:查找并过滤您想要的照片. 一个呼叫标签上贴有照片内容(屏幕拍摄,接收,自拍),照片内容(狗,海滩,558场景),照片是怎样出来的(浆,眼睛闭着),照片中是谁(团体拍摄,肖像),照片是否敏感. 每个标签都有自信,其中0.5是推荐的截取,0.9是严格截取. 图像留在本地.
两条共用一条 Eye API : (英语)
@desert-ant-labs/eye(默认):一个WebAssembly输油管 LitteRT.js (法语) 推论: 浏览器:当浏览器拥有GPU时,通过WebGPU在GPU上,否则在CPU上. 在服务器侧渲染过程中安全导入;Eye.load()只在浏览器或 Web Worker 中运行推论.@desert-ant-labs/eye/native: 预建的本地核心, macOS上的核心ML和Linux上的LiteRT, for 服务器侧推论 在节点。 从服务器代码导入它 .
npm i @desert-ant-labs/eye @litertjs/core # browser
npm i @desert-ant-labs/eye # Node, prebuilt native core
import { Eye, Tag } from "@desert-ant-labs/eye";
const eye = await Eye.load();
const photo = await eye.analyze(image);
if (photo.has(Tag.dog) && !photo.has(Tag.blurry)) keep(photo);
photo.tags(); // ["photo", "beach", "people", "smiling", ...]
photo.has(Tag.sensitive, "strict");
photo.bestCrop(1); // a square thumbnail
const groups = Eye.duplicates(library, { dates }); // near-duplicates, best first
eye.dispose();
JSON.stringify(photo) 存储分析 Analysis.fromJSON 恢复了它,所以一个库可以在以后没有模型的情况下被过滤. options.parts 选择要计算的内容( e)"photo", (中文(简体) ), "layout", (中文(简体) ), "faces", (中文(简体) ), "sharpness"; 全部默认); 需要留出部分的标记缺失。 在浏览器中, image 任何东西 createImageBitmap 接受或接受一个 ImageData在节点中,通过解码像素为 { data, width, height } 有 RGB 或 RGBA 字节, 向上:
import sharp from "sharp";
import { Eye } from "@desert-ant-labs/eye/native";
const { data, info } = await sharp("photo.jpg").rotate().raw().toBuffer({ resolveWithObject: true });
const photo = await eye.analyze({ data, width: info.width, height: info.height });
整个指南在 眼睛文件。 。 。 .
许可证
沙漠蚂蚁实验室 源头可破坏许可证。为大多数免费提供 应用软件和商务许可证必须规模化。 完整的术语在链接. 许可证发放: 许可@ desertant.com。 。 。 .
SDK的第三方通知: THIRD_PARTY_NOTICES.md。 。 。 .
权重第三方通知: THIRD_PARTY_NOTICES.md。 。 。 .