[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-hollance--Forge":3,"tool-hollance--Forge":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":80,"owner_email":81,"owner_twitter":82,"owner_website":83,"owner_url":84,"languages":85,"stars":98,"forks":99,"last_commit_at":100,"license":101,"difficulty_score":102,"env_os":103,"env_gpu":104,"env_ram":105,"env_deps":106,"category_tags":113,"github_topics":114,"view_count":23,"oss_zip_url":123,"oss_zip_packed_at":123,"status":16,"created_at":124,"updated_at":125,"faqs":126,"releases":162},2370,"hollance\u002FForge","Forge","A neural network toolkit for Metal","Forge 是一款专为 Apple Metal 框架设计的神经网络工具包，旨在简化在 iOS 和 macOS 平台上构建深度神经网络的流程。它主要解决了直接调用底层 MPSCNN API 时代码繁琐、数据格式转换困难以及调试复杂等痛点，让开发者能更专注于模型逻辑而非底层细节。\n\nForge 非常适合需要在苹果生态中进行高性能移动端 AI 开发的工程师和研究人员。如果你追求比 Core ML 更快的推理速度，或者需要实现 MobileNet、SSD 等特定架构，Forge 提供了极佳的解决方案。其核心亮点在于提供了一套简洁的领域特定语言（DSL），允许通过链式调用轻松定义网络层级；同时内置了丰富的数据预处理核（如均值减法、色彩空间转换）及自定义计算核支持。此外，Forge 还配备了实用的调试工具，帮助开发者直观检查 Metal 纹理中的数据内容，确保计算准确性。\n\n需要注意的是，由于作者已停止维护且其依赖的旧版 MPSCNN API 不再被苹果官方支持，建议使用者在评估项目需求时谨慎参考，或将其作为理解 Metal 神经网络底层实现的优秀学习资源。","# Forge: a neural network toolkit for Metal\n\n:warning: :warning: :warning: **IMPORTANT:** I'm no longer maintaining Forge. It uses an older version of the MPSCNN API that is no longer supported by Apple. I also feel that Core ML has largely taken away the need for a library like this. However, neural networks implemented in Metal are still faster than Core ML. If you're looking for very fast implementations of MobileNet V1, MobileNet V2, and SSD for iOS and macOS, check out [my new source code library](http:\u002F\u002Fmachinethink.net\u002Ffaster-neural-networks\u002F).\n\n---\n\n**Forge** is a collection of helper code that makes it a little easier to construct deep neural networks using Apple's MPSCNN framework.\n\n[Read the blog post](http:\u002F\u002Fmachinethink.net\u002Fblog\u002Fforge-neural-network-toolkit-for-metal\u002F)\n\n![Geordi likes it!](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhollance_Forge_readme_83109f9f889c.png)\n\n## What does this do?\n\nFeatures of Forge:\n\n**Conversion functions.** MPSCNN uses `MPSImage`s and `MTLTexture`s for everything, often using 16-bit floats. But you probably want to work with Swift `[Float]` arrays. Forge's conversion functions make it easy to work with Metal images and textures.\n\n**Easy layer creation.** Reduce the boilerplate when building the layers for your neural network. Forge's domain-specific language makes defining a neural net as simple as:\n\n```swift\nlet input = Input()\n\nlet output = input\n        --> Resize(width: 28, height: 28)\n        --> Convolution(kernel: (5, 5), channels: 20, activation: relu, name: \"conv1\")\n        --> MaxPooling(kernel: (2, 2), stride: (2, 2))\n        --> Convolution(kernel: (5, 5), channels: 50, activation: relu, name: \"conv2\")\n        --> MaxPooling(kernel: (2, 2), stride: (2, 2))\n        --> Dense(neurons: 320, activation: relu, name: \"fc1\")\n        --> Dense(neurons: 10, name: \"fc2\")\n        --> Softmax()\n\nlet model = Model(input: input, output: output)\n```\n\n**Custom layers.** MPSCNN only supports a limited number of layers, so we've added a few of our own:\n\n- Depth-wise convolution\n- Transpose channels\n- Deconvolution (coming soon!)\n\n**Preprocessing kernels.** Often you need to preprocess data before it goes into the neural network. Forge comes with a few handy kernels for this:\n\n- SubtractMeanColor\n- RGB2Gray\n- RGB2BGR\n\n**Custom compute kernels.** Many neural networks require custom compute kernels, so Forge provides helpers that make it easy to write and launch your own kernels.\n\n**Debugging tools.** When you implement a neural network in Metal you want to make sure it actually computes the correct thing. Due to the way Metal encodes the data, inspecting the contents of the `MTLTexture` objects is not always straightforward. Forge can help with this.\n\n**Example projects.** Forge comes with a number of pretrained neural networks, such as LeNet-5 on MNIST, Inception3 on ImageNet, and MobileNets.\n\n> **Note:** A lot of the code in this library is still *experimental* and subject to change. Use at your own risk!\n\n## iOS 10 and iOS 11 compatibility\n\nForge supports both iOS 10 and iOS 11.\n\nForge must be compiled with **Xcode 9** and the iOS 11 SDK. (An older version is available under the tag `xcode8`, but is no longer supported.)\n\n**Important changes:**\n\nThe order of the weights for `DepthwiseConvolution` layers has changed. It used to be:\n\n\t[kernelHeight][kernelWidth][channels]\n\t\nnow it is:\n\n\t[channels][kernelHeight][kernelWidth]\n\nThis was done to make this layer compatible with MPS's new depthwise convolution. On iOS 10, Forge will use its own `DepthwiseConvolutionKernel`, on iOS 11 and later is uses the MPS version (`MPSCNNDepthWiseConvolutionDescriptor`).\n\nNote: Forge does not yet take advantage of all the MPS improvements in iOS 11, such as the ability to load batch normalization parameters or loading weights via data sources. This functionality will be added in a future version.\n\n## Run the examples!\n\nTo see a demo of Forge in action, open **Forge.xcworkspace** in Xcode and run one of the example apps on your device.\n\nYou need at least Xcode 9 and a device with an A8 processor (iPhone 6 or better) running iOS 10 or later. You cannot build for the simulator as it does not support Metal.\n\nThe included examples are:\n\n### MNIST\n\nThis example implements a very basic LeNet5-type neural network, trained on the MNIST dataset for handwritten digit recognition.\n\nRun the app and point the camera at a handwritten digit (there are some images in the `Test Images` folder you can use for this) and the app will tell you what digit it is, and how sure it is of this prediction.\n\n![MNIST example](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhollance_Forge_readme_4529016655a1.jpg)\n\nThe small image in the top-left corner shows what the network sees (this is the output of the preprocessing shader that attempts to increase the contrast between black and white).\n\nThere are two targets in this project: \n\n- MNIST\n- MNIST-DSL\n\nThey do the exact same thing, except the first one is written with straight MPSCNN code and the second one uses the Forge DSL and is therefore much easier to read.\n\n### Inception-v3\n\nGoogle's famous [Inception network](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1512.00567v3.pdf) for image classification. Point your phone at some object and the app will give you its top-5 predictions:\n\n![Inception example](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhollance_Forge_readme_37e0f53c0379.jpg)\n\nThe Inception example app is based on [Apple's sample code](https:\u002F\u002Fdeveloper.apple.com\u002Flibrary\u002Fcontent\u002Fsamplecode\u002FMetalImageRecognition\u002FIntroduction\u002FIntro.html) but completely rewritten using the DSL. We use their learned parameters. Thanks, Apple!\n\n### YOLO\n\nYOLO is an object detection network. It can detect multiple objects in an image and will even tell you where they are!\n\n![YOLO example](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhollance_Forge_readme_1459499a60b3.jpg)\n\nThe example app implements the Tiny YOLO network, which is not as accurate as the full version of [YOLO9000](https:\u002F\u002Fpjreddie.com\u002Fdarknet\u002Fyolo\u002F) and can detect only 20 different kinds of objects.\n\n[YOLO9000: Better, Faster, Stronger](https:\u002F\u002Farxiv.org\u002Fabs\u002F1612.08242) by Joseph Redmon and Ali Farhadi (2016).\n\n### MobileNets\n\nThe **MobileNets** example app is an implementation of the network architecture from the paper [MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications](https:\u002F\u002Farxiv.org\u002Fabs\u002F1704.04861v1).\n\nIt works like Inception-v3 but is much faster. On the iPhone 6s it runs at 20 FPS with only moderate-to-high energy usage.\n\nForge uses the pretrained weights from [shicai\u002FMobileNet-Caffe](https:\u002F\u002Fgithub.com\u002Fshicai\u002FMobileNet-Caffe).\n\n## How to add Forge to your own project\n\nUse Xcode 9 or better.\n\n1. Copy the **Forge** folder into your project.\n2. Use **File > Add Files to \"YourProject\" > Forge.xcodeproj** to add the Forge project inside your own project.\n3. Drag **Products\u002FForge.framework** into the **Embedded Binaries** section of your project settings.\n4. `import Forge` in your code.\n\nNOTE: You cannot build for the simulator, only for \"Generic iOS Device\" or an actual device with arm64 architecture.\n\n## How to use Forge\n\n- [Creating a model with Forge](Docs\u002FDSL.markdown)\n- [Importing a model from Keras, TensorFlow, Caffe, etc](Docs\u002FImporting.markdown)\n\n## Where are the unit tests?\n\nRun the **ForgeTests** app on a device.\n\nThe reason the tests are in a separate app is that Metal does not work on the simulator and Xcode can't run logic tests on the device. Catch-22.\n\n## TODO\n\nForge is under active development. Here is the [list of bugs and upcoming features](Docs\u002FTODO.markdown).\n\n## License and credits\n\nForge is copyright 2016-2017 Matthijs Hollemans and is licensed under the terms of the [MIT license](LICENSE.txt).\n","# Forge：适用于 Metal 的神经网络工具包\n\n:warning: :warning: :warning: **重要提示：** 我已不再维护 Forge。它使用的是较旧版本的 MPSCNN API，而该 API 现已被 Apple 废弃。此外，我认为 Core ML 已经在很大程度上消除了对类似库的需求。不过，在 Metal 中实现的神经网络仍然比 Core ML 更快。如果您正在寻找适用于 iOS 和 macOS 的非常快速的 MobileNet V1、MobileNet V2 和 SSD 实现，请查看[我的新源代码库](http:\u002F\u002Fmachinethink.net\u002Ffaster-neural-networks\u002F)。\n\n---\n\n**Forge** 是一套辅助代码集合，旨在让使用 Apple 的 MPSCNN 框架构建深度神经网络变得更加简单。\n\n[阅读博客文章](http:\u002F\u002Fmachinethink.net\u002Fblog\u002Fforge-neural-network-toolkit-for-metal\u002F)\n\n![乔迪很喜欢！](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhollance_Forge_readme_83109f9f889c.png)\n\n## 这个工具能做什么？\n\nForge 的主要特性：\n\n**转换函数。** MPSCNN 对所有内容都使用 `MPSImage` 和 `MTLTexture`，并且通常采用 16 位浮点数格式。但您可能更希望使用 Swift 的 `[Float]` 数组。Forge 提供的转换函数可以让您轻松地处理 Metal 图像和纹理。\n\n**便捷的层创建。** 减少构建神经网络各层时的样板代码。Forge 的领域特定语言使定义神经网络变得极其简单，例如：\n\n```swift\nlet input = Input()\n\nlet output = input\n        --> Resize(width: 28, height: 28)\n        --> Convolution(kernel: (5, 5), channels: 20, activation: relu, name: \"conv1\")\n        --> MaxPooling(kernel: (2, 2), stride: (2, 2))\n        --> Convolution(kernel: (5, 5), channels: 50, activation: relu, name: \"conv2\")\n        --> MaxPooling(kernel: (2, 2), stride: (2, 2))\n        --> Dense(neurons: 320, activation: relu, name: \"fc1\")\n        --> Dense(neurons: 10, name: \"fc2\")\n        --> Softmax()\n\nlet model = Model(input: input, output: output)\n```\n\n**自定义层。** MPSCNN 仅支持有限数量的层，因此我们添加了一些自定义层：\n\n- 深度可分离卷积\n- 通道转置\n- 反卷积（即将推出！）\n\n**预处理内核。** 在数据进入神经网络之前，通常需要进行预处理。Forge 提供了几个实用的预处理内核：\n\n- SubtractMeanColor（减去平均颜色）\n- RGB2Gray（RGB 转灰度）\n- RGB2BGR（RGB 转 BGR）\n\n**自定义计算内核。** 许多神经网络需要自定义计算内核，因此 Forge 提供了帮助程序，使编写和启动您自己的内核变得容易。\n\n**调试工具。** 当您在 Metal 中实现神经网络时，需要确保其计算结果正确。由于 Metal 编码数据的方式，直接检查 `MTLTexture` 对象的内容并不总是那么容易。Forge 可以在这方面提供帮助。\n\n**示例项目。** Forge 自带多个预训练的神经网络，例如 MNIST 数据集上的 LeNet-5、ImageNet 上的 Inception3 以及 MobileNets。\n\n> **注意：** 此库中的许多代码仍处于 *实验性* 阶段，并可能随时发生变化。请自行承担风险！\n\n## iOS 10 和 iOS 11 兼容性\n\nForge 同时支持 iOS 10 和 iOS 11。\n\nForge 必须使用 **Xcode 9** 和 iOS 11 SDK 进行编译。（有一个较旧的版本位于 `xcode8` 标签下，但已不再维护。）\n\n**重要变更：**\n\n`DepthwiseConvolution` 层权重的顺序发生了变化。以前是：\n\n\t[kernelHeight][kernelWidth][channels]\n\t\n现在变为：\n\n\t[channels][kernelHeight][kernelWidth]\n\n这是为了使该层与 MPS 的新型深度可分离卷积兼容。在 iOS 10 上，Forge 将使用自己的 `DepthwiseConvolutionKernel`；而在 iOS 11 及更高版本中，则使用 MPS 版本（`MPSCNNDepthWiseConvolutionDescriptor`）。\n\n注意：Forge 目前尚未利用 iOS 11 中 MPS 的所有改进功能，例如加载批归一化参数或通过数据源加载权重的功能。这些功能将在未来的版本中加入。\n\n## 运行示例！\n\n要查看 Forge 的实际演示效果，请在 Xcode 中打开 **Forge.xcworkspace**，并在您的设备上运行其中一个示例应用。\n\n您至少需要 Xcode 9 和搭载 A8 处理器（iPhone 6 或更高）且运行 iOS 10 或更高版本的设备。无法针对模拟器进行构建，因为模拟器不支持 Metal。\n\n包含的示例包括：\n\n### MNIST\n\n此示例实现了一个非常基础的 LeNet5 类型神经网络，该网络在 MNIST 手写数字识别数据集上进行了训练。\n\n运行该应用，并将摄像头对准一个手写数字（`Test Images` 文件夹中有一些可用于此目的的图像），应用会告诉您该数字是什么，以及它对该预测的置信度。\n\n![MNIST 示例](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhollance_Forge_readme_4529016655a1.jpg)\n\n左上角的小图显示了网络所看到的内容（这是预处理着色器的输出，该着色器试图增强黑白之间的对比度）。\n\n该项目有两个目标：\n\n- MNIST\n- MNIST-DSL\n\n它们执行完全相同的操作，只是第一个是用纯 MPSCNN 代码编写的，而第二个则使用 Forge DSL，因此更容易阅读。\n\n### Inception-v3\n\nGoogle 著名的 [Inception 网络](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1512.00567v3.pdf) 用于图像分类。将您的手机对准某个物体，应用会给出其前 5 名预测：\n\n![Inception 示例](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhollance_Forge_readme_37e0f53c0379.jpg)\n\nInception 示例应用基于 [Apple 的示例代码](https:\u002F\u002Fdeveloper.apple.com\u002Flibrary\u002Fcontent\u002Fsamplecode\u002FMetalImageRecognition\u002FIntroduction\u002FIntro.html)，但我们完全使用 DSL 重写了它。我们使用了他们训练好的参数。感谢 Apple！\n\n### YOLO\n\nYOLO 是一种目标检测网络。它可以检测图像中的多个对象，甚至会告诉您它们的位置！\n\n![YOLO 示例](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhollance_Forge_readme_1459499a60b3.jpg)\n\n示例应用实现了 Tiny YOLO 网络，其精度不如完整的 [YOLO9000](https:\u002F\u002Fpjreddie.com\u002Fdarknet\u002Fyolo\u002F) 版本，只能检测 20 种不同的物体。\n\n[YOLO9000：更好、更快、更强](https:\u002F\u002Farxiv.org\u002Fabs\u002F1612.08242) 由 Joseph Redmon 和 Ali Farhadi（2016 年）提出。\n\n### MobileNets\n\n**MobileNets** 示例应用是对论文 [MobileNets：用于移动视觉应用的高效卷积神经网络](https:\u002F\u002Farxiv.org\u002Fabs\u002F1704.04861v1) 中网络架构的实现。\n\n它的工作方式类似于 Inception-v3，但速度要快得多。在 iPhone 6s 上，它能够以 20 FPS 的帧率运行，同时能耗仅为中等至较高水平。\n\nForge 使用了来自 [shicai\u002FMobileNet-Caffe](https:\u002F\u002Fgithub.com\u002Fshicai\u002FMobileNet-Caffe) 的预训练权重。\n\n## 如何将 Forge 添加到您自己的项目中\n\n请使用 Xcode 9 或更高版本。\n\n1. 将 **Forge** 文件夹复制到您的项目中。\n2. 使用 **文件 > 添加文件到“YourProject” > Forge.xcodeproj** 将 Forge 项目添加到您自己的项目中。\n3. 将 **Products\u002FForge.framework** 拖放到您的项目设置中的 **嵌入式二进制文件** 部分。\n4. 在您的代码中 `import Forge`。\n\n注意：您无法针对模拟器进行构建，只能针对“通用 iOS 设备”或具有 arm64 架构的实际设备进行构建。\n\n## 如何使用 Forge\n\n- [使用 Forge 创建模型](Docs\u002FDSL.markdown)\n- [从 Keras、TensorFlow、Caffe 等导入模型](Docs\u002FImporting.markdown)\n\n## 单元测试在哪里？\n\n在设备上运行 **ForgeTests** 应用。\n\n将测试放在单独的应用中的原因是，Metal 在模拟器上无法正常工作，而 Xcode 又无法在设备上运行逻辑测试。真是个两难的境地。\n\n## 待办事项\n\nForge 目前正处于积极开发中。以下是[已知问题和即将推出的功能列表](Docs\u002FTODO.markdown)。\n\n## 许可证与致谢\n\nForge 版权归 Matthijs Hollemans 所有，版权年份为 2016–2017 年，并根据 [MIT 许可证](LICENSE.txt)条款授权使用。","# Forge 快速上手指南\n\n> **⚠️ 重要提示**：本项目作者已停止维护。Forge 使用的是旧版 MPSCNN API，不再受 Apple 支持。虽然 Metal 实现的神经网络速度仍快于 Core ML，但建议新项目优先考虑 Core ML 或作者推荐的 [新代码库](http:\u002F\u002Fmachinethink.net\u002Ffaster-neural-networks\u002F)。本指南仅适用于需要维护旧项目或研究特定 Metal 实现的开发者。\n\nForge 是一个基于 Apple MPSCNN 框架的辅助工具集，旨在简化使用 Metal 构建深度神经网络的过程，提供便捷的层创建、数据转换及调试功能。\n\n## 环境准备\n\n在开始之前，请确保满足以下硬件和软件要求：\n\n*   **操作系统**：macOS（需安装 Xcode）\n*   **开发工具**：**Xcode 9** 或更高版本（必须使用 iOS 11 SDK 编译）。\n    *   *注：旧版 Xcode 8 对应版本位于 `xcode8` 标签，但已不再支持。*\n*   **目标设备**：\n    *   搭载 **A8 处理器** 或更高版本的 iPhone\u002FiPad（iPhone 6 及以上）。\n    *   系统版本：**iOS 10** 或更高。\n*   **架构限制**：仅支持 `arm64` 架构。**不支持 iOS 模拟器**（Simulator 不支持 Metal），必须使用真机或 \"Generic iOS Device\" 进行构建。\n\n## 安装步骤\n\nForge 没有通过 CocoaPods 或 Carthage 分发，需手动将其源码集成到您的项目中。\n\n1.  **获取源码**\n    克隆仓库或下载源码包，将名为 `Forge` 的文件夹复制到您的项目目录中。\n\n2.  **添加子项目**\n    在 Xcode 中打开您的项目，选择菜单栏：\n    `File` > `Add Files to \"YourProject\"...`\n    选中并添加 `Forge\u002FForge.xcodeproj` 文件。\n\n3.  **嵌入框架**\n    点击您的主项目 Target，进入 `General` 设置页：\n    *   找到 **Embedded Binaries** 部分。\n    *   将 `Products\u002FForge.framework` 从左侧项目导航栏拖入该区域。\n    *   确保 `Copy items if needed` 被勾选（如果尚未自动处理）。\n\n4.  **引入模块**\n    在您的 Swift 代码文件顶部添加：\n    ```swift\n    import Forge\n    ```\n\n## 基本使用\n\nForge 的核心优势在于其领域特定语言（DSL），可以极大地减少构建神经网络时的样板代码。以下是一个构建简单卷积神经网络（类似 LeNet-5）的最小化示例：\n\n```swift\n\u002F\u002F 1. 定义输入\nlet input = Input()\n\n\u002F\u002F 2. 使用链式调用构建网络结构\nlet output = input\n        --> Resize(width: 28, height: 28)\n        --> Convolution(kernel: (5, 5), channels: 20, activation: relu, name: \"conv1\")\n        --> MaxPooling(kernel: (2, 2), stride: (2, 2))\n        --> Convolution(kernel: (5, 5), channels: 50, activation: relu, name: \"conv2\")\n        --> MaxPooling(kernel: (2, 2), stride: (2, 2))\n        --> Dense(neurons: 320, activation: relu, name: \"fc1\")\n        --> Dense(neurons: 10, name: \"fc2\")\n        --> Softmax()\n\n\u002F\u002F 3. 创建模型对象\nlet model = Model(input: input, output: output)\n```\n\n### 关键功能说明\n\n*   **数据转换**：Forge 提供了辅助函数，方便在 Metal 的 `MPSImage`\u002F`MTLTexture`（通常为 16 位浮点）与您常用的 Swift `[Float]` 数组之间进行转换。\n*   **自定义层**：除了 MPSCNN 原生支持的层外，Forge 还额外实现了 `Depth-wise convolution`（深度可分离卷积）、`Transpose channels` 等层。\n*   **预处理内核**：内置了 `SubtractMeanColor`、`RGB2Gray`、`RGB2BGR` 等常用图像预处理算子。\n*   **调试支持**：提供工具帮助检查 `MTLTexture` 内部数据，验证计算结果是否正确。\n\n### 运行示例\n\n项目包含多个预训练模型示例（如 MNIST 手写数字识别、Inception-v3 图像分类、YOLO 目标检测、MobileNets）。\n\n1.  打开 `Forge.xcworkspace`。\n2.  连接您的 iOS 真机。\n3.  选择一个示例 Scheme（例如 `MNIST-DSL`）。\n4.  点击运行（Build & Run）。\n    *   *注意：切勿选择模拟器作为运行目标，否则构建会失败。*","一位 iOS 开发者需要在旧款 iPhone 上部署一个实时的工业缺陷检测应用，要求极低的推理延迟且无法依赖云端服务。\n\n### 没有 Forge 时\n- **数据转换繁琐**：开发者必须手动编写大量样板代码，在 Swift 的 `[Float]` 数组与 Metal 所需的 `MPSImage` 或 `MTLTexture` 之间进行复杂的格式转换。\n- **网络构建冗长**：使用原生 MPSCNN API 定义卷积、池化等层级时，需要初始化大量描述符对象，代码臃肿且难以直观查看网络结构。\n- **调试极其困难**：由于 Metal 以特殊编码存储纹理数据，直接检查中间层输出是否正确几乎不可能，排查错误如同“盲人摸象”。\n- **缺失关键算子**：原生框架缺乏深度卷积（Depth-wise convolution）等移动端必备的高效算子，导致模型运行速度无法满足实时性要求。\n- **预处理重复造轮子**：每次都需要重新编写均值减去、RGB 转灰度等基础图像预处理内核，浪费开发时间。\n\n### 使用 Forge 后\n- **无缝数据交互**：利用 Forge 内置的转换函数，开发者可以直接使用熟悉的 Swift 数组处理数据，底层自动完成与 Metal 纹理的对接。\n- **链式简洁建模**：通过 Forge 的领域特定语言（DSL），可以用类似 `input --> Convolution(...) --> MaxPooling(...)` 的链式调用清晰定义整个神经网络。\n- **可视化调试支持**：借助 Forge 提供的调试工具，可以轻松提取并 inspect 纹理内容，快速验证每一层的计算结果是否符合预期。\n- **高性能算子即用**：直接调用 Forge 扩展的深度卷积等自定义层，在老旧设备上也能获得比 Core ML 更快的推理速度。\n- **开箱即用的预处理**：直接复用 `SubtractMeanColor` 等现成内核，几分钟内即可完成数据清洗流程，专注于核心算法优化。\n\nForge 将原本晦涩难懂的底层 Metal 图形编程转化为直观的 Swift 代码，让开发者能在苹果设备上轻松构建并调试高性能的深度学习模型。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhollance_Forge_8c002da6.png","hollance","Matthijs Hollemans","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fhollance_d5df01c7.jpg","Audio software developer and all-round software geek.","Audio developer","Netherlands","mail@hollance.com","mhollemans","https:\u002F\u002Faudiodev.blog","https:\u002F\u002Fgithub.com\u002Fhollance",[86,90,94],{"name":87,"color":88,"percentage":89},"Swift","#F05138",92.4,{"name":91,"color":92,"percentage":93},"Metal","#8f14e9",7.1,{"name":95,"color":96,"percentage":97},"Objective-C","#438eff",0.5,1265,172,"2026-04-01T01:04:43","MIT",4,"macOS, iOS","必需 Apple GPU (支持 Metal)，需 A8 处理器或更高版本 (iPhone 6 及以上)，不支持 NVIDIA\u002FCUDA","未说明",{"notes":107,"python":108,"dependencies":109},"该项目已停止维护，使用的是旧版 MPSCNN API。仅支持真机运行，不支持模拟器 (因模拟器不支持 Metal)。主要使用 Swift 语言开发，而非 Python。作者建议对于新需求可考虑 Core ML 或其新的代码库。","不适用 (基于 Swift)",[110,111,112,91],"Xcode 9+","iOS 11 SDK","Apple MPSCNN Framework",[13],[115,116,117,118,119,120,121,122],"metal","deep-learning","deep-neural-networks","neural-network","ios","swift","mobilenets","machine-learning",null,"2026-03-27T02:49:30.150509","2026-04-06T05:35:40.908127",[127,132,137,142,147,152,157],{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},10886,"每次创建神经网络或呈现相机控制器时出现内存泄漏（约 10MB 未释放），如何解决？","该问题已被修复。维护者已更新代码解决了内存泄漏问题，请拉取最新代码并重新测试。如果之前遇到此问题，更新后应不再出现内存随次数增加的情况。","https:\u002F\u002Fgithub.com\u002Fhollance\u002FForge\u002Fissues\u002F21",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},10887,"CoreML 是否支持 MobileNet-SSD 模型？转换时遇到 'permute_param' 错误怎么办？","是的，CoreML 支持 MobileNet-SSD。如果遇到 Protobuf 解析错误（如缺少 'permute_param' 字段），可以尝试以下方案：\n1. 直接从主分支加载并在 Xcode 中更改开发者团队设置即可运行。\n2. 或者使用社区提供的部分移植版本：https:\u002F\u002Fgithub.com\u002Fvonholst\u002FSSDMobileNet_CoreML，该版本的网络输出末端已用 Swift 代码重新实现，可避免转换错误。","https:\u002F\u002Fgithub.com\u002Fhollance\u002FForge\u002Fissues\u002F22",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},10888,"在使用 MPSCNNConvolution 进行卷积操作时结果不正确或报错，常见原因有哪些？","常见原因及解决方法如下：\n1. 数据类型不匹配：如果将数据类型设置为 `.float16`，但权重缓冲区使用的是 32 位浮点数（Float），会导致错误。请确保权重和输入的数据类型一致。\n2. 偏移量（offset）设置不当：检查是否正确设置了 `mpsoffset`。\n3. 张量维度转换：注意 NCHW 到 NHWC 的转换逻辑，确保输入缓冲区和权重缓冲区的维度排列符合 MPSImage 的要求。","https:\u002F\u002Fgithub.com\u002Fhollance\u002FForge\u002Fissues\u002F44",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},10889,"在 Windows ML 或其他平台迁移 YOLO 模型时，由于通道数不同（如 125 vs 128）导致边界框计算出现“数组索引越界”错误，如何处理？","这是因为不同实现的输出通道数不同（Swift 实现通常为 125 或 128，取决于是否包含背景类或填充）。解决方法是：\n1. 相应地调整步长（stride）变量以匹配实际的通道数。\n2. 根据内存组织方式（如 [height][width][channels]）重写偏移量（offset）计算函数，确保索引计算不超出实际通道范围。需要根据具体的内存布局调整索引公式。","https:\u002F\u002Fgithub.com\u002Fhollance\u002FForge\u002Fissues\u002F43",{"id":148,"question_zh":149,"answer_zh":150,"source_url":151},10890,"使用 Forge 框架打包（Archive）应用时报错，提示 unresolved symbols 或 CFBundleExecutable 相关错误，如何解决？","请按以下步骤排查：\n1. 检查 Forge 的 `Info.plist` 文件，移除其中的 `CFBundleExecutable` 键值，这通常是导致归档失败的主要原因。\n2. 确认 Forge 框架仅针对 arm64 架构编译，如果归档配置中包含不支持的架构（如模拟器架构），可能会导致第一个错误。\n3. 确保正确嵌入了 `Forge.framework`，并且没有重复链接或配置冲突。","https:\u002F\u002Fgithub.com\u002Fhollance\u002FForge\u002Fissues\u002F9",{"id":153,"question_zh":154,"answer_zh":155,"source_url":156},10891,"为什么自己编写的 Metal Shader 卷积性能远不如 MPSCNN？MPSCNN 为何如此快？","MPSCNN 是 Apple 高度优化的底层库，专门针对 GPU 硬件特性进行了深度优化（如利用特定的缓存策略、指令集和并行计算单元），因此性能极高（例如 SqueezeNet 仅需 20ms）。\n而自己编写的 Metal Shader 如果没有经过同等程度的底层优化（如寄存器分配、内存访问模式优化等），性能通常会较差。对于生产环境，建议优先使用 MPSCNN API；若需自定义算子，需深入研究 GPU 架构并进行精细的手动优化才能接近 MPSCNN 的性能。","https:\u002F\u002Fgithub.com\u002Fhollance\u002FForge\u002Fissues\u002F4",{"id":158,"question_zh":159,"answer_zh":160,"source_url":161},10892,"Forge 框架在 iOS 10 及以下版本设备上如何运行模型？与 iOS 11 的 MPSCNN 有何区别？","iOS 11 引入了对 dilated conv（空洞卷积）和 deconv（反卷积）层的原生支持，可以直接使用 MPSCNN。\n对于 iOS 10 及更旧版本的设备，系统原生不支持这些新特性，此时必须使用 Forge 框架。Forge 通过自定义 Metal 着色器实现了这些层，是在旧版 iOS 设备上运行复杂深度学习模型的唯一可行方案。","https:\u002F\u002Fgithub.com\u002Fhollance\u002FForge\u002Fissues\u002F11",[]]