[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-lukemelas--PyTorch-Pretrained-ViT":3,"tool-lukemelas--PyTorch-Pretrained-ViT":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":70,"readme_en":71,"readme_zh":72,"quickstart_zh":73,"use_case_zh":74,"hero_image_url":75,"owner_login":76,"owner_name":77,"owner_avatar_url":78,"owner_bio":79,"owner_company":80,"owner_location":81,"owner_email":82,"owner_twitter":82,"owner_website":83,"owner_url":84,"languages":85,"stars":98,"forks":99,"last_commit_at":100,"license":82,"difficulty_score":101,"env_os":102,"env_gpu":103,"env_ram":103,"env_deps":104,"category_tags":110,"github_topics":82,"view_count":23,"oss_zip_url":82,"oss_zip_packed_at":82,"status":16,"created_at":111,"updated_at":112,"faqs":113,"releases":144},3041,"lukemelas\u002FPyTorch-Pretrained-ViT","PyTorch-Pretrained-ViT","Vision Transformer (ViT) in PyTorch","PyTorch-Pretrained-ViT 是一个将谷歌提出的视觉 Transformer（ViT）架构完美移植到 PyTorch 框架的开源项目。它致力于解决研究人员和开发者在尝试使用 ViT 进行图像分类时，面临的原生代码依赖 JAX 框架、环境配置复杂以及预训练权重难以直接加载等痛点。\n\n该工具的核心优势在于实现了与谷歌原始 JAX 版本“操作对操作”的一致性，确保能够无缝加载官方提供的预训练模型权重。用户只需几行代码，即可轻松调用在 ImageNet-21k 或 ImageNet-1k 数据集上预训练好的多种规格模型（如 B_16, L_32 等），快速开展图像分类评估、特征提取或针对自定义数据集的微调工作。其设计哲学强调简洁性与高扩展性，代码结构清晰，非常便于集成到现有的深度学习项目中。\n\nPyTorch-Pretrained-ViT 特别适合熟悉 PyTorch 生态的 AI 工程师、计算机视觉研究人员以及希望快速验证 ViT 算法效果的学生群体。对于想要探索\"Attention 机制在视觉领域应用”但又不愿陷入繁琐底层实现的从业者来说，这是一个高效且可靠的入门与实践工具","PyTorch-Pretrained-ViT 是一个将谷歌提出的视觉 Transformer（ViT）架构完美移植到 PyTorch 框架的开源项目。它致力于解决研究人员和开发者在尝试使用 ViT 进行图像分类时，面临的原生代码依赖 JAX 框架、环境配置复杂以及预训练权重难以直接加载等痛点。\n\n该工具的核心优势在于实现了与谷歌原始 JAX 版本“操作对操作”的一致性，确保能够无缝加载官方提供的预训练模型权重。用户只需几行代码，即可轻松调用在 ImageNet-21k 或 ImageNet-1k 数据集上预训练好的多种规格模型（如 B_16, L_32 等），快速开展图像分类评估、特征提取或针对自定义数据集的微调工作。其设计哲学强调简洁性与高扩展性，代码结构清晰，非常便于集成到现有的深度学习项目中。\n\nPyTorch-Pretrained-ViT 特别适合熟悉 PyTorch 生态的 AI 工程师、计算机视觉研究人员以及希望快速验证 ViT 算法效果的学生群体。对于想要探索\"Attention 机制在视觉领域应用”但又不愿陷入繁琐底层实现的从业者来说，这是一个高效且可靠的入门与实践工具。","# ViT PyTorch\n\n### Quickstart\n\nInstall with `pip install pytorch_pretrained_vit` and load a pretrained ViT with:\n```python\nfrom pytorch_pretrained_vit import ViT\nmodel = ViT('B_16_imagenet1k', pretrained=True)\n```\n\nOr find a Google Colab example [here](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1muZ4QFgVfwALgqmrfOkp7trAvqDemckO?usp=sharing).  \n\n### Overview\nThis repository contains an op-for-op PyTorch reimplementation of the [Visual Transformer](https:\u002F\u002Fopenreview.net\u002Fforum?id=YicbFdNTTy) architecture from [Google](https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fvision_transformer), along with pre-trained models and examples.\n\nThe goal of this implementation is to be simple, highly extensible, and easy to integrate into your own projects. \n\nAt the moment, you can easily:\n * Load pretrained ViT models\n * Evaluate on ImageNet or your own data\n * Finetune ViT on your own dataset\n\n_(Upcoming features)_ Coming soon: \n * Train ViT from scratch on ImageNet (1K)\n * Export to ONNX for efficient inference\n\n### Table of contents\n1. [About ViT](#about-vit)\n2. [About ViT-PyTorch](#about-vit-pytorch)\n3. [Installation](#installation)\n4. [Usage](#usage)\n    * [Load pretrained models](#loading-pretrained-models)\n    * [Example: Classify](#example-classification)\n    \u003C!-- * [Example: Extract features](#example-feature-extraction) -->\n    \u003C!-- * [Example: Export to ONNX](#example-export) -->\n6. [Contributing](#contributing)\n\n### About ViT\n\nVisual Transformers (ViT) are a straightforward application of the [transformer architecture](https:\u002F\u002Farxiv.org\u002Fabs\u002F1706.03762) to image classification. Even in computer vision, it seems, attention is all you need. \n\nThe ViT architecture works as follows: (1) it considers an image as a 1-dimensional sequence of patches, (2) it prepends a classification token to the sequence, (3) it passes these patches through a transformer encoder (like [BERT](https:\u002F\u002Farxiv.org\u002Fabs\u002F1810.04805)), (4) it passes the first token of the output of the transformer through a small MLP to obtain the classification logits. \nViT is trained on a large-scale dataset (ImageNet-21k) with a huge amount of compute. \n\n\u003Cdiv style=\"text-align: center; padding: 10px\">\n    \u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fgoogle-research\u002Fvision_transformer\u002Fmaster\u002Ffigure1.png\" width=\"100%\" style=\"max-width: 300px; margin: auto\"\u002F>\n\u003C\u002Fdiv>\n\n\n### About ViT-PyTorch\n\nViT-PyTorch is a PyTorch re-implementation of ViT. It is consistent with the [original Jax implementation](https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fvision_transformer), so that it's easy to load Jax-pretrained weights.\n\nAt the same time, we aim to make our PyTorch implementation as simple, flexible, and extensible as possible.\n\n### Installation\n\nInstall with pip:\n```bash\npip install pytorch_pretrained_vit\n```\n\nOr from source:\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Flukemelas\u002FViT-PyTorch\ncd ViT-Pytorch\npip install -e .\n```\n\n### Usage\n\n#### Loading pretrained models\n\nLoading a pretrained model is easy:\n```python\nfrom pytorch_pretrained_vit import ViT\nmodel = ViT('B_16_imagenet1k', pretrained=True)\n```\n\nDetails about the models are below:\n\n|    *Name*         |* Pretrained on *|*Finetuned on*|*Available? *|\n|:-----------------:|:---------------:|:------------:|:-----------:|\n| `B_16`            |  ImageNet-21k   | -            |      ✓      |\n| `B_32`            |  ImageNet-21k   | -            |      ✓      |\n| `L_16`            |  ImageNet-21k   | -            |      -      |\n| `L_32`            |  ImageNet-21k   | -            |      ✓      |\n| `B_16_imagenet1k` |  ImageNet-21k   | ImageNet-1k  |      ✓      |\n| `B_32_imagenet1k` |  ImageNet-21k   | ImageNet-1k  |      ✓      |\n| `L_16_imagenet1k` |  ImageNet-21k   | ImageNet-1k  |      ✓      |\n| `L_32_imagenet1k` |  ImageNet-21k   | ImageNet-1k  |      ✓      |\n\n#### Custom ViT\n\nLoading custom configurations is just as easy: \n```python\nfrom pytorch_pretrained_vit import ViT\n# The following is equivalent to ViT('B_16')\nconfig = dict(hidden_size=512, num_heads=8, num_layers=6)\nmodel = ViT.from_config(config)\n```\n\n#### Example: Classification\n\nBelow is a simple, complete example. It may also be found as a Jupyter notebook in `examples\u002Fsimple` or as a [Colab Notebook]().  \n\u003C!-- TODO: new Colab -->\n\n```python\nimport json\nfrom PIL import Image\nimport torch\nfrom torchvision import transforms\n\n# Load ViT\nfrom pytorch_pretrained_vit import ViT\nmodel = ViT('B_16_imagenet1k', pretrained=True)\nmodel.eval()\n\n# Load image\n# NOTE: Assumes an image `img.jpg` exists in the current directory\nimg = transforms.Compose([\n    transforms.Resize((384, 384)), \n    transforms.ToTensor(),\n    transforms.Normalize(0.5, 0.5),\n])(Image.open('img.jpg')).unsqueeze(0)\nprint(img.shape) # torch.Size([1, 3, 384, 384])\n\n# Classify\nwith torch.no_grad():\n    outputs = model(img)\nprint(outputs.shape)  # (1, 1000)\n```\n\n\u003C!-- #### Example: Feature Extraction\n\nYou can easily extract features with `model.extract_features`:\n```python\nfrom efficientnet_pytorch import EfficientNet\nmodel = EfficientNet.from_pretrained('efficientnet-b0')\n\n# ... image preprocessing as in the classification example ...\nprint(img.shape) # torch.Size([1, 3, 384, 384])\n\nfeatures = model.extract_features(img)\nprint(features.shape) # torch.Size([1, 1280, 7, 7])\n``` -->\n\n\u003C!-- #### Example: Export to ONNX\n\nExporting to ONNX for deploying to production is now simple:\n```python\nimport torch\nfrom efficientnet_pytorch import EfficientNet\n\nmodel = EfficientNet.from_pretrained('efficientnet-b1')\ndummy_input = torch.randn(10, 3, 240, 240)\n\nmodel.set_swish(memory_efficient=False)\ntorch.onnx.export(model, dummy_input, \"test-b1.onnx\", verbose=True)\n```\n\n[Here](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1rOAEXeXHaA8uo3aG2YcFDHItlRJMV0VP) is a Colab example. -->\n\n\n#### ImageNet\n\nSee `examples\u002Fimagenet` for details about evaluating on ImageNet.\n\n#### Credit\n\nOther great repositories with this model include: \n - [Ross Wightman's repo](https:\u002F\u002Fgithub.com\u002Frwightman\u002Fpytorch-image-models)\n - [Phil Wang's repo](https:\u002F\u002Fgithub.com\u002Flucidrains\u002Fvit-pytorch)\n\n### Contributing\n\nIf you find a bug, create a GitHub issue, or even better, submit a pull request. Similarly, if you have questions, simply post them as GitHub issues.\n\nI look forward to seeing what the community does with these models!\n","# ViT PyTorch\n\n### 快速入门\n\n使用 `pip install pytorch_pretrained_vit` 安装，并通过以下代码加载预训练的 ViT 模型：\n```python\nfrom pytorch_pretrained_vit import ViT\nmodel = ViT('B_16_imagenet1k', pretrained=True)\n```\n\n或者，您可以在 [这里](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1muZ4QFgVfwALgqmrfOkp7trAvqDemckO?usp=sharing) 找到一个 Google Colab 示例。\n\n### 概述\n本仓库包含对来自 [Google](https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fvision_transformer) 的 [视觉 Transformer](https:\u002F\u002Fopenreview.net\u002Fforum?id=YicbFdNTTy) 架构的逐层实现的 PyTorch 重写版本，并附带预训练模型和示例。\n\n该实现的目标是简单、高度可扩展，并且易于集成到您自己的项目中。目前，您可以轻松地：\n * 加载预训练的 ViT 模型\n * 在 ImageNet 或您自己的数据集上进行评估\n * 在您自己的数据集上微调 ViT\n\n_(即将推出的功能)_ 即将支持：\n * 从头开始在 ImageNet (1K) 上训练 ViT\n * 导出为 ONNX 格式以实现高效推理\n\n### 目录\n1. [关于 ViT](#about-vit)\n2. [关于 ViT-PyTorch](#about-vit-pytorch)\n3. [安装](#installation)\n4. [使用](#usage)\n    * [加载预训练模型](#loading-pretrained-models)\n    * [示例：分类](#example-classification)\n    \u003C!-- * [示例：特征提取](#example-feature-extraction) -->\n    \u003C!-- * [示例：导出为 ONNX](#example-export) -->\n6. [贡献](#contributing)\n\n### 关于 ViT\n\n视觉 Transformer (ViT) 是将 [Transformer 架构](https:\u002F\u002Farxiv.org\u002Fabs\u002F1706.03762) 直接应用于图像分类的一种方法。即使在计算机视觉领域，似乎注意力机制就是一切。\n\nViT 的工作原理如下：(1) 将图像视为一维的 patch 序列，(2) 在序列前添加一个分类 token，(3) 将这些 patch 输入到 Transformer 编码器中（类似于 [BERT](https:\u002F\u002Farxiv.org\u002Fabs\u002F1810.04805)），(4) 再将 Transformer 输出的第一个 token 通过一个小的 MLP 层，得到最终的分类 logits。ViT 是在大规模数据集（ImageNet-21k）上，利用大量计算资源训练得到的。\n\n\u003Cdiv style=\"text-align: center; padding: 10px\">\n    \u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fgoogle-research\u002Fvision_transformer\u002Fmaster\u002Ffigure1.png\" width=\"100%\" style=\"max-width: 300px; margin: auto\"\u002F>\n\u003C\u002Fdiv>\n\n\n### 关于 ViT-PyTorch\nViT-PyTorch 是 ViT 的 PyTorch 重写实现。它与 [原始的 Jax 实现](https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fvision_transformer) 保持一致，因此可以轻松加载 Jax 预训练的权重。\n\n同时，我们致力于使我们的 PyTorch 实现尽可能简单、灵活和可扩展。\n\n### 安装\n使用 pip 安装：\n```bash\npip install pytorch_pretrained_vit\n```\n\n或者从源码安装：\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Flukemelas\u002FViT-PyTorch\ncd ViT-Pytorch\npip install -e .\n```\n\n### 使用\n\n#### 加载预训练模型\n加载预训练模型非常简单：\n```python\nfrom pytorch_pretrained_vit import ViT\nmodel = ViT('B_16_imagenet1k', pretrained=True)\n```\n\n以下是各模型的详细信息：\n\n|    *名称*         |* 预训练数据集 *|*微调数据集*|*是否可用*|\n|:-----------------:|:---------------:|:------------:|:-----------:|\n| `B_16`            |  ImageNet-21k   | -            |      ✓      |\n| `B_32`            |  ImageNet-21k   | -            |      ✓      |\n| `L_16`            |  ImageNet-21k   | -            |      -      |\n| `L_32`            |  ImageNet-21k   | -            |      ✓      |\n| `B_16_imagenet1k` |  ImageNet-21k   | ImageNet-1k  |      ✓      |\n| `B_32_imagenet1k` |  ImageNet-21k   | ImageNet-1k  |      ✓      |\n| `L_16_imagenet1k` |  ImageNet-21k   | ImageNet-1k  |      ✓      |\n| `L_32_imagenet1k` |  ImageNet-21k   | ImageNet-1k  |      ✓      |\n\n#### 自定义 ViT\n加载自定义配置同样简单：\n```python\nfrom pytorch_pretrained_vit import ViT\n# 下面的配置等价于 ViT('B_16')\nconfig = dict(hidden_size=512, num_heads=8, num_layers=6)\nmodel = ViT.from_config(config)\n```\n\n#### 示例：分类\n以下是一个简单完整的示例。您也可以在 `examples\u002Fsimple` 中找到对应的 Jupyter 笔记本，或在 [Colab 笔记本]() 中查看。  \n\u003C!-- TODO: new Colab -->\n\n```python\nimport json\nfrom PIL import Image\nimport torch\nfrom torchvision import transforms\n\n# 加载 ViT\nfrom pytorch_pretrained_vit import ViT\nmodel = ViT('B_16_imagenet1k', pretrained=True)\nmodel.eval()\n\n# 加载图像\n# 注意：假设当前目录下存在名为 `img.jpg` 的图像\nimg = transforms.Compose([\n    transforms.Resize((384, 384)), \n    transforms.ToTensor(),\n    transforms.Normalize(0.5, 0.5),\n])(Image.open('img.jpg')).unsqueeze(0)\nprint(img.shape) # torch.Size([1, 3, 384, 384])\n\n# 分类\nwith torch.no_grad():\n    outputs = model(img)\nprint(outputs.shape)  # (1, 1000)\n```\n\n\u003C!-- #### 示例：特征提取\n\n您可以使用 `model.extract_features` 轻松提取特征：\n```python\nfrom efficientnet_pytorch import EfficientNet\nmodel = EfficientNet.from_pretrained('efficientnet-b0')\n\n# ... 图像预处理步骤同分类示例 ...\nprint(img.shape) # torch.Size([1, 3, 384, 384])\n\nfeatures = model.extract_features(img)\nprint(features.shape) # torch.Size([1, 1280, 7, 7])\n``` -->\n\n\u003C!-- #### 示例：导出为 ONNX\n\n现在可以轻松地将模型导出为 ONNX 格式以便部署到生产环境中：\n```python\nimport torch\nfrom efficientnet_pytorch import EfficientNet\n\nmodel = EfficientNet.from_pretrained('efficientnet-b1')\ndummy_input = torch.randn(10, 3, 240, 240)\n\nmodel.set_swish(memory_efficient=False)\ntorch.onnx.export(model, dummy_input, \"test-b1.onnx\", verbose=True)\n```\n\n[这里](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1rOAEXeXHaA8uo3aG2YcFDHItlRJMV0VP) 是一个 Colab 示例。 -->\n\n\n#### ImageNet\n有关在 ImageNet 上评估的详细信息，请参阅 `examples\u002Fimagenet`。\n\n#### 致谢\n其他包含此模型的优秀仓库包括：\n - [Ross Wightman 的仓库](https:\u002F\u002Fgithub.com\u002Frwightman\u002Fpytorch-image-models)\n - [Phil Wang 的仓库](https:\u002F\u002Fgithub.com\u002Flucidrains\u002Fvit-pytorch)\n\n### 贡献\n如果您发现任何 bug，请创建一个 GitHub 问题，或者更好的是提交一个拉取请求。同样，如果您有任何疑问，也请直接在 GitHub 上提出。\n\n我期待看到社区如何利用这些模型！","# PyTorch-Pretrained-ViT 快速上手指南\n\n## 环境准备\n*   **系统要求**：支持 Linux、macOS 或 Windows。\n*   **前置依赖**：\n    *   Python 3.6+\n    *   PyTorch 1.4+\n    *   torchvision\n    *   Pillow (PIL)\n*   **推荐**：建议使用虚拟环境（如 `venv` 或 `conda`）以避免依赖冲突。\n\n## 安装步骤\n\n### 方式一：通过 pip 安装（推荐）\n直接使用 pip 安装发布版本：\n```bash\npip install pytorch_pretrained_vit\n```\n> **国内加速提示**：若下载速度较慢，可使用清华或阿里镜像源：\n> ```bash\n> pip install pytorch_pretrained_vit -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n> ```\n\n### 方式二：从源码安装\n如需使用最新开发版功能，可从 GitHub 克隆源码安装：\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Flukemelas\u002FViT-PyTorch\ncd ViT-Pytorch\npip install -e .\n```\n\n## 基本使用\n\n### 1. 加载预训练模型\n只需一行代码即可加载在 ImageNet 上预训练的 ViT 模型。以下示例加载 `B_16_imagenet1k` 模型：\n\n```python\nfrom pytorch_pretrained_vit import ViT\n\n# 加载预训练模型\nmodel = ViT('B_16_imagenet1k', pretrained=True)\nmodel.eval()  # 设置为评估模式\n```\n\n**可用模型列表**：\n| 模型名称 | 预训练数据集 | 微调数据集 | 状态 |\n| :--- | :--- | :--- | :--- |\n| `B_16_imagenet1k` | ImageNet-21k | ImageNet-1k | ✅ 可用 |\n| `B_32_imagenet1k` | ImageNet-21k | ImageNet-1k | ✅ 可用 |\n| `L_16_imagenet1k` | ImageNet-21k | ImageNet-1k | ✅ 可用 |\n| `L_32_imagenet1k` | ImageNet-21k | ImageNet-1k | ✅ 可用 |\n| `B_16` \u002F `B_32` | ImageNet-21k | - | ✅ 可用 |\n\n### 2. 图像分类示例\n以下是一个完整的图像分类流程，包含图像预处理和推理：\n\n```python\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\nfrom pytorch_pretrained_vit import ViT\n\n# 1. 加载模型\nmodel = ViT('B_16_imagenet1k', pretrained=True)\nmodel.eval()\n\n# 2. 图像预处理\n# 注意：ViT 通常需要调整图像大小至固定分辨率 (如 384x384)\nimg_path = 'img.jpg'  # 替换为你的图片路径\ntransform = transforms.Compose([\n    transforms.Resize((384, 384)), \n    transforms.ToTensor(),\n    transforms.Normalize(0.5, 0.5), # 归一化\n])\n\nimg = transform(Image.open(img_path)).unsqueeze(0) # 增加 batch 维度\nprint(f\"输入张量形状：{img.shape}\") # 输出：torch.Size([1, 3, 384, 384])\n\n# 3. 执行推理\nwith torch.no_grad():\n    outputs = model(img)\n\nprint(f\"输出 logits 形状：{outputs.shape}\") # 输出：(1, 1000)，对应 1000 个类别\n```\n\n### 3. 自定义模型配置\n如果需要从头构建特定结构的 ViT，可以使用 `from_config` 方法：\n\n```python\nfrom pytorch_pretrained_vit import ViT\n\n# 定义自定义配置 (等价于 ViT('B_16'))\nconfig = dict(hidden_size=512, num_heads=8, num_layers=6)\nmodel = ViT.from_config(config)\n```","某医疗影像初创公司的算法团队正致力于开发一套自动识别皮肤癌病变的辅助诊断系统，急需在有限的数据集上快速构建高精度的图像分类模型。\n\n### 没有 PyTorch-Pretrained-ViT 时\n- **复现门槛极高**：团队需手动将 Google 原始的 JAX 代码逐行翻译为 PyTorch，极易因算子差异导致架构不一致，耗费数周时间调试。\n- **训练资源受限**：ViT 架构依赖海量数据（如 ImageNet-21k）预训练才能收敛，团队缺乏千卡级算力从头训练，直接在小样本医疗数据上训练导致模型严重过拟合。\n- **迁移学习困难**：难以找到与 PyTorch 生态完美兼容的预训练权重，加载外部权重时常遇到维度不匹配或参数丢失问题，阻碍了微调流程的启动。\n- **工程集成繁琐**：缺乏标准化的模型加载接口，每次实验都需编写大量样板代码来处理图像分块（Patching）和位置编码，降低了迭代效率。\n\n### 使用 PyTorch-Pretrained-ViT 后\n- **一键加载模型**：通过 `ViT('B_16_imagenet1k', pretrained=True)` 单行代码即可载入经过 ImageNet 大规模预训练的成熟模型，立即开始业务开发。\n- **小样本高效微调**：直接利用已在通用数据集上学到的强大特征提取能力，仅需少量皮肤癌标注数据即可快速微调出高精度模型，显著缓解过拟合。\n- **架构精准对齐**：该库提供了与原始实现操作对操作（op-for-op）一致的 PyTorch 版本，确保预训练权重无损加载，保证了模型性能的可靠性。\n- **灵活扩展开发**：内置高度模块化的设计让团队能轻松替换分类头或调整超参数，专注于针对医疗场景的特殊优化，而非底层架构搭建。\n\nPyTorch-Pretrained-ViT 通过提供开箱即用的预训练 ViT 模型，将原本需要数周的基础设施搭建工作缩短至几分钟，让团队能全心聚焦于解决具体的医疗诊断难题。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Flukemelas_PyTorch-Pretrained-ViT_3fca488e.png","lukemelas","Luke Melas-Kyriazi","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Flukemelas_747d4cf3.jpg","Building @getcursor. Previously Rhodes Scholar and a PhD student at Oxford University. Always open to meeting interesting people!","Anysphere (Cursor)","San Francisco, CA",null,"https:\u002F\u002Flukemelas.github.io\u002F","https:\u002F\u002Fgithub.com\u002Flukemelas",[86,90,94],{"name":87,"color":88,"percentage":89},"Python","#3572A5",54.9,{"name":91,"color":92,"percentage":93},"Jupyter Notebook","#DA5B0B",43.1,{"name":95,"color":96,"percentage":97},"Shell","#89e051",1.9,853,127,"2026-03-22T09:05:39",1,"","未说明",{"notes":105,"python":103,"dependencies":106},"README 中未明确列出具体的操作系统、GPU、内存或 Python 版本要求。该工具通过 pip 安装（pytorch_pretrained_vit），主要依赖 PyTorch 生态。代码示例显示需要处理图像（PIL, torchvision.transforms）并加载预训练权重（如 ImageNet-21k 训练的模型），实际运行时显存和内存需求取决于所选模型大小（如 B_16, L_32 等）及输入图像分辨率。",[107,108,109],"torch","torchvision","PIL",[14,13],"2026-03-27T02:49:30.150509","2026-04-06T05:36:48.653272",[114,119,124,129,134,139],{"id":115,"question_zh":116,"answer_zh":117,"source_url":118},14010,"下载预训练模型时出现 'NoneType' object has no attribute 'group' 错误怎么办？","这通常与 PyTorch Hub 的 URL 加载功能有关。解决方法是手动下载预训练模型并加载：\n1. 从 configs.py 中找到模型下载链接并手动下载。\n2. 使用以下代码加载：\n   model = ViT('L_16_imagenet1k')\n   checkpoint = torch.load('L_16_imagenet1k.pth')\n   model.load_state_dict(checkpoint)\n\n注意：如果使用的 PyTorch 版本低于 1.5，还需将 `transformer.py` 中 `PositionWiseFeedForward` 类里的 `F.gelu` 替换为自定义函数：\ndef gelu(x):\n    return 0.5 * x * (1 + torch.tanh(math.sqrt(2 \u002F math.pi) * (x + 0.044715 * torch.pow(x, 3))))","https:\u002F\u002Fgithub.com\u002Flukemelas\u002FPyTorch-Pretrained-ViT\u002Fissues\u002F3",{"id":120,"question_zh":121,"answer_zh":122,"source_url":123},14011,"如何从模型中提取图像特征（去除最后的分类层）？","不要通过切片 `model.children()` 来移除层，这会导致维度不匹配。推荐直接使用 `del model.fc` 来删除全连接层，从而保留特征提取部分。","https:\u002F\u002Fgithub.com\u002Flukemelas\u002FPyTorch-Pretrained-ViT\u002Fissues\u002F4",{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},14012,"哪个预训练模型的性能最好？","通常情况下，模型越大、补丁（patch）越小，性能越好。对于 ImageNet 预训练模型，ViT-B\u002F16 表现最佳。","https:\u002F\u002Fgithub.com\u002Flukemelas\u002FPyTorch-Pretrained-ViT\u002Fissues\u002F2",{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},14013,"在微调预训练模型（如改变输入图像尺寸）时遇到 \"TypeError: 'tuple' object is not callable\" 错误如何解决？","这是一个已知的 Bug，发生在重新加载和调整位置嵌入（positional embeddings）大小时。该问题已在最新版本中修复。请升级库到最新版本（通过 pip install --upgrade pytorch-pretrained-vit）即可解决。","https:\u002F\u002Fgithub.com\u002Flukemelas\u002FPyTorch-Pretrained-ViT\u002Fissues\u002F1",{"id":135,"question_zh":136,"answer_zh":137,"source_url":138},14014,"运行示例脚本时遇到 \"TypeError: unsupported format string passed to Tensor.__format__\" 错误怎么办？","该错误通常与进度条打印格式有关。请参考 Issue #26 中的修复方法（通常涉及修改 ProgressMeter 类中将 Tensor 直接格式化的代码，改为先转换为数值或字符串）。","https:\u002F\u002Fgithub.com\u002Flukemelas\u002FPyTorch-Pretrained-ViT\u002Fissues\u002F31",{"id":140,"question_zh":141,"answer_zh":142,"source_url":143},14015,"项目是否支持或计划支持 MLP-Mixer 架构？","维护者曾尝试过类似 MLP-Mixer 的想法，相关代码可以在这个仓库找到：https:\u002F\u002Fgithub.com\u002Flukemelas\u002Fdo-you-even-need-attention","https:\u002F\u002Fgithub.com\u002Flukemelas\u002FPyTorch-Pretrained-ViT\u002Fissues\u002F17",[145,150],{"id":146,"version":147,"summary_zh":148,"released_at":149},80778,"0.0.2","此版本新增了使用旧序列化格式保存的预训练模型。此举修复了 `torch.hub` 中的一个 bug。","2020-11-03T22:54:49",{"id":151,"version":152,"summary_zh":82,"released_at":153},80779,"0.0.1","2020-10-30T18:47:28"]