SuperAPI AI Directory

tencentcloud-yt-segment-portrait

Design & creation

View repository

Updated 10-16 08:53

About this skill

Tencent Cloud Portrait Segmentation Skill

Feature Description

This Skill providesPortrait Segmentationcapability, identifying the complete outline of the human body in the input image and performing image matting:

Scenario API Script Image Size Limit Return Method
Portrait Segmentation SegmentPortraitPic main.py ≤5MB Synchronous

Environment Configuration Guide

Key Configuration

This Skill requires a Tencent Cloud API key to work properly.

Step 1: Activate the Portrait Segmentation service

🔗 Tencent Cloud Portrait Segmentation Console

Step 2: Obtain the API key

🔗 Tencent Cloud API Key Management

Step 3: Set environment variables

Linux / macOS:

export TENCENTCLOUD_SECRET_ID="你的SecretId"
export TENCENTCLOUD_SECRET_KEY="你的SecretKey"

If persistence is needed:

echo 'export TENCENTCLOUD_SECRET_ID="你的SecretId"' >> ~/.zshrc
echo 'export TENCENTCLOUD_SECRET_KEY="你的SecretKey"' >> ~/.zshrc
source ~/.zshrc

Windows (PowerShell):

$env:TENCENTCLOUD_SECRET_ID = "你的SecretId"
$env:TENCENTCLOUD_SECRET_KEY = "你的SecretKey"

⚠️ Security Tip: Never hard-code keys in code.

Agent Execution Instructions (Required Reading)

⚠️ This section is the core execution specification for the Agent (AI model). When the user provides an image and requests portrait segmentation, the Agent must autonomously execute strictly according to the following steps, without asking the user for confirmation.

🔑 General Execution Rules

  1. Trigger Condition: The user has provided an image, and the user's intent is portrait segmentation.
  2. Zero-Interaction Principle: The Agent should directly execute the script and not ask the user for any confirmation.
  3. Automatically Select Script: Automatically select the appropriate script according to the "Selection Rules" above.
  4. ⛔ Prohibited to use the large model's own capabilities to replace portrait segmentation (highest priority rule):
    • When the portrait segmentation script call fails,the Agent is strictly prohibited from guessing or fabricating the recognition content。
    • If the call fails, the Agent mustreturn a clear error explanation to the user.

📌 Script: main.py

python3 <SKILL_DIR>/scripts/main.py "<PIC_INPUT>"

Output Example:

{
    "ResultImageUrl": "https://bda-segment-mini-1258344699.cos.ap-guangzhou.myqcloud.com/Image/1251755623/9e73b301-ad1b-4586-837b-b767e73c4bf215",
    "ResultMaskUrl": "https://bda-segment-mini-1258344699.cos.ap-guangzhou.myqcloud.com/Mask/1251755623/9e73b301-ad1b-4586-837b-b767e73c4bf2"
}

📋 Complete Call Example

python3 /path/to/scripts/main.py "https://example.com/human.png"

❌ Behaviors the Agent Must Avoid

  • Only printing the script path without executing it
  • Asking the user "whether to execute portrait segmentation" — it should be executed directly
  • Manually installing dependencies — the script handles this automatically internally
  • Forgetting to read the output result and return it to the user
  • Fabricating recognition content when the portrait segmentation service call fails

API Reference Documentation

For detailed engine types, parameter descriptions, error codes, and other information, please refer to the documents in the references/ directory:

Core Script

  • scripts/main.py — Portrait Segmentation Script

Dependencies

  • Python 3.7+
  • tencentcloud-sdk-python(Tencent Cloud SDK,main.py used by

Install dependencies (optional - the script will install automatically):

pip install tencentcloud-sdk-python requests