← Back to Skills Marketplace
maple-8899

Baidu Image Classify

by Maple-8899 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
73
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install baidu-image-classify
Description
支持通用物体识别、商品识别和场景识别,输入图片返回标签、商品信息或场景标签及置信度。
README (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
  • 🛍️ 发商品图片 → 我识别商品信息
  • 🎬 发文案 → 我生成语音

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

Usage Guidance
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.
Capability Analysis
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.
Capability Tags
requires-oauth-token
Capability Assessment
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.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install baidu-image-classify
  3. After installation, invoke the skill by name or use /baidu-image-classify
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
baidu-image-classify 1.0.0 初始版本发布 - 新增基于百度 API 的图像识别技能,支持 OAuth 2.0 认证。 - 实现通用物体识别、商品识别和场景识别三大功能。 - 提供详细调用示例、输入输出格式说明和常见应用场景。 - 支持 jpg/png/bmp 等格式,限制图片小于 4MB。 - 每月免费额度 5 万次,建议缓存识别结果以提升效率。
Metadata
Slug baidu-image-classify
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Baidu Image Classify?

支持通用物体识别、商品识别和场景识别,输入图片返回标签、商品信息或场景标签及置信度。 It is an AI Agent Skill for Claude Code / OpenClaw, with 73 downloads so far.

How do I install Baidu Image Classify?

Run "/install baidu-image-classify" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Baidu Image Classify free?

Yes, Baidu Image Classify is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Baidu Image Classify support?

Baidu Image Classify is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Baidu Image Classify?

It is built and maintained by Maple-8899 (@maple-8899); the current version is v1.0.0.

💬 Comments