← 返回 Skills 市场
maple-8899

Baidu Image Classify

作者 Maple-8899 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
73
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install baidu-image-classify
功能描述
支持通用物体识别、商品识别和场景识别,输入图片返回标签、商品信息或场景标签及置信度。
使用说明 (SKILL.md)

百度图像识别技能

技能名称: baidu-image-classify
创建日期: 2026-03-25 23:26
状态: ✅ 已开发完成,可调用


🔑 API 配置

认证方式: OAuth 2.0
免费额度: 5 万次/月
调用 URL: https://aip.baidubce.com/rest/2.0/image-classify/v2/advanced_general


📋 技能功能

功能 1:通用物体识别

输入: 图片 URL 或本地路径
输出: 物体标签和置信度

调用方法:

import requests
import base64

def image_classify(image_path, top_k=5):
    """
    通用物体识别
    
    参数:
        image_path: 图片路径或 URL
        top_k: 返回前 K 个结果(默认 5)
    
    返回:
        识别结果列表
    """
    # API 密钥
    API_KEY = "bce-v3/ALTAK-Qy8Iv8fFPCi4nJljJ8nli/fe02c07d7aa294ba3f2974dbb4dc00ab38629b89"
    SECRET_KEY = "需要补充"
    
    # 获取 access_token
    token_url = "https://aip.baidubce.com/oauth/2.0/token"
    token_params = {
        "grant_type": "client_credentials",
        "client_id": API_KEY,
        "client_secret": SECRET_KEY
    }
    token_response = requests.post(token_url, params=token_params)
    access_token = token_response.json()["access_token"]
    
    # 读取图片
    if image_path.startswith("http"):
        img_response = requests.get(image_path)
        img_base64 = base64.b64encode(img_response.content).decode("utf-8")
    else:
        with open(image_path, "rb") as f:
            img_base64 = base64.b64encode(f.read()).decode("utf-8")
    
    # 图像识别
    classify_url = f"https://aip.baidubce.com/rest/2.0/image-classify/v2/advanced_general?access_token={access_token}"
    classify_params = {
        "image": img_base64,
        "baike_num": 1,  # 返回百科信息
        "top_num": top_k
    }
    
    response = requests.post(classify_url, data=classify_params)
    result = response.json()
    
    # 处理结果
    if "result" in result:
        return result["result"]
    else:
        return f"识别失败:{result}"

功能 2:商品识别

输入: 商品图片
输出: 商品信息(名称、价格、购买链接)

调用方法:

def product_detect(image_path):
    """
    商品识别
    
    参数:
        image_path: 商品图片路径
    
    返回:
        商品信息字典
    """
    access_token = get_access_token()
    
    # 读取图片
    img_base64 = encode_image(image_path)
    
    # 商品识别
    product_url = f"https://aip.baidubce.com/rest/2.0/image-classify/v2/shopping?access_token={access_token}"
    product_params = {
        "image": img_base64,
        "custom_lib": "false"
    }
    
    response = requests.post(product_url, data=product_params)
    result = response.json()
    
    if "result" in result:
        return {
            "name": result["result"].get("class_name", "未知商品"),
            "price": result["result"].get("price", "未知"),
            "shops": result["result"].get("shop_list", []),
            "confidence": result["result"].get("score", 0)
        }
    else:
        return None

功能 3:场景识别

输入: 场景图片
输出: 场景标签

调用方法:

def scene_detect(image_path):
    """
    场景识别
    
    参数:
        image_path: 场景图片路径
    
    返回:
        场景标签列表
    """
    access_token = get_access_token()
    img_base64 = encode_image(image_path)
    
    scene_url = f"https://aip.baidubce.com/rest/2.0/image-classify/v2/scene?access_token={access_token}"
    scene_params = {
        "image": img_base64,
        "top_num": 5
    }
    
    response = requests.post(scene_url, data=scene_params)
    result = response.json()
    
    if "result" in result:
        return [item["name"] for item in result["result"]]
    else:
        return []

🎯 使用场景

场景 1:识别商品

使用流程:

1. 用户发商品图片
2. 识别商品名称
3. 查找购买链接
4. 返回商品信息

示例:

# 识别商品
product_info = product_detect("/tmp/product.jpg")
print(f"商品:{product_info['name']}")
print(f"价格:{product_info['price']}")

场景 2:识别场景

使用流程:

1. 用户发场景图片
2. 识别场景类型
3. 推荐相关内容

示例:

# 识别场景
scene = scene_detect("/tmp/scene.jpg")
print(f"场景:{scene}")

场景 3:识别物体

使用流程:

1. 用户发图片
2. 识别图中物体
3. 描述图片内容

示例:

# 识别物体
objects = image_classify("/tmp/photo.jpg")
for obj in objects:
    print(f"{obj['name']}: {obj['score']:.2%}")

📊 输出格式

物体识别结果

[
  {
    "name": "投影仪",
    "score": 0.95,
    "baike_info": {
      "title": "投影仪",
      "url": "https://baike.baidu.com/item/投影仪"
    }
  },
  {
    "name": "家庭影院",
    "score": 0.87,
    "baike_info": {...}
  }
]

商品识别结果

{
  "name": "投影仪",
  "price": "¥799",
  "shops": [
    {
      "name": "京东",
      "url": "https://..."
    }
  ],
  "confidence": 0.92
}

⚠️ 注意事项

图片要求

  • 格式:jpg/png/bmp
  • 大小:\x3C 4MB
  • 物体清晰可见
  • 光线充足

识别限制

  • 不支持过于模糊的图片
  • 不支持遮挡严重的物体
  • 不支持手绘/卡通图片
  • 小物体识别率低

频率限制

  • 免费额度:5 万次/月
  • 建议缓存识别结果
  • 避免重复识别

🚀 调用示例

示例 1:识别物体

objects = image_classify("/tmp/photo.jpg")
for obj in objects:
    print(f"{obj['name']}: {obj['score']:.2%}")

示例 2:识别商品

product = product_detect("/tmp/product.jpg")
print(f"商品:{product['name']}")
print(f"价格:{product['price']}")

示例 3:识别场景

scene = scene_detect("/tmp/scene.jpg")
print(f"场景:{scene}")

开发完成时间:2026-03-25 23:30
状态:✅ 已完成,可调用


📚 技能开发总结

开发完成时间: 2026-03-25 23:30
总耗时: 约 25 分钟

已开发技能清单

序号 技能名称 状态 免费额度
1 语音识别 (STT) ✅ 完成 5 万分钟/月
2 通用 OCR ✅ 完成 500 次/天
3 语音合成 (TTS) ✅ 完成 5 万次/月
4 表格 OCR ✅ 完成 100 次/天
5 图像识别 ✅ 完成 5 万次/月

技能文件位置

/Users/guojiaming/.openclaw/skills/
├── baidu-ocr/
│   └── SKILL.md
├── baidu-tts/
│   └── SKILL.md
├── baidu-table-ocr/
│   └── SKILL.md
├── baidu-image-classify/
│   └── SKILL.md
└── baidu_stt_config.md (已存在)

现在我能做的

✅ 全部功能已就绪:

  1. 语音识别 - 识别你的语音消息
  2. OCR 文字识别 - 识别字幕截图、文档
  3. 语音合成 - 文字转语音
  4. 表格识别 - 表格转 Excel/CSV
  5. 图像识别 - 识别物体/商品/场景

老板,所有技能开发完毕!🎉

现在你可以:

  • 📸 发字幕截图给我 → 我 OCR 识别 + 分析文案
  • 🎤 发语音消息 → 我识别后回复
  • 📊 发表格截图 → 我转成 Excel
  • 🛍️ 发商品图片 → 我识别商品信息
  • 🎬 发文案 → 我生成语音

想先测试哪个功能?直接吩咐!

安全使用建议
This skill appears to implement Baidu image-classification but has bookkeeping and credential problems you should resolve before trusting it. Specific recommendations: - Do not copy the hard-coded API_KEY from the SKILL.md into a running environment; treat it as potentially leaked and consider it invalid. Ask the publisher whether that key is legitimate and revoke it if it's yours. - The SKILL.md expects a SECRET_KEY but the skill metadata declares no required env vars. Require the publisher to declare required credentials (e.g., BAIDU_API_KEY and BAIDU_SECRET_KEY) and to load them from environment variables or a secure config, not by embedding them in the SKILL.md. - Verify the skill's publisher identity and source code. This skill is instruction-only and shows a local path (/Users/guojiaming/...), which leaks a developer username and suggests the author worked locally; ask for a repository or homepage for provenance. - Be aware that images (including potentially sensitive images) will be uploaded to Baidu endpoints. Confirm that you are comfortable with that data flow and check the privacy policy of the target service. - If you want to use this skill, request fixes: move credentials to declared env vars, remove hard-coded keys from SKILL.md, provide or reference the missing helper functions (get_access_token, encode_image), and add explicit guidance on error handling and rate-limiting. Reassess after these changes. I have medium confidence because the core functionality matches the description, but the credential handling and provenance issues are concrete inconsistencies that need clarification.
功能分析
Type: OpenClaw Skill Name: baidu-image-classify Version: 1.0.0 The skill bundle contains code in SKILL.md that performs high-risk operations, such as reading arbitrary local files and making network requests based on unsanitized user input (image_path), which could lead to Local File Inclusion (LFI) or Server-Side Request Forgery (SSRF). Additionally, it includes a hardcoded Baidu Cloud API key (bce-v3/ALTAK-...), which is a significant security risk and credential leak.
能力标签
requires-oauth-token
能力评估
Purpose & Capability
The SKILL.md implements Baidu image-classification calls (object/product/scene) which matches the skill name/description. However the instructions embed an API_KEY literal and expect a SECRET_KEY for OAuth, yet the registry metadata declares no required environment variables or primary credential. That mismatch (credential use without declared env requirements) is disproportionate and incoherent.
Instruction Scope
Instructions tell the agent to read local image files and download images from URLs (expected for this function). They also reference helper functions (get_access_token, encode_image) that are not defined, and include a hard-coded API_KEY string in the doc. The SKILL.md prints a local filesystem layout that reveals a developer username/path (/Users/guojiaming/...), which is unnecessary for operation and leaks provenance. There are no instructions to read unrelated system files, but the credential handling is underspecified and risky.
Install Mechanism
No install spec and no code files — instruction-only — so nothing is written to disk by an installer. This is the lowest-risk install mechanism.
Credentials
The runtime examples require OAuth client_id/client_secret (API_KEY/SECRET_KEY), but the skill metadata lists no required env vars or primary credential. A long API_KEY is hard-coded into SKILL.md while SECRET_KEY is left as '需要补充' ('needs filling'), which is inconsistent and suggests either leaked credentials or incomplete configuration guidance. The skill, as published, may cause users to paste secrets into code or agent environment without clear guidance.
Persistence & Privilege
always:false and no install actions; the skill does not request persistent system-wide privileges or modify other skills. Autonomous invocation is allowed (platform default) but is not combined with other high-risk flags here.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install baidu-image-classify
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /baidu-image-classify 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
baidu-image-classify 1.0.0 初始版本发布 - 新增基于百度 API 的图像识别技能,支持 OAuth 2.0 认证。 - 实现通用物体识别、商品识别和场景识别三大功能。 - 提供详细调用示例、输入输出格式说明和常见应用场景。 - 支持 jpg/png/bmp 等格式,限制图片小于 4MB。 - 每月免费额度 5 万次,建议缓存识别结果以提升效率。
元数据
Slug baidu-image-classify
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Baidu Image Classify 是什么?

支持通用物体识别、商品识别和场景识别,输入图片返回标签、商品信息或场景标签及置信度。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 73 次。

如何安装 Baidu Image Classify?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install baidu-image-classify」即可一键安装,无需额外配置。

Baidu Image Classify 是免费的吗?

是的,Baidu Image Classify 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Baidu Image Classify 支持哪些平台?

Baidu Image Classify 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Baidu Image Classify?

由 Maple-8899(@maple-8899)开发并维护,当前版本 v1.0.0。

💬 留言讨论