[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-xinyu1205--recognize-anything":3,"tool-xinyu1205--recognize-anything":62},[4,18,26,35,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},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,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,2,"2026-04-10T11:39:34",[14,15,13],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":32,"last_commit_at":41,"category_tags":42,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[43,13,15,14],"插件",{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":10,"last_commit_at":50,"category_tags":51,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[52,15,13,14],"语言模型",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4292,"Deep-Live-Cam","hacksider\u002FDeep-Live-Cam","Deep-Live-Cam 是一款专注于实时换脸与视频生成的开源工具，用户仅需一张静态照片，即可通过“一键操作”实现摄像头画面的即时变脸或制作深度伪造视频。它有效解决了传统换脸技术流程繁琐、对硬件配置要求极高以及难以实时预览的痛点，让高质量的数字内容创作变得触手可及。\n\n这款工具不仅适合开发者和技术研究人员探索算法边界，更因其极简的操作逻辑（仅需三步：选脸、选摄像头、启动），广泛适用于普通用户、内容创作者、设计师及直播主播。无论是为了动画角色定制、服装展示模特替换，还是制作趣味短视频和直播互动，Deep-Live-Cam 都能提供流畅的支持。\n\n其核心技术亮点在于强大的实时处理能力，支持口型遮罩（Mouth Mask）以保留使用者原始的嘴部动作，确保表情自然精准；同时具备“人脸映射”功能，可同时对画面中的多个主体应用不同面孔。此外，项目内置了严格的内容安全过滤机制，自动拦截涉及裸露、暴力等不当素材，并倡导用户在获得授权及明确标注的前提下合规使用，体现了技术发展与伦理责任的平衡。",88924,"2026-04-06T03:28:53",[14,15,13,61],"视频",{"id":63,"github_repo":64,"name":65,"description_en":66,"description_zh":67,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":78,"owner_email":79,"owner_twitter":80,"owner_website":81,"owner_url":82,"languages":83,"stars":92,"forks":93,"last_commit_at":94,"license":95,"difficulty_score":32,"env_os":96,"env_gpu":97,"env_ram":98,"env_deps":99,"category_tags":102,"github_topics":104,"view_count":32,"oss_zip_url":80,"oss_zip_packed_at":80,"status":17,"created_at":106,"updated_at":107,"faqs":108,"releases":144},6663,"xinyu1205\u002Frecognize-anything","recognize-anything","Open-source and strong foundation image recognition models.","recognize-anything 是一个开源且强大的基础图像识别模型系列，旨在让计算机像人类一样精准地“看懂”图片内容。它主要解决了传统模型只能识别有限预设类别、难以应对未知物体或复杂场景的痛点，实现了对常见类别及多样化开放集类别的高精度识别。\n\n该工具非常适合开发者、研究人员以及需要处理大量图像数据的设计师使用。无论是构建智能相册、开发视觉搜索应用，还是进行多模态学术研究，recognize-anything 都能提供可靠的技术支持。普通用户也可通过其在线演示轻松体验给图片自动打标签的乐趣。\n\n其核心技术亮点在于推出了新一代 RAM++ 模型，不仅在零样本（zero-shot）场景下超越了现有的主流模型，还能同时处理预定义类别和未知的开放集类别。此外，项目包含的 Tag2Text 模型创新性地将图像 tagging（打标签）与 captioning（生成描述）相结合，并能与 Grounding-DINO、SAM 等定位模型联动，形成强大的视觉语义分析流水线，为深入理解图像内容提供了全新方案。","# \u003Cfont size=8> :label: Recognize Anything Model \u003C\u002Ffont>\n\nThis project aims to develop a series of open-source and strong fundamental image recognition models.\n\n[![Training Dataset](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F📦-Training%20Dataset-orange.svg)](#open_book-training-datasets)\n[![Tag List](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F🏷️-4585%20Tags-green.svg)](ram\u002Fdata\u002Fram_tag_list.txt)\n[![Web Demo](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F🤗-HuggingFace%20Space-cyan.svg)](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002FRecognize_Anything-Tag2Text)\n[![Open in Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fmhd-medfa\u002Frecognize-anything\u002Fblob\u002Fmain\u002Frecognize_anything_demo.ipynb)\n[![Open in Bohrium](https:\u002F\u002Fcdn.dp.tech\u002Fbohrium\u002Fweb\u002Fstatic\u002Fimages\u002Fopen-in-bohrium.svg)](https:\u002F\u002Fbohrium.dp.tech\u002Fnotebooks\u002F63116114759)\n\n\n- **Recognize Anything Plus Model (RAM++)** [[Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.15200)] \u003Cbr>\n\n  RAM++ is the next generation of RAM, which can **recognize any category with high accuracy**, including **both predefined common categories and diverse open-set categories**.\n\n- **Recognize Anything Model (RAM)** [[Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2306.03514)][[Demo](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002Frecognize-anything)] \u003Cbr>\n\n  RAM is an image tagging model, which can **recognize any common category with high accuracy**.\n  \n  RAM is accepted at **CVPR 2024 Multimodal Foundation Models Workshop**.\n\n- **Tag2Text (ICLR 2024)**  [[Paper](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.05657)] [[Demo](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002Frecognize-anything)]\u003Cbr>\n\n  Tag2Text is a vision-language model guided by tagging, which can **support tagging and comprehensive captioning simultaneously**.\n  \n  Tag2Text is accepted at **ICLR 2024!** See you in Vienna!\n\n\n\n\n## :bulb: Highlight\n\n### **Superior Image Recognition Capability** \n\nRAM++ outperforms existing SOTA image fundamental recognition models on common tag categories, uncommon tag categories, and  human-object interaction phrases.\n\n\u003Cp align=\"center\">\n \u003Ctable class=\"tg\">\n  \u003Ctr>\n    \u003Ctd class=\"tg-c3ow\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_7abb8f483de0.jpg\" align=\"center\" width=\"700\" >\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n   \u003Cp align=\"center\">Comparison of zero-shot image recognition performance.\u003C\u002Fp>\n\u003C\u002Fp>\n\n\n### **Strong Visual Semantic Analysis** \n\n\nWe have combined Tag2Text and RAM with localization models (Grounding-DINO and SAM) and developed a strong visual semantic analysis pipeline in the [Grounded-SAM](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything) project.\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_27d1ca05509d.jpg)\n\n\n## :sunrise: Model Zoo\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"3\" style=\"font-weight:bold;\">\nRAM++\n\u003C\u002Ffont>\u003C\u002Fsummary> \n\nRAM++ is the next generation of RAM, which can recognize any category with high accuracy, including both predefined common categories and diverse open-set categories.\n\n\n- **For Common Predefined Categoies.** RAM++ exhibits exceptional image tagging capabilities with powerful zero-shot generalization, which maintains the same capabilities as RAM.\n    \u003C!-- - RAM++ showcases impressive zero-shot performance, significantly outperforming CLIP and BLIP.\n    - RAM++ even surpasses the fully supervised manners (ML-Decoder).\n    - RAM++ exhibits competitive performance with the Google tagging API. -->\n- **For Diverse Open-set Categoires.** RAM++ achieves notably enhancements beyond CLIP and RAM.\n    \u003C!-- - RAM++ integrate the image-tags-text triplets within a unified alignment framework.\n    - RAM++ pioneer the intergation of LLM's knowledge into image tagging training. -->\n\n\n\u003Cp align=\"center\">\n \u003Ctable class=\"tg\">\n  \u003Ctr>\n    \u003Ctd class=\"tg-c3ow\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_e1a55e61db91.png\" align=\"center\" width=\"800\" >\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n  \u003Cp align=\"center\">(Green color means fully supervised learning and others means zero-shot performance.)\u003C\u002Fp>\n\u003C\u002Fp>\n\n\n\u003Cp align=\"center\">\n \u003Ctable class=\"tg\">\n  \u003Ctr>\n    \u003Ctd class=\"tg-c3ow\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_a7b415239506.jpg\" align=\"center\" width=\"800\" >\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n  \u003Cp align=\"center\">RAM++ demonstrate a significant improvement in open-set category recognition.\u003C\u002Fp>\n\u003C\u002Fp>\n\n\n\u003C\u002Fdetails>\n\n\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"3\" style=\"font-weight:bold;\">\nRAM\n\u003C\u002Ffont>\u003C\u002Fsummary>\n\n\nRAM is a strong image tagging model, which can recognize any common category with high accuracy.\n- **Strong and general.** RAM exhibits exceptional image tagging capabilities with powerful zero-shot generalization;\n    - RAM showcases impressive zero-shot performance, significantly outperforming CLIP and BLIP.\n    - RAM even surpasses the fully supervised manners (ML-Decoder).\n    - RAM exhibits competitive performance with the Google tagging API.\n- **Reproducible and affordable.** RAM requires Low reproduction cost with open-source and annotation-free dataset;\n- **Flexible and versatile.** RAM offers remarkable flexibility, catering to various application scenarios.\n\n\n\u003Cp align=\"center\">\n \u003Ctable class=\"tg\">\n  \u003Ctr>\n    \u003Ctd class=\"tg-c3ow\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_71bddbed4d53.png\" align=\"center\" width=\"800\" >\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n  \u003Cp align=\"center\">(Green color means fully supervised learning and Blue color means zero-shot performance.)\u003C\u002Fp>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n \u003Ctable class=\"tg\">\n  \u003Ctr>\n    \u003Ctd class=\"tg-c3ow\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_c2c9f0a7c5db.jpg\" align=\"center\" width=\"800\" >\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n\u003C\u002Fp>\n\nRAM significantly improves the tagging ability based on the Tag2text framework.\n- **Accuracy.** RAM utilizes a **data engine** to **generate** additional annotations and **clean** incorrect ones,  **higher accuracy** compared to Tag2Text.\n- **Scope.** RAM upgrades the number of fixed tags from  3,400+ to **[6,400+](.\u002Fram\u002Fdata\u002Fram_tag_list.txt)** (synonymous reduction to 4,500+ different semantic tags), covering **more valuable categories**.\n  Moreover, RAM is equipped with **open-set capability**, feasible to recognize tags not seen during training\n\n\n\u003C\u002Fdetails>\n\n\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"3\" style=\"font-weight:bold;\">\nTag2text\n\u003C\u002Ffont>\u003C\u002Fsummary>\n\n\nTag2Text is an efficient and controllable vision-language model with tagging guidance.\n- **Tagging.** Tag2Text recognizes **[3,400+](.\u002Fram\u002Fdata\u002Ftag2text_ori_tag_list.txt)** commonly human-used categories without manual annotations.\n- **Captioning.** Tag2Text integrates **tags information** into text generation as the **guiding elements**, resulting in **more controllable and comprehensive descriptions**. \n- **Retrieval.** Tag2Text provides **tags** as **additional visible alignment indicators** for image-text retrieval. \n\n\n\u003Cp align=\"center\">\n \u003Ctable class=\"tg\">\n  \u003Ctr>\n    \u003Ctd class=\"tg-c3ow\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_51a5ea101a5a.png\" align=\"center\" width=\"800\" >\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n    \u003Cp align=\"center\">Tag2Text generate more comprehensive captions with tagging guidance.\u003C\u002Fp>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n \u003Ctable class=\"tg\">\n  \u003Ctr>\n    \u003Ctd class=\"tg-c3ow\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_d6b5dc1f2ead.png\" align=\"center\" width=\"800\" >\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n    \u003Cp align=\"center\">Tag2Text provides tags as additional visible alignment indicators.\u003C\u002Fp>\n\u003C\u002Fp>\n\n\n\u003C\u002Fdetails>\n\n\u003C!-- ## :sparkles: Highlight Projects with other Models\n- [Tag2Text\u002FRAM with Grounded-SAM](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything) is trong and general pipeline for visual semantic analysis, which can automatically **recognize**, detect, and segment for an image!\n- [Ask-Anything](https:\u002F\u002Fgithub.com\u002FOpenGVLab\u002FAsk-Anything) is a multifunctional video question answering tool. Tag2Text provides powerful tagging and captioning capabilities as a fundamental component.\n- [Prompt-can-anything](https:\u002F\u002Fgithub.com\u002Fpositive666\u002FPrompt-Can-Anything) is a gradio web library that integrates SOTA multimodal large models, including Tag2text as the core model for graphic understanding -->\n\n\n\u003C!-- \n## :fire: News\n\n- **`2023\u002F10\u002F30`**: We release the [Recognize Anything Model Plus Model(RAM++)](), checkpoints and inference code!\n- **`2023\u002F06\u002F08`**: We release the [Recognize Anything Model (RAM) Tag2Text web demo 🤗](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002FRecognize_Anything-Tag2Text), checkpoints and inference code!\n- **`2023\u002F06\u002F07`**: We release the [Recognize Anything Model (RAM)](https:\u002F\u002Frecognize-anything.github.io\u002F), a strong image tagging model!\n- **`2023\u002F06\u002F05`**: Tag2Text is combined with [Prompt-can-anything](https:\u002F\u002Fgithub.com\u002FOpenGVLab\u002FAsk-Anything).\n- **`2023\u002F05\u002F20`**: Tag2Text is combined with [VideoChat](https:\u002F\u002Fgithub.com\u002FOpenGVLab\u002FAsk-Anything).\n- **`2023\u002F04\u002F20`**: We marry Tag2Text with with [Grounded-SAM](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything).\n- **`2023\u002F04\u002F10`**: Code and checkpoint is available Now!\n- **`2023\u002F03\u002F14`**: [Tag2Text web demo 🤗](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002FRecognize_Anything-Tag2Text) is available on Hugging Face Space!   -->\n\n\n\n\n\u003C!-- \n## :writing_hand: TODO \n\n- [x] Release checkpoints.\n- [x] Release inference code.\n- [x] Release demo and checkpoints.\n- [x] Release training codes.\n- [x] Release training datasets.\n- [ ] Release full training codes and scripts. -->\n\n\n## :open_book: Training Datasets\n\n### **Image Texts and Tags** \n\nThese annotation files come from the [Tag2Text](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.05657) and [RAM](https:\u002F\u002Frecognize-anything.github.io\u002F). Tag2Text automatically extracts image tags from image-text pairs. RAM further augments both tags and texts via an automatic data engine.\n\n\n| DataSet  | Size    | Images | Texts | Tags  |\n|----------|---------|--------|-------|-------|\n| [COCO](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fxinyu1205\u002Frecognize-anything-dataset\u002Fblob\u002Fmain\u002Fcoco_train_rmcocodev_ram.json)     | 168 MB  | 113K   | 680K  | 3.2M  |\n| [VG](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fxinyu1205\u002Frecognize-anything-dataset\u002Fblob\u002Fmain\u002Fvg_ram.json)       | 55 MB   | 100K   | 923K  | 2.7M  |\n| [SBU](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fxinyu1205\u002Frecognize-anything-dataset\u002Fblob\u002Fmain\u002Fsbu_ram.json)      | 234 MB  | 849K   | 1.7M  | 7.6M  |\n| [CC3M](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fxinyu1205\u002Frecognize-anything-dataset\u002Fblob\u002Fmain\u002Fcc3m_train_ram.json)     | 766 MB  | 2.8M   | 5.6M  | 28.2M |\n| [CC3M-val](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fxinyu1205\u002Frecognize-anything-dataset\u002Fblob\u002Fmain\u002Fcc3m_val_ram.json) | 3.5 MB  | 12K    | 26K   | 132K  |\n\nCC12M to be released in the next update.\n\n### **LLM Tag Descriptions** \n\nThese tag descriptions files come from the [RAM++](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.15200) by calling GPT api. You can also customize any tag categories by [generate_tag_des_llm.py](generate_tag_des_llm.py).\n\n| Tag Descriptions    | Tag List |\n|---------------------|----------|\n| [RAM Tag List](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fxinyu1205\u002Frecognize-anything-plus-model-tag-descriptions\u002Fblob\u002Fmain\u002Fram_tag_list_4585_llm_tag_descriptions.json)        | [4,585](ram\u002Fdata\u002Fram_tag_list.txt)    |\n| [OpenImages Uncommon](.\u002Fdatasets\u002Fopenimages_rare_200\u002Fopenimages_rare_200_llm_tag_descriptions.json) | [200](datasets\u002Fopenimages_rare_200\u002Fopenimages_rare_200_ram_taglist.txt)      |\n\n## :toolbox: Checkpoints\nNote : you need to create 'pretrained' folder and download these checkpoints into this folder.\n\u003C!-- insert a table -->\n\u003Ctable>\n  \u003Cthead>\n    \u003Ctr style=\"text-align: right;\">\n      \u003Cth>\u003C\u002Fth>\n      \u003Cth>Name\u003C\u002Fth>\n      \u003Cth>Backbone\u003C\u002Fth>\n      \u003Cth>Data\u003C\u002Fth>\n      \u003Cth>Illustration\u003C\u002Fth>\n      \u003Cth>Checkpoint\u003C\u002Fth>\n    \u003C\u002Ftr>\n  \u003C\u002Fthead>\n  \u003Ctbody>\n    \u003Ctr>\n      \u003Cth>1\u003C\u002Fth>\n      \u003Ctd>RAM++ (14M)\u003C\u002Ftd>\n      \u003Ctd>Swin-Large\u003C\u002Ftd>\n      \u003Ctd>COCO, VG, SBU, CC3M, CC3M-val, CC12M\u003C\u002Ftd>\n      \u003Ctd>Provide strong image tagging ability for any category.\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fxinyu1205\u002Frecognize-anything-plus-model\u002Fblob\u002Fmain\u002Fram_plus_swin_large_14m.pth\">Download  link\u003C\u002Fa>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>2\u003C\u002Fth>\n      \u003Ctd>RAM (14M)\u003C\u002Ftd>\n      \u003Ctd>Swin-Large\u003C\u002Ftd>\n      \u003Ctd>COCO, VG, SBU, CC3M, CC3M-val, CC12M\u003C\u002Ftd>\n      \u003Ctd>Provide strong image tagging ability for common category.\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002FRecognize_Anything-Tag2Text\u002Fblob\u002Fmain\u002Fram_swin_large_14m.pth\">Download  link\u003C\u002Fa>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>3\u003C\u002Fth>\n      \u003Ctd>Tag2Text (14M)\u003C\u002Ftd>\n      \u003Ctd>Swin-Base\u003C\u002Ftd>\n      \u003Ctd>COCO, VG, SBU, CC3M, CC3M-val, CC12M\u003C\u002Ftd>\n      \u003Ctd>Support comprehensive captioning and tagging.\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002FRecognize_Anything-Tag2Text\u002Fblob\u002Fmain\u002Ftag2text_swin_14m.pth\">Download  link\u003C\u002Fa>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n  \u003C\u002Ftbody>\n\u003C\u002Ftable>\n\n\n## :running: Model Inference\n\n### **Setting Up** ###\n\n1. Create and activate a Conda environment:\n\n```bash\nconda create -n recognize-anything python=3.8 -y\nconda activate recognize-anything\n```\n\n2. Install `recognize-anything` as a package:\n\n```bash\npip install git+https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything.git\n```\n\n3. Or, for development, you may build from source:\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything.git\ncd recognize-anything\npip install -e .\n```\n\nThen the RAM++, RAM, and Tag2Text models can be imported in other projects:\n\n```python\nfrom ram.models import ram_plus, ram, tag2text\n```\n\n### **RAM++ Inference** ###\n\nGet the English and Chinese outputs of the images:\n\n```bash\npython inference_ram_plus.py --image images\u002Fdemo\u002Fdemo1.jpg --pretrained pretrained\u002Fram_plus_swin_large_14m.pth\n```\n\n\nThe output will look like the following:\n\n```\nImage Tags:  armchair | blanket | lamp | carpet | couch | dog | gray | green | hassock | home | lay | living room | picture frame | pillow | plant | room | wall lamp | sit | wood floor\n图像标签:  扶手椅  | 毯子\u002F覆盖层 | 灯  | 地毯  | 沙发 | 狗 | 灰色 | 绿色  | 坐垫\u002F搁脚凳\u002F草丛 | 家\u002F住宅 | 躺  | 客厅  | 相框  | 枕头  | 植物  | 房间  | 壁灯  | 坐\u002F放置\u002F坐落 | 木地板\n```\n\n### **RAM++ Inference on Unseen Categories (Open-Set)** ##\n\n1. Get the [OpenImages-Uncommon categories](.\u002Fdatasets\u002Fopenimages_rare_200\u002Fopenimages_rare_200_ram_taglist.txt) of the image:\n\nWe have released the LLM tag descriptions of OpenImages-Uncommon categories in [openimages_rare_200_llm_tag_descriptions](.\u002Fdatasets\u002Fopenimages_rare_200\u002F).\n\n\u003Cpre\u002F>\npython inference_ram_plus_openset.py  --image images\u002Fopenset_example.jpg \\\n--pretrained pretrained\u002Fram_plus_swin_large_14m.pth \\\n--llm_tag_des datasets\u002Fopenimages_rare_200\u002Fopenimages_rare_200_llm_tag_descriptions.json\n\u003C\u002Fpre>\n\nThe output will look like the following:\n```\nImage Tags: Close-up | Compact car | Go-kart | Horse racing | Sport utility vehicle | Touring car\n```\n\n2. You can also customize any tag categories for recognition through tag descriptions:\n\nModify [categories](.\u002Fgenerate_tag_des_llm.py#L56), and call GPT api to generate corresponding tag descriptions:\n\n\u003Cpre\u002F>\npython generate_tag_des_llm.py \\\n--openai_api_key 'your openai api key' \\\n--output_file_path datasets\u002Fopenimages_rare_200\u002Fopenimages_rare_200_llm_tag_descriptions.json\n\u003C\u002Fpre>\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"4\" style=\"font-weight:bold;\">\nRAM Inference\n\u003C\u002Ffont>\u003C\u002Fsummary>\n\nGet the English and Chinese outputs of the images:\n\n\u003Cpre\u002F>\npython inference_ram.py  --image images\u002Fdemo\u002Fdemo1.jpg \\\n--pretrained pretrained\u002Fram_swin_large_14m.pth\n\u003C\u002Fpre>\n\nThe output will look like the following:\n\n```\nImage Tags:  armchair | blanket | lamp | carpet | couch | dog | floor | furniture | gray | green | living room | picture frame | pillow | plant | room | sit | stool | wood floor\n图像标签:  扶手椅  | 毯子\u002F覆盖层 | 灯  | 地毯  | 沙发 | 狗 | 地板\u002F地面 | 家具  | 灰色 | 绿色  | 客厅  | 相框  | 枕头  | 植物  | 房间  | 坐\u002F放置\u002F坐落 | 凳子  | 木地板 \n```\n\n\u003C\u002Fdetails>\n\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"4\" style=\"font-weight:bold;\">\nRAM Inference on Unseen Categories (Open-Set)\n\u003C\u002Ffont>\u003C\u002Fsummary>\n\n\nFirstly, custom recognition categories in [build_openset_label_embedding](.\u002Fram\u002Futils\u002Fopenset_utils.py), then get the tags of the images:\n\n\u003Cpre\u002F>\npython inference_ram_openset.py  --image images\u002Fopenset_example.jpg \\\n--pretrained pretrained\u002Fram_swin_large_14m.pth\n\u003C\u002Fpre>\n\nThe output will look like the following:\n```\nImage Tags: Black-and-white | Go-kart\n```\n\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"4\" style=\"font-weight:bold;\">\nTag2Text Inference\n\u003C\u002Ffont>\u003C\u002Fsummary>\n\n\nGet the tagging and captioning results:\n\u003Cpre\u002F>\npython inference_tag2text.py  --image images\u002Fdemo\u002Fdemo1.jpg \\\n--pretrained pretrained\u002Ftag2text_swin_14m.pth\n\u003C\u002Fpre>\nOr get the tagging and sepcifed captioning results (optional):\n\u003Cpre\u002F>python inference_tag2text.py  --image images\u002Fdemo\u002Fdemo1.jpg \\\n--pretrained pretrained\u002Ftag2text_swin_14m.pth \\\n--specified-tags \"cloud,sky\"\u003C\u002Fpre>\n\n\u003C\u002Fdetails>\n\n### **Batch Inference and Evaluation** ##\nWe release two datasets `OpenImages-common` (214 common tag classes) and `OpenImages-rare` (200 uncommon tag classes). Copy or sym-link test images of [OpenImages v6](https:\u002F\u002Fstorage.googleapis.com\u002Fopenimages\u002Fweb\u002Fdownload_v6.html) to `datasets\u002Fopenimages_common_214\u002Fimgs\u002F` and `datasets\u002Fopenimages_rare_200\u002Fimgs`.\n\nTo evaluate RAM++ on `OpenImages-common`:\n\n```bash\npython batch_inference.py \\\n  --model-type ram_plus \\\n  --checkpoint pretrained\u002Fram_plus_swin_large_14m.pth \\\n  --dataset openimages_common_214 \\\n  --output-dir outputs\u002Fram_plus\n```\n\nTo evaluate RAM++ open-set capability on `OpenImages-rare`:\n\n```bash\npython batch_inference.py \\\n  --model-type ram_plus \\\n  -- pretrained\u002Fram_plus_swin_large_14m.pth \\\n  --open-set \\\n  --dataset openimages_rare_200 \\\n  --output-dir outputs\u002Fram_plus_openset\n```\n\nTo evaluate RAM on `OpenImages-common`:\n\n```bash\npython batch_inference.py \\\n  --model-type ram \\\n  -- pretrained\u002Fram_swin_large_14m.pth \\\n  --dataset openimages_common_214 \\\n  --output-dir outputs\u002Fram\n```\n\nTo evaluate RAM open-set capability on `OpenImages-rare`:\n\n```bash\npython batch_inference.py \\\n  --model-type ram \\\n  -- pretrained\u002Fram_swin_large_14m.pth \\\n  --open-set \\\n  --dataset openimages_rare_200 \\\n  --output-dir outputs\u002Fram_openset\n```\n\nTo evaluate Tag2Text on `OpenImages-common`:\n\n```bash\npython batch_inference.py \\\n  --model-type tag2text \\\n  -- pretrained\u002Ftag2text_swin_14m.pth \\\n  --dataset openimages_common_214 \\\n  --output-dir outputs\u002Ftag2text\n```\n\nPlease refer to `batch_inference.py` for more options. To get P\u002FR in table 3 of RAM paper, pass `--threshold=0.86` for RAM and `--threshold=0.68` for Tag2Text.\n\nTo batch inference custom images, you can set up you own datasets following the given two datasets.\n\n\n## :golfing: Model Training\u002FFinetuning\n\n### **RAM++** ##\n\n1. Download [RAM training datasets](#open_book-training-datasets) where each json file contains a list. Each item in the list is a dictonary with three key-value pairs: {'image_path': path_of_image, 'caption': text_of_image, 'union_label_id': image tags for tagging which including parsed tags and pseudo tags }.\n\n2. In ram\u002Fconfigs\u002Fpretrain.yaml, set 'train_file' as the paths for the json files.\n\n3. Prepare [pretained Swin-Transformer](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FSwin-Transformer), and set 'ckpt' in ram\u002Fconfigs\u002Fswin.\n\n4. Download RAM++ frozen tag embedding file \"[ram_plus_tag_embedding_class_4585_des_51.pth](https:\u002F\u002Fhuggingface.co\u002Fxinyu1205\u002Frecognize-anything-plus-model\u002Fblob\u002Fmain\u002Fram_plus_tag_embedding_class_4585_des_51.pth)\", and set file in \"ram\u002Fdata\u002Ffrozen_tag_embedding\u002Fram_plus_tag_embedding_class_4585_des_51.pth\"\n\n5. Pre-train the model using 8 A100 GPUs:\n\n```bash\npython -m torch.distributed.run --nproc_per_node=8 pretrain.py \\\n  --model-type ram_plus \\\n  --config ram\u002Fconfigs\u002Fpretrain.yaml  \\\n  --output-dir outputs\u002Fram_plus\n```\n\n6. Fine-tune the pre-trained checkpoint using 8 A100 GPUs:\n\n```bash\npython -m torch.distributed.run --nproc_per_node=8 finetune.py \\\n  --model-type ram_plus \\\n  --config ram\u002Fconfigs\u002Ffinetune.yaml  \\\n  --checkpoint outputs\u002Fram_plus\u002Fcheckpoint_04.pth \\\n  --output-dir outputs\u002Fram_plus_ft\n```\n\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"4\" style=\"font-weight:bold;\">\nRAM \n\u003C\u002Ffont>\u003C\u002Fsummary>\n\n1. Download [RAM training datasets](#open_book-training-datasets) where each json file contains a list. Each item in the list is a dictonary with four key-value pairs: {'image_path': path_of_image, 'caption': text_of_image, 'union_label_id': image tags for tagging which including parsed tags and pseudo tags, 'parse_label_id': image tags parsed from caption }.\n\n2. In ram\u002Fconfigs\u002Fpretrain.yaml, set 'train_file' as the paths for the json files.\n\n3. Prepare [pretained Swin-Transformer](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FSwin-Transformer), and set 'ckpt' in ram\u002Fconfigs\u002Fswin.\n\n4. Download RAM frozen tag embedding file \"[ram_tag_embedding_class_4585.pth](https:\u002F\u002Fhuggingface.co\u002Fxinyu1205\u002Frecognize_anything_model\u002Fblob\u002Fmain\u002Fram_tag_embedding_class_4585.pth)\", and set file in \"ram\u002Fdata\u002Ffrozen_tag_embedding\u002Fram_tag_embedding_class_4585.pth\"\n\n5. Pre-train the model using 8 A100 GPUs:\n\n```bash\npython -m torch.distributed.run --nproc_per_node=8 pretrain.py \\\n  --model-type ram \\\n  --config ram\u002Fconfigs\u002Fpretrain.yaml  \\\n  --output-dir outputs\u002Fram\n```\n\n6. Fine-tune the pre-trained checkpoint using 8 A100 GPUs:\n\n```bash\npython -m torch.distributed.run --nproc_per_node=8 finetune.py \\\n  --model-type ram \\\n  --config ram\u002Fconfigs\u002Ffinetune.yaml  \\\n  --checkpoint outputs\u002Fram\u002Fcheckpoint_04.pth \\\n  --output-dir outputs\u002Fram_ft\n```\n\n\u003C\u002Fdetails>\n\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"4\" style=\"font-weight:bold;\">\nTag2Text \n\u003C\u002Ffont>\u003C\u002Fsummary>\n\n1. Download [RAM training datasets](#open_book-training-datasets) where each json file contains a list. Each item in the list is a dictonary with three key-value pairs: {'image_path': path_of_image, 'caption': text_of_image, 'parse_label_id': image tags parsed from caption }.\n\n2. In ram\u002Fconfigs\u002Fpretrain_tag2text.yaml, set 'train_file' as the paths for the json files.\n\n3. Prepare [pretained Swin-Transformer](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FSwin-Transformer), and set 'ckpt' in ram\u002Fconfigs\u002Fswin.\n\n4. Pre-train the model using 8 A100 GPUs:\n\n```bash\npython -m torch.distributed.run --nproc_per_node=8 pretrain.py \\\n  --model-type tag2text \\\n  --config ram\u002Fconfigs\u002Fpretrain_tag2text.yaml  \\\n  --output-dir outputs\u002Ftag2text\n```\n\n5. Fine-tune the pre-trained checkpoint using 8 A100 GPUs:\n\n```bash\npython -m torch.distributed.run --nproc_per_node=8 finetune.py \\\n  --model-type tag2text \\\n  --config ram\u002Fconfigs\u002Ffinetune_tag2text.yaml  \\\n  --checkpoint outputs\u002Ftag2text\u002Fcheckpoint_04.pth \\\n  --output-dir outputs\u002Ftag2text_ft\n```\n\n\u003C\u002Fdetails>\n\n\n## :black_nib: Citation\nIf you find our work to be useful for your research, please consider citing.\n\n```\n@article{huang2023open,\n  title={Open-Set Image Tagging with Multi-Grained Text Supervision},\n  author={Huang, Xinyu and Huang, Yi-Jie and Zhang, Youcai and Tian, Weiwei and Feng, Rui and Zhang, Yuejie and Xie, Yanchun and Li, Yaqian and Zhang, Lei},\n  journal={arXiv e-prints},\n  pages={arXiv--2310},\n  year={2023}\n}\n\n@article{zhang2023recognize,\n  title={Recognize Anything: A Strong Image Tagging Model},\n  author={Zhang, Youcai and Huang, Xinyu and Ma, Jinyu and Li, Zhaoyang and Luo, Zhaochuan and Xie, Yanchun and Qin, Yuzhuo and Luo, Tong and Li, Yaqian and Liu, Shilong and others},\n  journal={arXiv preprint arXiv:2306.03514},\n  year={2023}\n}\n\n@article{huang2023tag2text,\n  title={Tag2Text: Guiding Vision-Language Model via Image Tagging},\n  author={Huang, Xinyu and Zhang, Youcai and Ma, Jinyu and Tian, Weiwei and Feng, Rui and Zhang, Yuejie and Li, Yaqian and Guo, Yandong and Zhang, Lei},\n  journal={arXiv preprint arXiv:2303.05657},\n  year={2023}\n}\n```\n\n## :hearts: Acknowledgements\nThis work is done with the help of the amazing code base of [BLIP](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FBLIP), thanks very much!\n\nWe want to thank @Cheng Rui @Shilong Liu @Ren Tianhe for their help in [marrying RAM\u002FTag2Text with Grounded-SAM](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything).\n\nWe also want to thank [Ask-Anything](https:\u002F\u002Fgithub.com\u002FOpenGVLab\u002FAsk-Anything), [Prompt-can-anything](https:\u002F\u002Fgithub.com\u002Fpositive666\u002FPrompt-Can-Anything) for  combining RAM\u002FTag2Text, which greatly expands the application boundaries of RAM\u002FTag2Text.\n","# \u003Cfont size=8> :label: 识别任何事物模型 \u003C\u002Ffont>\n\n本项目旨在开发一系列开源且强大的基础图像识别模型。\n\n[![训练数据集](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F📦-Training%20Dataset-orange.svg)](#open_book-training-datasets)\n[![标签列表](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F🏷️-4585%20Tags-green.svg)](ram\u002Fdata\u002Fram_tag_list.txt)\n[![Web演示](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F🤗-HuggingFace%20Space-cyan.svg)](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002FRecognize_Anything-Tag2Text)\n[![在Colab中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fmhd-medfa\u002Frecognize-anything\u002Fblob\u002Fmain\u002Frecognize_anything_demo.ipynb)\n[![在Bohrium中打开](https:\u002F\u002Fcdn.dp.tech\u002Fbohrium\u002Fweb\u002Fstatic\u002Fimages\u002Fopen-in-bohrium.svg)](https:\u002F\u002Fbohrium.dp.tech\u002Fnotebooks\u002F63116114759)\n\n\n- **识别任何事物增强版模型（RAM++）** [[论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.15200)] \u003Cbr>\n\n  RAM++ 是 RAM 的下一代模型，能够以高精度识别任意类别，包括预定义的常见类别和多样化的开放集类别。\n\n- **识别任何事物模型（RAM）** [[论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2306.03514)][[演示](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002Frecognize-anything)] \u003Cbr>\n\n  RAM 是一个图像标注模型，能够以高精度识别任何常见类别。\n  \n  RAM 已被 **CVPR 2024 多模态基础模型研讨会** 接受。\n\n- **Tag2Text（ICLR 2024）** [[论文](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.05657)][[演示](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002Frecognize-anything)]\u003Cbr>\n\n  Tag2Text 是一种由标注引导的视觉语言模型，能够同时支持标注和全面的图文描述。\n  \n  Tag2Text 已被 **ICLR 2024** 接受！维也纳见！\n\n\n\n## :bulb: 亮点\n\n### **卓越的图像识别能力** \n\nRAM++ 在常见标签类别、不常见标签类别以及人与物体交互短语方面，均优于现有的最先进基础图像识别模型。\n\n\u003Cp align=\"center\">\n \u003Ctable class=\"tg\">\n  \u003Ctr>\n    \u003Ctd class=\"tg-c3ow\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_7abb8f483de0.jpg\" align=\"center\" width=\"700\" >\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n   \u003Cp align=\"center\">零样本图像识别性能对比。\u003C\u002Fp>\n\u003C\u002Fp>\n\n\n### **强大的视觉语义分析能力** \n\n\n我们已将 Tag2Text 和 RAM 与定位模型（Grounding-DINO 和 SAM）相结合，在 [Grounded-SAM](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything) 项目中开发出一套强大的视觉语义分析流水线。\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_27d1ca05509d.jpg)\n\n## :sunrise: 模型动物园\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"3\" style=\"font-weight:bold;\">\nRAM++\n\u003C\u002Ffont>\u003C\u002Fsummary> \n\nRAM++ 是 RAM 的下一代版本，能够以高精度识别任何类别，包括预定义的常见类别以及多样化的开放集类别。\n\n\n- **针对常见预定义类别。** RAM++ 具备强大的零样本泛化能力，展现出卓越的图像标注能力，其性能与 RAM 保持一致。\n    \u003C!-- - RAM++ 展现出令人印象深刻的零样本性能，显著优于 CLIP 和 BLIP。\n    - RAM++ 甚至超越了完全监督的方法（ML-Decoder）。\n    - RAM++ 的性能与 Google 标注 API 相当。 -->\n- **针对多样化的开放集类别。** RAM++ 在 CLIP 和 RAM 的基础上实现了显著提升。\n    \u003C!-- - RAM++ 将图像、标签和文本三元组整合进统一的对齐框架中。\n    - RAM++ 首次将大型语言模型的知识融入图像标注训练中。 -->\n\n\n\u003Cp align=\"center\">\n \u003Ctable class=\"tg\">\n  \u003Ctr>\n    \u003Ctd class=\"tg-c3ow\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_e1a55e61db91.png\" align=\"center\" width=\"800\" >\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n  \u003Cp align=\"center\">(绿色表示完全监督学习，其他颜色表示零样本性能。)\u003C\u002Fp>\n\u003C\u002Fp>\n\n\n\u003Cp align=\"center\">\n \u003Ctable class=\"tg\">\n  \u003Ctr>\n    \u003Ctd class=\"tg-c3ow\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_a7b415239506.jpg\" align=\"center\" width=\"800\" >\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n  \u003Cp align=\"center\">RAM++ 在开放集类别识别方面表现出显著提升。\u003C\u002Fp>\n\u003C\u002Fp>\n\n\n\u003C\u002Fdetails\n\n\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"3\" style=\"font-weight:bold;\">\nRAM\n\u003C\u002Ffont>\u003C\u002Fsummary>\n\n\nRAM 是一款强大的图像标注模型，能够以高精度识别任何常见类别。\n- **强大且通用。** RAM 具备出色的零样本泛化能力；\n    - RAM 展现出令人印象深刻的零样本性能，显著优于 CLIP 和 BLIP。\n    - RAM 甚至超越了完全监督的方法（ML-Decoder）。\n    - RAM 的性能与 Google 标注 API 相当。\n- **可复现且经济实惠。** RAM 使用开源且无需标注的数据集，复现成本较低；\n- **灵活且多功能。** RAM 具有极高的灵活性，适用于多种应用场景。\n\n\n\u003Cp align=\"center\">\n \u003Ctable class=\"tg\">\n  \u003Ctr>\n    \u003Ctd class=\"tg-c3ow\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_71bddbed4d53.png\" align=\"center\" width=\"800\" >\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n  \u003Cp align=\"center\">(绿色表示完全监督学习，蓝色表示零样本性能。)\u003C\u002Fp>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n \u003Ctable class=\"tg\">\n  \u003Ctr>\n    \u003Ctd class=\"tg-c3ow\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_c2c9f0a7c5db.jpg\" align=\"center\" width=\"800\" >\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n\u003C\u002Fp>\n\nRAM 在 Tag2text 框架的基础上显著提升了标注能力。\n- **准确性。** RAM 利用**数据引擎**生成额外的标注并清理错误标注，相比 Tag2Text 准确性更高。\n- **覆盖范围。** RAM 将固定标签的数量从 3,400 多个提升至 **[6,400+](.\u002Fram\u002Fdata\u002Fram_tag_list.txt)** 个（经过同义词归并后为 4,500 多个不同的语义标签），覆盖了更多有价值的类别。\n此外，RAM 还具备**开放集能力**，能够识别训练过程中未出现过的标签。\n\n\n\u003C\u002Fdetails\n\n\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"3\" style=\"font-weight:bold;\">\nTag2text\n\u003C\u002Ffont>\u003C\u002Fsummary>\n\n\nTag2Text 是一个高效且可控的视觉-语言模型，具有标注引导功能。\n- **标注。** Tag2Text 能够识别 **[3,400+](.\u002Fram\u002Fdata\u002Ftag2text_ori_tag_list.txt)** 种人类常用类别，无需人工标注。\n- **描述生成。** Tag2Text 将**标签信息**作为**引导元素**融入文本生成中，从而产生**更可控、更全面的描述**。\n- **检索。** Tag2Text 提供**标签**作为**额外的可见对齐指标**，用于图像-文本检索。\n\n\n\u003Cp align=\"center\">\n \u003Ctable class=\"tg\">\n  \u003Ctr>\n    \u003Ctd class=\"tg-c3ow\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_51a5ea101a5a.png\" align=\"center\" width=\"800\" >\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n    \u003Cp align=\"center\">Tag2Text 在标注引导下生成更全面的描述。\u003C\u002Fp>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n \u003Ctable class=\"tg\">\n  \u003Ctr>\n    \u003Ctd class=\"tg-c3ow\">\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_readme_d6b5dc1f2ead.png\" align=\"center\" width=\"800\" >\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n    \u003Cp align=\"center\">Tag2Text 提供标签作为额外的可见对齐指标。\u003C\u002Fp>\n\u003C\u002Fp>\n\n\n\u003C\u002Fdetails\n\n\u003C!-- ## :sparkles: 精选项目与其他模型\n- [Tag2Text\u002FRAM 与 Grounded-SAM](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything) 是一个强大而通用的视觉语义分析流水线，可以自动对图像进行**识别**、检测和分割！\n- [Ask-Anything](https:\u002F\u002Fgithub.com\u002FOpenGVLab\u002FAsk-Anything) 是一个多功能视频问答工具。Tag2Text 作为基础组件，提供了强大的标注和描述生成能力。\n- [Prompt-can-anything](https:\u002F\u002Fgithub.com\u002Fpositive666\u002FPrompt-Can-Anything) 是一个 Gradio Web 库，集成了 SOTA 多模态大模型，其中 Tag2Text 是图形理解的核心模型 -->\n\n\n\u003C!--\n## :fire: 新闻\n\n- **`2023\u002F10\u002F30`**: 我们发布了 [Recognize Anything Model Plus Model(RAM++)](), 包括检查点和推理代码！\n- **`2023\u002F06\u002F08`**: 我们发布了 [Recognize Anything Model (RAM) Tag2Text web demo 🤗](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002FRecognize_Anything-Tag2Text), 包括检查点和推理代码！\n- **`2023\u002F06\u002F07`**: 我们发布了 [Recognize Anything Model (RAM)](https:\u002F\u002Frecognize-anything.github.io\u002F), 一款强大的图像标注模型！\n- **`2023\u002F06\u002F05`**: Tag2Text 与 [Prompt-can-anything](https:\u002F\u002Fgithub.com\u002FOpenGVLab\u002FAsk-Anything) 结合使用。\n- **`2023\u002F05\u002F20`**: Tag2Text 与 [VideoChat](https:\u002F\u002Fgithub.com\u002FOpenGVLab\u002FAsk-Anything) 结合使用。\n- **`2023\u002F04\u002F20`**: Tag2Text 与 [Grounded-SAM](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything) 结合使用。\n- **`2023\u002F04\u002F10`**: 代码和检查点现已可用！\n- **`2023\u002F03\u002F14`**: [Tag2Text web demo 🤗](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002FRecognize_Anything-Tag2Text) 已在 Hugging Face Space 上发布！   -->\n\n\n\n\n\u003C!--\n## :writing_hand: 待办事项 \n\n- [x] 发布检查点。\n- [x] 发布推理代码。\n- [x] 发布演示和检查点。\n- [x] 发布训练代码。\n- [x] 发布训练数据集。\n- [ ] 发布完整的训练代码和脚本。 -->\n\n\n## :open_book: 训练数据集\n\n### **图像文本与标签** \n\n这些标注文件来自 [Tag2Text](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.05657) 和 [RAM](https:\u002F\u002Frecognize-anything.github.io\u002F)。Tag2Text 会自动从图像-文本对中提取图像标签。而 RAM 则通过自动化数据引擎进一步扩充标签和文本内容。\n\n\n| 数据集  | 大小    | 图像 | 文本 | 标签  |\n|----------|---------|--------|-------|-------|\n| [COCO](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fxinyu1205\u002Frecognize-anything-dataset\u002Fblob\u002Fmain\u002Fcoco_train_rmcocodev_ram.json)     | 168 MB  | 113K   | 680K  | 3.2M  |\n| [VG](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fxinyu1205\u002Frecognize-anything-dataset\u002Fblob\u002Fmain\u002Fvg_ram.json)       | 55 MB   | 100K   | 923K  | 2.7M  |\n| [SBU](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fxinyu1205\u002Frecognize-anything-dataset\u002Fblob\u002Fmain\u002Fsbu_ram.json)      | 234 MB  | 849K   | 1.7M  | 7.6M  |\n| [CC3M](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fxinyu1205\u002Frecognize-anything-dataset\u002Fblob\u002Fmain\u002Fcc3m_train_ram.json)     | 766 MB  | 2.8M   | 5.6M  | 28.2M |\n| [CC3M-val](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fxinyu1205\u002Frecognize-anything-dataset\u002Fblob\u002Fmain\u002Fcc3m_val_ram.json) | 3.5 MB  | 12K    | 26K   | 132K  |\n\nCC12M 将在下一次更新中发布。\n\n### **LLM 标签描述** \n\n这些标签描述文件来自 [RAM++](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.15200)，通过调用 GPT API 生成。您也可以使用 [generate_tag_des_llm.py](generate_tag_des_llm.py) 自定义任何标签类别。\n\n| 标签描述    | 标签列表 |\n|---------------------|----------|\n| [RAM 标签列表](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fxinyu1205\u002Frecognize-anything-plus-model-tag-descriptions\u002Fblob\u002Fmain\u002Fram_tag_list_4585_llm_tag_descriptions.json)        | [4,585](ram\u002Fdata\u002Fram_tag_list.txt)    |\n| [OpenImages 罕见标签](.\u002Fdatasets\u002Fopenimages_rare_200\u002Fopenimages_rare_200_llm_tag_descriptions.json) | [200](datasets\u002Fopenimages_rare_200\u002Fopenimages_rare_200_ram_taglist.txt)      |\n\n## :toolbox: 检查点\n注意：您需要创建一个名为 'pretrained' 的文件夹，并将这些检查点下载到该文件夹中。\n\u003C!-- 插入表格 -->\n\u003Ctable>\n  \u003Cthead>\n    \u003Ctr style=\"text-align: right;\">\n      \u003Cth>\u003C\u002Fth>\n      \u003Cth>名称\u003C\u002Fth>\n      \u003Cth>骨干网络\u003C\u002Fth>\n      \u003Cth>数据集\u003C\u002Fth>\n      \u003Cth>说明\u003C\u002Fth>\n      \u003Cth>检查点\u003C\u002Fth>\n    \u003C\u002Ftr>\n  \u003C\u002Fthead>\n  \u003Ctbody>\n    \u003Ctr>\n      \u003Cth>1\u003C\u002Fth>\n      \u003Ctd>RAM++ (14M)\u003C\u002Ftd>\n      \u003Ctd>Swin-Large\u003C\u002Ftd>\n      \u003Ctd>COCO、VG、SBU、CC3M、CC3M-val、CC12M\u003C\u002Ftd>\n      \u003Ctd>为任意类别提供强大的图像标注能力。\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fxinyu1205\u002Frecognize-anything-plus-model\u002Fblob\u002Fmain\u002Fram_plus_swin_large_14m.pth\">下载链接\u003C\u002Fa>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>2\u003C\u002Fth>\n      \u003Ctd>RAM (14M)\u003C\u002Ftd>\n      \u003Ctd>Swin-Large\u003C\u002Ftd>\n      \u003Ctd>COCO、VG、SBU、CC3M、CC3M-val、CC12M\u003C\u002Ftd>\n      \u003Ctd>为常见类别提供强大的图像标注能力。\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002FRecognize_Anything-Tag2Text\u002Fblob\u002Fmain\u002Fram_swin_large_14m.pth\">下载链接\u003C\u002Fa>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n    \u003Ctr>\n      \u003Cth>3\u003C\u002Fth>\n      \u003Ctd>Tag2Text (14M)\u003C\u002Ftd>\n      \u003Ctd>Swin-Base\u003C\u002Ftd>\n      \u003Ctd>COCO、VG、SBU、CC3M、CC3M-val、CC12M\u003C\u002Ftd>\n      \u003Ctd>支持全面的图像描述与标注。\u003C\u002Ftd>\n      \u003Ctd>\u003Ca href=\"https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fxinyu1205\u002FRecognize_Anything-Tag2Text\u002Fblob\u002Fmain\u002Ftag2text_swin_14m.pth\">下载链接\u003C\u002Fa>\u003C\u002Ftd>\n    \u003C\u002Ftr>\n  \u003C\u002Ftbody>\n\u003C\u002Ftable>\n\n\n## :running: 模型推理\n\n### **设置步骤** ###\n\n1. 创建并激活 Conda 环境：\n\n```bash\nconda create -n recognize-anything python=3.8 -y\nconda activate recognize-anything\n```\n\n2. 安装 `recognize-anything` 包：\n\n```bash\npip install git+https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything.git\n```\n\n3. 或者，如果您需要进行开发，可以从源代码构建：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything.git\ncd recognize-anything\npip install -e .\n```\n\n之后，您就可以在其他项目中导入 RAM++、RAM 和 Tag2Text 模型：\n\n```python\nfrom ram.models import ram_plus, ram, tag2text\n```\n\n### **RAM++ 推理** ###\n\n获取图像的英文和中文输出：\n\n```bash\npython inference_ram_plus.py --image images\u002Fdemo\u002Fdemo1.jpg --pretrained pretrained\u002Fram_plus_swin_large_14m.pth\n```\n\n\n输出将如下所示：\n\n```\nImage Tags:  armchair | blanket | lamp | carpet | couch | dog | gray | green | hassock | home | lay | living room | picture frame | pillow | plant | room | wall lamp | sit | wood floor\n图像标签:  扶手椅  | 毯子\u002F覆盖层 | 灯  | 地毯  | 沙发 | 狗 | 灰色 | 绿色  | 坐垫\u002F搁脚凳\u002F草丛 | 家\u002F住宅 | 躺  | 客厅  | 相框  | 枕头  | 植物  | 房间  | 壁灯  | 坐\u002F放置\u002F坐落 | 木地板\n```\n\n### **RAM++ 在未见类别上的推理（开放集）** ##\n\n1. 获取图像的 [OpenImages-罕见类别](.\u002Fdatasets\u002Fopenimages_rare_200\u002Fopenimages_rare_200_ram_taglist.txt)：\n\n我们已在 [openimages_rare_200_llm_tag_descriptions](.\u002Fdatasets\u002Fopenimages_rare_200\u002F) 中发布了 OpenImages-罕见类别的 LLM 标签描述。\n\n\u003Cpre\u002F>\npython inference_ram_plus_openset.py  --image images\u002Fopenset_example.jpg \\\n--pretrained pretrained\u002Fram_plus_swin_large_14m.pth \\\n--llm_tag_des datasets\u002Fopenimages_rare_200\u002Fopenimages_rare_200_llm_tag_descriptions.json\n\u003C\u002Fpre>\n\n输出将如下所示：\n```\n图像标签: 特写 | 小型车 | 卡丁车 | 赛马 | 运动型多用途车 | 跑车\n```\n\n2. 您也可以通过标签描述自定义任何要识别的类别：\n\n修改 [categories](.\u002Fgenerate_tag_des_llm.py#L56)，并调用 GPT API 生成相应的标签描述：\n\n\u003Cpre\u002F>\npython generate_tag_des_llm.py \\\n--openai_api_key '您的 OpenAI API 密钥' \\\n--output_file_path datasets\u002Fopenimages_rare_200\u002Fopenimages_rare_200_llm_tag_descriptions.json\n\u003C\u002Fpre>\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"4\" style=\"font-weight:bold;\">\nRAM 推理\n\u003C\u002Ffont>\u003C\u002Fsummary>\n\n获取图像的英文和中文输出：\n\n\u003Cpre\u002F>\npython inference_ram.py  --image images\u002Fdemo\u002Fdemo1.jpg \\\n--pretrained pretrained\u002Fram_swin_large_14m.pth\n\u003C\u002Fpre>\n\n输出将如下所示：\n\n```\n图像标签: 扶手椅 | 毯子 | 灯 | 地毯 | 沙发 | 狗 | 地板 | 家具 | 灰色 | 绿色 | 客厅 | 相框 | 枕头 | 植物 | 房间 | 坐 | 凳子 | 木地板\n图像标签: 扶手椅 | 毯子\u002F覆盖层 | 灯 | 地毯 | 沙发 | 狗 | 地板\u002F地面 | 家具 | 灰色 | 绿色 | 客厅 | 相框 | 枕头 | 植物 | 房间 | 坐\u002F放置\u002F坐落 | 凳子 | 木地板\n```\n\n\u003C\u002Fdetails>\n\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"4\" style=\"font-weight:bold;\">\nRAM 在未见类别上的推理（开放集）\n\u003C\u002Ffont>\u003C\u002Fsummary>\n\n\n首先，在 [build_openset_label_embedding](.\u002Fram\u002Futils\u002Fopenset_utils.py) 中自定义识别类别，然后获取图像的标签：\n\n\u003Cpre\u002F>\npython inference_ram_openset.py  --image images\u002Fopenset_example.jpg \\\n--pretrained pretrained\u002Fram_swin_large_14m.pth\n\u003C\u002Fpre>\n\n输出将如下所示：\n```\n图像标签: 黑白 | 卡丁车\n```\n\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"4\" style=\"font-weight:bold;\">\nTag2Text 推理\n\u003C\u002Ffont>\u003C\u002Fsummary>\n\n\n获取标记和标题生成结果：\n\u003Cpre\u002F>\npython inference_tag2text.py  --image images\u002Fdemo\u002Fdemo1.jpg \\\n--pretrained pretrained\u002Ftag2text_swin_14m.pth\n\u003C\u002Fpre>\n或者获取标记及指定标题生成结果（可选）：\n\u003Cpre\u002F>python inference_tag2text.py  --image images\u002Fdemo\u002Fdemo1.jpg \\\n--pretrained pretrained\u002Ftag2text_swin_14m.pth \\\n--specified-tags \"云,天空\"\u003C\u002Fpre>\n\n\u003C\u002Fdetails>\n\n### **批量推理与评估** ##\n我们发布了两个数据集 `OpenImages-common`（214 个常见标签类别）和 `OpenImages-rare`（200 个罕见标签类别）。请将 [OpenImages v6](https:\u002F\u002Fstorage.googleapis.com\u002Fopenimages\u002Fweb\u002Fdownload_v6.html) 的测试图像复制或符号链接到 `datasets\u002Fopenimages_common_214\u002Fimgs\u002F` 和 `datasets\u002Fopenimages_rare_200\u002Fimgs`。\n\n在 `OpenImages-common` 数据集上评估 RAM++：\n\n```bash\npython batch_inference.py \\\n  --model-type ram_plus \\\n  --checkpoint pretrained\u002Fram_plus_swin_large_14m.pth \\\n  --dataset openimages_common_214 \\\n  --output-dir outputs\u002Fram_plus\n```\n\n在 `OpenImages-rare` 数据集上评估 RAM++ 的开放集能力：\n\n```bash\npython batch_inference.py \\\n  --model-type ram_plus \\\n  --checkpoint pretrained\u002Fram_plus_swin_large_14m.pth \\\n  --open-set \\\n  --dataset openimages_rare_200 \\\n  --output-dir outputs\u002Fram_plus_openset\n```\n\n在 `OpenImages-common` 数据集上评估 RAM：\n\n```bash\npython batch_inference.py \\\n  --model-type ram \\\n  --checkpoint pretrained\u002Fram_swin_large_14m.pth \\\n  --dataset openimages_common_214 \\\n  --output-dir outputs\u002Fram\n```\n\n在 `OpenImages-rare` 数据集上评估 RAM 的开放集能力：\n\n```bash\npython batch_inference.py \\\n  --model-type ram \\\n  --checkpoint pretrained\u002Fram_swin_large_14m.pth \\\n  --open-set \\\n  --dataset openimages_rare_200 \\\n  --output-dir outputs\u002Fram_openset\n```\n\n在 `OpenImages-common` 数据集上评估 Tag2Text：\n\n```bash\npython batch_inference.py \\\n  --model-type tag2text \\\n  --checkpoint pretrained\u002Ftag2text_swin_14m.pth \\\n  --dataset openimages_common_214 \\\n  --output-dir outputs\u002Ftag2text\n```\n\n更多选项请参阅 `batch_inference.py`。若需获得 RAM 论文表 3 中的 P\u002FR 值，对于 RAM 请传递 `--threshold=0.86`，对于 Tag2Text 则传递 `--threshold=0.68`。\n\n如需对自定义图像进行批量推理，您可以参照上述两个数据集自行设置数据集。\n\n\n## :golfing: 模型训练\u002F微调\n\n### **RAM++** ##\n\n1. 下载 [RAM 训练数据集](#open_book-training-datasets)，其中每个 JSON 文件包含一个列表。列表中的每个条目是一个字典，包含三个键值对：{'image_path': 图像路径, 'caption': 图像描述文本, 'union_label_id': 用于标注的图像标签，包括解析标签和伪标签}。\n\n2. 在 ram\u002Fconfigs\u002Fpretrain.yaml 中，将 'train_file' 设置为这些 JSON 文件的路径。\n\n3. 准备 [预训练的 Swin-Transformer](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FSwin-Transformer)，并在 ram\u002Fconfigs\u002Fswin 中设置 'ckpt'。\n\n4. 下载 RAM++ 冻结标签嵌入文件 “[ram_plus_tag_embedding_class_4585_des_51.pth](https:\u002F\u002Fhuggingface.co\u002Fxinyu1205\u002Frecognize-anything-plus-model\u002Fblob\u002Fmain\u002Fram_plus_tag_embedding_class_4585_des_51.pth)”，并将其放置在 \"ram\u002Fdata\u002Ffrozen_tag_embedding\u002Fram_plus_tag_embedding_class_4585_des_51.pth\"。\n\n5. 使用 8 张 A100 GPU 对模型进行预训练：\n\n```bash\npython -m torch.distributed.run --nproc_per_node=8 pretrain.py \\\n  --model-type ram_plus \\\n  --config ram\u002Fconfigs\u002Fpretrain.yaml  \\\n  --output-dir outputs\u002Fram_plus\n```\n\n6. 使用 8 张 A100 GPU 对预训练检查点进行微调：\n\n```bash\npython -m torch.distributed.run --nproc_per_node=8 finetune.py \\\n  --model-type ram_plus \\\n  --config ram\u002Fconfigs\u002Ffinetune.yaml  \\\n  --checkpoint outputs\u002Fram_plus\u002Fcheckpoint_04.pth \\\n  --output-dir outputs\u002Fram_plus_ft\n```\n\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"4\" style=\"font-weight:bold;\">\nRAM \n\u003C\u002Ffont>\u003C\u002Fsummary>\n\n1. 下载 [RAM 训练数据集](#open_book-training-datasets)，其中每个 JSON 文件包含一个列表。列表中的每个条目是一个字典，包含四个键值对：{'image_path': 图像路径, 'caption': 图像描述文本, 'union_label_id': 用于标注的图像标签，包括解析标签和伪标签, 'parse_label_id': 从图像描述中解析出的标签}。\n\n2. 在 ram\u002Fconfigs\u002Fpretrain.yaml 中，将 'train_file' 设置为这些 JSON 文件的路径。\n\n3. 准备 [预训练的 Swin-Transformer](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FSwin-Transformer)，并在 ram\u002Fconfigs\u002Fswin 中设置 'ckpt'。\n\n4. 下载 RAM 冻结标签嵌入文件 “[ram_tag_embedding_class_4585.pth](https:\u002F\u002Fhuggingface.co\u002Fxinyu1205\u002Frecognize_anything_model\u002Fblob\u002Fmain\u002Fram_tag_embedding_class_4585.pth)”，并将其放置在 \"ram\u002Fdata\u002Ffrozen_tag_embedding\u002Fram_tag_embedding_class_4585.pth\"。\n\n5. 使用 8 张 A100 GPU 对模型进行预训练：\n\n```bash\npython -m torch.distributed.run --nproc_per_node=8 pretrain.py \\\n  --model-type ram \\\n  --config ram\u002Fconfigs\u002Fpretrain.yaml  \\\n  --output-dir outputs\u002Fram\n```\n\n6. 使用 8 张 A100 GPU 对预训练检查点进行微调：\n\n```bash\npython -m torch.distributed.run --nproc_per_node=8 finetune.py \\\n  --model-type ram \\\n  --config ram\u002Fconfigs\u002Ffinetune.yaml  \\\n  --checkpoint outputs\u002Fram\u002Fcheckpoint_04.pth \\\n  --output-dir outputs\u002Fram_ft\n```\n\n\u003C\u002Fdetails>\n\n\n\u003Cdetails>\n\u003Csummary>\u003Cfont size=\"4\" style=\"font-weight:bold;\">\nTag2Text \n\u003C\u002Ffont>\u003C\u002Fsummary>\n\n1. 下载 [RAM 训练数据集](#open_book-training-datasets)，其中每个 JSON 文件包含一个列表。列表中的每个条目是一个字典，包含三个键值对：{'image_path': 图像路径, 'caption': 图像描述文本, 'parse_label_id': 从图像描述中解析出的标签}。\n\n2. 在 ram\u002Fconfigs\u002Fpretrain_tag2text.yaml 中，将 'train_file' 设置为这些 JSON 文件的路径。\n\n3. 准备 [预训练的 Swin-Transformer](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FSwin-Transformer)，并在 ram\u002Fconfigs\u002Fswin 中设置 'ckpt'。\n\n4. 使用 8 张 A100 GPU 对模型进行预训练：\n\n```bash\npython -m torch.distributed.run --nproc_per_node=8 pretrain.py \\\n  --model-type tag2text \\\n  --config ram\u002Fconfigs\u002Fpretrain_tag2text.yaml  \\\n  --output-dir outputs\u002Ftag2text\n```\n\n5. 使用 8 张 A100 GPU 对预训练检查点进行微调：\n\n```bash\npython -m torch.distributed.run --nproc_per_node=8 finetune.py \\\n  --model-type tag2text \\\n  --config ram\u002Fconfigs\u002Ffinetune_tag2text.yaml  \\\n  --checkpoint outputs\u002Ftag2text\u002Fcheckpoint_04.pth \\\n  --output-dir outputs\u002Ftag2text_ft\n```\n\n\u003C\u002Fdetails>\n\n\n## :black_nib: 引用\n如果您认为我们的工作对您的研究有所帮助，请考虑引用。\n\n```\n@article{huang2023open,\n  title={开放集图像标注与多粒度文本监督},\n  author={黄鑫宇、黄义杰、张友才、田伟伟、冯锐、张跃杰、谢延春、李雅倩、张磊},\n  journal={arXiv 预印本},\n  pages={arXiv--2310},\n  year={2023}\n}\n\n@article{zhang2023recognize,\n  title={识别一切：强大的图像标注模型},\n  author={张友才、黄鑫宇、马金宇、李兆阳、罗赵川、谢延春、秦宇卓、罗彤、李雅倩、刘士龙等},\n  journal={arXiv 预印本 arXiv:2306.03514},\n  year={2023}\n}\n\n@article{huang2023tag2text,\n  title={Tag2Text：通过图像标注引导视觉-语言模型},\n  author={黄鑫宇、张友才、马金宇、田伟伟、冯锐、张跃杰、李雅倩、郭彦东、张磊},\n  journal={arXiv 预印本 arXiv:2303.05657},\n  year={2023}\n}\n```\n\n## :hearts: 致谢\n这项工作得益于 [BLIP](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FBLIP) 令人惊叹的代码库，在此表示衷心感谢！\n\n我们还要感谢 @Cheng Rui、@Shilong Liu 和 @Ren Tianhe 在 [将 RAM\u002FTag2Text 与 Grounded-SAM 结合](https:\u002F\u002Fgithub.com\u002FIDEA-Research\u002FGrounded-Segment-Anything)方面提供的帮助。\n\n此外，我们也感谢 [Ask-Anything](https:\u002F\u002Fgithub.com\u002FOpenGVLab\u002FAsk-Anything) 和 [Prompt-can-anything](https:\u002F\u002Fgithub.com\u002Fpositive666\u002FPrompt-Can-Anything) 将 RAM\u002FTag2Text 结合起来，这极大地扩展了 RAM\u002FTag2Text 的应用范围。","# Recognize Anything 快速上手指南\n\nRecognize Anything (RAM) 系列模型是一组强大的开源图像识别基础模型，包含 **RAM++**（支持任意类别的高精度识别）、**RAM**（高精度常见类别标签识别）和 **Tag2Text**（结合标签引导的图文生成模型）。本指南将帮助您快速部署并使用这些模型。\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**: Linux 或 macOS (Windows 用户建议使用 WSL2 或 Docker)\n*   **Python**: 3.8 或更高版本\n*   **GPU**: 推荐 NVIDIA GPU (显存建议 8GB 以上以运行 Swin-Large 版本)，需安装对应的 CUDA 驱动\n*   **依赖管理**: 推荐使用 `conda` 或 `venv` 创建独立虚拟环境\n\n## 安装步骤\n\n### 1. 克隆项目代码\n首先从 GitHub 克隆仓库到本地：\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything.git\ncd recognize-anything\n```\n\n### 2. 安装依赖\n安装项目所需的 Python 依赖包。如果下载速度较慢，可配置国内镜像源（如清华源）：\n\n```bash\npip install -r requirements.txt -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n> **注意**：如果 `requirements.txt` 中未明确指定 torch 版本，请根据您的 CUDA 版本手动安装 PyTorch。例如：\n> ```bash\n> pip install torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118\n> ```\n\n### 3. 下载预训练模型\n项目提供了 RAM++、RAM 和 Tag2Text 的预训练权重。您需要创建一个 `pretrained` 文件夹并将模型文件放入其中。\n\n**手动下载方式：**\n访问 [Hugging Face Model Hub](https:\u002F\u002Fhuggingface.co\u002Fxinyu1205) 下载以下核心模型文件，并放入项目根目录下的 `pretrained\u002F` 文件夹中：\n\n*   **RAM++ (推荐)**: `ram_plus_swin_large_14m.pth`\n    *   下载地址: [RAM++ Checkpoint](https:\u002F\u002Fhuggingface.co\u002Fxinyu1205\u002Frecognize-anything-plus-model\u002Fblob\u002Fmain\u002Fram_plus_swin_large_14m.pth)\n*   **RAM**: `ram_swin_large_14m.pth`\n*   **Tag2Text**: `tag2text_swin_14m.pth`\n\n```bash\nmkdir pretrained\n# 示例：使用 wget 下载 RAM++ (请替换为实际下载链接或使用浏览器下载后移动文件)\n# wget -P pretrained\u002F \u003CRAM++_Download_URL>\n```\n\n## 基本使用\n\n以下是最简单的 Python 脚本示例，展示如何使用 **RAM++** 对单张图片进行标签识别。\n\n### 代码示例\n\n创建一个名为 `demo.py` 的文件，写入以下内容：\n\n```python\nimport torch\nfrom torchvision import transforms\nfrom ram.models import ram_plus\nfrom ram import inference_ram_plus\nimport cv2\n\n# 1. 设置设备\ndevice = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n\n# 2. 加载模型 (确保 pretrained 文件夹下有对应的权重文件)\nimage_size = 384\nmodel = ram_plus(pretrained='pretrained\u002Fram_plus_swin_large_14m.pth',\n                 image_size=image_size,\n                 vit='swin_l')\nmodel.eval()\nmodel = model.to(device)\n\n# 3. 数据预处理\ntransform = transforms.Compose([\n    transforms.Resize((image_size, image_size)),\n    transforms.ToTensor(),\n    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])\n])\n\n# 4. 加载图片\nimage_path = 'images\u002Fdemo.jpg'  # 替换为您的图片路径\nimage = cv2.imread(image_path)\nimage = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\nimage_input = transform(image).unsqueeze(0).to(device)\n\n# 5. 执行推理\nwith torch.no_grad():\n    tags = inference_ram_plus(image_input, model)\n\n# 6. 输出结果\nprint(\"识别到的标签:\", tags[0])\n```\n\n### 运行测试\n\n确保您有一张测试图片（例如 `images\u002Fdemo.jpg`），然后运行脚本：\n\n```bash\npython demo.py\n```\n\n**输出示例：**\n模型将输出一串逗号分隔的英文标签，例如：\n`sky, cloud, tree, grass, outdoor, nature, landscape`\n\n### 进阶提示\n*   **模型切换**：若需使用原版 RAM 或 Tag2Text，只需更改导入的模型类 (`ram`, `tag2text`) 和对应的推理函数 (`inference_ram`, `inference_tag2text`)，并加载相应的权重文件。\n*   **批量处理**：可以通过构建 DataLoader 对图片文件夹进行批量推理。\n*   **Web Demo**：项目也提供了基于 Gradio 的本地 Web 界面，可通过运行 `app.py` (如果项目中包含) 或使用 Hugging Face Spaces 在线体验。","某电商运营团队每天需处理数万张用户上传的商品实拍图，以便快速生成搜索标签和商品描述。\n\n### 没有 recognize-anything 时\n- 依赖人工打标签，效率极低且容易因疲劳导致漏标或错标常见品类（如“连衣裙”、“运动鞋”）。\n- 面对用户拍摄的冷门或新颖商品（开放集类别），传统模型完全无法识别，导致大量长尾商品无法被检索。\n- 生成的商品描述过于通用，缺乏对画面中具体物体交互（如“人手持咖啡杯”）的精准语义分析。\n- 想要实现精细化的局部定位（如自动抠图或框选特定商品），需要串联多个独立模型，开发维护成本高昂。\n- 数据标注周期长达数周，严重拖慢新品上架速度和营销活动的响应节奏。\n\n### 使用 recognize-anything 后\n- RAM++ 模型自动高精度识别所有常见品类，将打标效率提升百倍，释放人力专注于创意策划。\n- 凭借强大的零样本泛化能力，轻松识别从未见过的“开放集”新奇商品，确保全量商品均可被搜索命中。\n- 结合 Tag2Text 能力，直接输出包含详细物体交互关系的自然语言描述，显著提升商品详情页的可读性。\n- 通过与 Grounding-DINO 等模型联动，一键完成从标签识别到物体精准定位的完整流程，大幅降低工程复杂度。\n- 新品图片上传即完成结构化处理，上架周期从数周缩短至分钟级，迅速响应市场热点。\n\nrecognize-anything 通过统一的强基座模型，彻底解决了图像识别中常见类别与开放集类别难以兼顾的痛点，实现了从“看图”到“懂图”的质变。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fxinyu1205_recognize-anything_27d1ca05.jpg","xinyu1205","Xinyu Huang","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fxinyu1205_a2798f0a.jpg","Ph.D. Student at Fudan University, homepage: xinyu1205.github.io","Fudan University","Shanghai, China","xinyuhuang20@fudan.edu.cn",null,"https:\u002F\u002Fxinyu1205.github.io","https:\u002F\u002Fgithub.com\u002Fxinyu1205",[84,88],{"name":85,"color":86,"percentage":87},"Jupyter Notebook","#DA5B0B",97.2,{"name":89,"color":90,"percentage":91},"Python","#3572A5",2.8,3617,325,"2026-04-09T14:05:04","Apache-2.0","","未说明（模型基于 Swin-Large 骨干网络，通常推理需要支持 CUDA 的 NVIDIA GPU，显存建议 8GB+ 以加载大模型）","未说明",{"notes":100,"python":98,"dependencies":101},"README 中未直接列出具体的运行环境配置（如 OS、Python 版本、依赖库列表）。该项目提供 RAM++、RAM 和 Tag2Text 模型，其中 RAM++ 和 RAM 使用 Swin-Large 作为骨干网络。用户需手动创建 'pretrained' 文件夹并下载检查点文件。项目提供了 Colab 和 Bohrium 的在线演示链接，暗示其可在云端 GPU 环境运行。具体依赖需参考项目代码库中的 requirements.txt 或安装脚本。",[],[15,103],"其他",[105,65],"tag2text-iclr2024","2026-03-27T02:49:30.150509","2026-04-11T23:23:56.530750",[109,114,119,124,129,134,139],{"id":110,"question_zh":111,"answer_zh":112,"source_url":113},30095,"RAM 模型支持中文标签输出吗？是否有训练代码发布计划？","目前的 RAM 模型已经支持同时输出中英文标签（tags）。关于训练代码，维护者表示会在几周内公开，届时用户可以在中文数据集上进行微调。","https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything\u002Fissues\u002F8",{"id":115,"question_zh":116,"answer_zh":117,"source_url":118},30096,"如何使用自定义标签列表微调 Tag2Text 模型？","微调步骤如下：\n1. 将原有的 `tag2text_ori_tag_list.txt` 替换为你的自定义标签列表文件（无特定排序规则）。\n2. 加载 Tag2Text 预训练权重，但必须重新初始化 `self.fc`、`self.label_embed` 和 `self.class_threshold`，因为这些层与标签列表维度相关。\n3. 准备训练数据集，JSON 文件中只需包含 `image`、`text` 和从文本解析出的标签 ID (`parse_label_id`)。\n4. 开始训练。\n注意：如果直接加载权重而不重新初始化上述层，会因维度不匹配报错。对于新类别的 `label_embed`，可以选择重叠类别保留权重，其他类别随机初始化；`self.fc` 也可直接尝试随机初始化。","https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything\u002Fissues\u002F143",{"id":120,"question_zh":121,"answer_zh":122,"source_url":123},30097,"微调新标签时，label_embedding 初始化为全零导致不收敛怎么办？","代码中默认将 `self.label_embed` 初始化为全零，这在微调新标签时可能导致 Loss 不下降或推理失效。解决方案是参考论文方法，使用 CLIP 模型离线生成新标签的文本嵌入（textual embeddings）来初始化 `label_embed`，而不是使用全零初始化。此外，RAM++ 中的维度对齐（如 51 的含义）通常指对每个标签使用大模型生成的多种文本描述（模板），你可以对自定义标签也生成类似的多种表达来对齐维度。","https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything\u002Fissues\u002F211",{"id":125,"question_zh":126,"answer_zh":127,"source_url":128},30098,"运行推理时结果不如示例图好（漏检标签），如何调整？","这通常是分类阈值（threshold）设置过高导致的。默认阈值可能为 0.68，建议尝试降低该值。例如，将 `model.threshold` 从 0.68 降至 0.64 或 0.63，可以检出更多标签（如 'lamp'、'door' 等）。此外，如果遇到 `RuntimeError: Expected all tensors to be on the same device` 错误，请确保代码中涉及的张量（如 `class_threshold`）已移动到与模型相同的设备（cuda 或 cpu）。","https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything\u002Fissues\u002F14",{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},30099,"一个英文标签对应多个中文含义（如 table 对应“桌子\u002F表格”），如何过滤无关中文标签？","目前 RAM 系列本质是英文模型，中文标签是通过翻译得到的，因此存在一词多义现象（如 table 被译为“桌子”和“表格”）。官方目前没有内置的功能来自动根据图像上下文过滤多义词的特定中文含义。用户需要在后处理阶段自行添加逻辑，或者结合其他上下文理解模块来筛选最合适的中文标签。","https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything\u002Fissues\u002F168",{"id":135,"question_zh":136,"answer_zh":137,"source_url":138},30100,"训练时是否可以移除 `loss_t2t` (tag-to-text loss)？","如果你希望强调模型的开放集（open-set）标签识别能力，建议保留 `loss_t2t` 以保持损失平衡。虽然可以移除该部分代码，但维护者指出保持 `loss_tag`、`loss_dis` 和 `loss_t2t` 之间的平衡对于模型性能（特别是开放集能力）更为重要。","https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything\u002Fissues\u002F172",{"id":140,"question_zh":141,"answer_zh":142,"source_url":143},30101,"Zero-shot 推理中的 frozen_tag_embedding 是如何生成的？","Zero-shot 推理所需的冻结标签嵌入（frozen_tag_embedding）通常是使用预训练的 CLIP 模型（如 openai\u002Fclip-vit-large-patch14 等）对标签列表进行编码生成的。用户若需复现，可使用类似的 CLIP 模型对 `ram_tag_list` 中的标签文本进行编码，获取对应的向量表示。具体的 Zero-shot 推理代码已在后续开源，可参考官方仓库的最新更新。","https:\u002F\u002Fgithub.com\u002Fxinyu1205\u002Frecognize-anything\u002Fissues\u002F27",[]]