azure-ai-vision-imageanalysis-py – skill DevOps & Hạ tầng cho agent AI
SDK Azure AI Vision Image Analysis cho chú thích, thẻ, đối tượng, OCR, nhận diện người và cắt ảnh thông minh. Dùng cho các tác vụ thị giác máy tính và hiểu nội dung ảnh.
Cài skill azure-ai-vision-imageanalysis-py bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-ai-vision-imageanalysis-py-3621f.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /azure-ai-vision-imageanalysis-py – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-ai-vision-imageanalysis-py-3621f.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $azure-ai-vision-imageanalysis-py – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-ai-vision-imageanalysis-py-3621f.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /azure-ai-vision-imageanalysis-py – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-ai-vision-imageanalysis-py-3621f.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /azure-ai-vision-imageanalysis-py – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Azure AI Vision Image Analysis SDK for Python
Client library for Azure AI Vision 4.0 image analysis including captions, tags, objects, OCR, and more.
Installation
pip install azure-ai-vision-imageanalysisEnvironment Variables
VISION_ENDPOINT=https://<resource>.cognitiveservices.azure.com
VISION_KEY=<your-api-key> # If using API keyAuthentication
API Key
import os
from azure.ai.vision.imageanalysis import ImageAnalysisClient
from azure.core.credentials import AzureKeyCredential
endpoint = os.environ["VISION_ENDPOINT"]
key = os.environ["VISION_KEY"]
client = ImageAnalysisClient(
endpoint=endpoint,
credential=AzureKeyCredential(key)
)Entra ID (Recommended)
from azure.ai.vision.imageanalysis import ImageAnalysisClient
from azure.identity import DefaultAzureCredential
client = ImageAnalysisClient(
endpoint=os.environ["VISION_ENDPOINT"],
credential=DefaultAzureCredential()
)Data and inference boundary
Calls disclose supplied images or URLs to Azure. Confirm rights and privacy scope, region, service availability and current supported features. OCR/captions can be wrong; people detection does not identify people or establish age, identity, consent or sensitive traits. Review output before consequential use and avoid logging private OCR text.
Analyze Image from URL
from azure.ai.vision.imageanalysis.models import VisualFeatures
image_url = "https://example.com/image.jpg"
result = client.analyze_from_url(
image_url=image_url,
visual_features=[
VisualFeatures.CAPTION,
VisualFeatures.TAGS,
VisualFeatures.OBJECTS,
VisualFeatures.READ,
VisualFeatures.PEOPLE,
VisualFeatures.SMART_CROPS,
VisualFeatures.DENSE_CAPTIONS
],
gender_neutral_caption=True,
language="en"
)Analyze Image from File
with open("image.jpg", "rb") as f:
image_data = f.read()
result = client.analyze(
image_data=image_data,
visual_features=[VisualFeatures.CAPTION, VisualFeatures.TAGS]
)Image Caption
result = client.analyze_from_url(
image_url=image_url,
visual_features=[VisualFeatures.CAPTION],
gender_neutral_caption=True
)
if result.caption:
print(f"Caption: {result.caption.text}")
print(f"Confidence: {result.caption.confidence:.2f}")Dense Captions (Multiple Regions)
result = client.analyze_from_url(
image_url=image_url,
visual_features=[VisualFeatures.DENSE_CAPTIONS]
)
if result.dense_captions:
for caption in result.dense_captions.list:
print(f"Caption: {caption.text}")
print(f" Confidence: {caption.confidence:.2f}")
print(f" Bounding box: {caption.bounding_box}")Tags
result = client.analyze_from_url(
image_url=image_url,
visual_features=[VisualFeatures.TAGS]
)
if result.tags:
for tag in result.tags.list:
print(f"Tag: {tag.name} (confidence: {tag.confidence:.2f})")Object Detection
result = client.analyze_from_url(
image_url=image_url,
visual_features=[VisualFeatures.OBJECTS]
)
if result.objects:
for obj in result.objects.list:
print(f"Object: {obj.tags[0].name}")
print(f" Confidence: {obj.tags[0].confidence:.2f}")
box = obj.bounding_box
print(f" Bounding box: x={box.x}, y={box.y}, w={box.width}, h={box.height}")OCR (Text Extraction)
result = client.analyze_from_url(
image_url=image_url,
visual_features=[VisualFeatures.READ]
)
if result.read:
for block in result.read.blocks:
for line in block.lines:
print(f"Line: {line.text}")
print(f" Bounding polygon: {line.bounding_polygon}")
# Word-level details
for word in line.words:
print(f" Word: {word.text} (confidence: {word.confidence:.2f})")People Detection
result = client.analyze_from_url(
image_url=image_url,
visual_features=[VisualFeatures.PEOPLE]
)
if result.people:
for person in result.people.list:
print(f"Person detected:")
print(f" Confidence: {person.confidence:.2f}")
box = person.bounding_box
print(f" Bounding box: x={box.x}, y={box.y}, w={box.width}, h={box.height}")Smart Cropping
result = client.analyze_from_url(
image_url=image_url,
visual_features=[VisualFeatures.SMART_CROPS],
smart_crops_aspect_ratios=[0.9, 1.33, 1.78] # Portrait, 4:3, 16:9
)
if result.smart_crops:
for crop in result.smart_crops.list:
print(f"Aspect ratio: {crop.aspect_ratio}")
box = crop.bounding_box
print(f" Crop region: x={box.x}, y={box.y}, w={box.width}, h={box.height}")Async Client
from azure.ai.vision.imageanalysis.aio import ImageAnalysisClient
from azure.identity.aio import DefaultAzureCredential
async def analyze_image():
async with ImageAnalysisClient(
endpoint=endpoint,
credential=DefaultAzureCredential()
) as client:
result = await client.analyze_from_url(
image_url=image_url,
visual_features=[VisualFeatures.CAPTION]
)
if result.caption:
print(result.caption.text)Visual Features
| Feature | Description |
|---------|-------------|
| CAPTION | Single sentence describing the image |
| DENSE_CAPTIONS | Captions for multiple regions |
| TAGS | Content tags (objects, scenes, actions) |
| OBJECTS | Object detection with bounding boxes |
| READ | OCR text extraction |
| PEOPLE | People detection with bounding boxes |
| SMART_CROPS | Suggested crop regions for thumbnails |
Error Handling
from azure.core.exceptions import HttpResponseError
try:
result = client.analyze_from_url(
image_url=image_url,
visual_features=[VisualFeatures.CAPTION]
)
except HttpResponseError as e:
print(f"Status code: {e.status_code}")
print(f"Reason: {e.reason}")
print(f"Message: {e.error.message}")Image Requirements
- Formats: JPEG, PNG, GIF, BMP, WEBP, ICO, TIFF, MPO
- Max size: 20 MB
- Dimensions: 50x50 to 16000x16000 pixels
Best Practices
1. Select only needed features to optimize latency and cost
2. Use async client for high-throughput scenarios
3. Handle HttpResponseError for invalid images or auth issues
4. Enable gender_neutral_caption for inclusive descriptions
5. Specify language for localized captions
6. Use smart_crops_aspect_ratios matching your thumbnail requirements
7. Cache results when analyzing the same image multiple times
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Skill liên quan
- azure-ai-voicelive-dotnet – SDK Azure AI Voice Live cho .NET. Xây dựng ứng dụng AI giọng nói thời gian thực với giao…
- azure-ai-voicelive-py – Xây dựng ứng dụng AI giọng nói thời gian thực với giao tiếp WebSocket hai chiều.
- azure-ai-voicelive-ts – SDK Azure AI Voice Live cho JavaScript/TypeScript. Xây dựng ứng dụng AI giọng nói thời…
- azure-aks – Triển khai và quản lý cụm Azure Kubernetes Service. Cấu hình node pool, mạng và tích…
- azure-appconfiguration-py – SDK Azure App Configuration cho Python. Dùng để quản lý cấu hình tập trung, feature flag…
- azure-appconfiguration-ts – Quản lý cấu hình tập trung với feature flag và làm mới động.
- azure-communication-callautomation-java – Xây dựng quy trình tự động hóa cuộc gọi phía máy chủ, bao gồm hệ thống IVR, định tuyến…
- azure-communication-chat-java – Xây dựng ứng dụng chat thời gian thực với quản lý luồng, nhắn tin, người tham gia và xác…