tensorslab-image
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTensorsLab Image Generation
TensorsLab 图片生成
Overview
概述
This skill enables AI-powered image generation through TensorsLab's API, supporting both text-to-image and image-to-image workflows. The agent enhances user prompts with detailed visual descriptions before calling the API, ensuring high-quality outputs.
该Skill通过TensorsLab的API实现基于AI的图片生成,支持文本转图片和图片转图片两种工作流程。Agent在调用API前会为用户的提示词补充详细的视觉描述,确保生成高质量的输出结果。
Authentication Check
身份验证检查
Before any image generation, verify the API key is configured:
bash
undefined在进行任何图片生成操作前,请先验证是否已配置API密钥:
bash
undefinedCheck if API key is set
检查是否已设置API密钥
echo $TENSORSLAB_API_KEY
If not set, display this friendly message:
您好!要生成高质量的内容,您需要先进行简单的配置:
- 访问 https://test.tensorai.tensorslab.com/ 登录并订阅。
- 在控制台中获取您的专属 API Key。
- 将其保存为环境变量:
- Windows (PowerShell): $env:TENSORSLAB_API_KEY="您的Key"
- Mac/Linux: export TENSORSLAB_API_KEY="您的Key"
undefinedecho $TENSORSLAB_API_KEY
如果未设置,显示以下友好提示:
您好!要生成高质量的内容,您需要先进行简单的配置:
- 访问 https://test.tensorai.tensorslab.com/ 登录并订阅。
- 在控制台中获取您的专属 API Key。
- 将其保存为环境变量:
- Windows (PowerShell): $env:TENSORSLAB_API_KEY="您的Key"
- Mac/Linux: export TENSORSLAB_API_KEY="您的Key"
undefinedModels
模型
| Model | Description | Best For |
|---|---|---|
| seedreamv45 | Latest enhanced model | General purpose, highest quality |
| seedreamv4 | Standard model | Fast generation, good quality |
| zimage | Alternative model | Specific artistic styles |
Default:
seedreamv4| 模型 | 描述 | 适用场景 |
|---|---|---|
| seedreamv45 | 最新增强版模型 | 通用场景,最高画质 |
| seedreamv4 | 标准版模型 | 生成速度快,画质优良 |
| zimage | 替代模型 | 特定艺术风格 |
默认模型:
seedreamv4Workflow
工作流程
For additional scenarios beyond basic generation (avatar generation, watermark removal, object erasure, face replacement), see references/scenarios.md.
除基础生成外的其他场景(头像生成、水印去除、物体擦除、人脸替换),请查看references/scenarios.md。
1. Text-to-Image Generation
1. 文本转图片生成
User request: "画一个在月球上吃热狗的宇航员"
Agent processing:
- Extract the core subject and action
- Enhance prompt with details (lighting, composition, style, atmosphere)
- Call API with enriched prompt
- Monitor progress with heartbeat updates
- Download to
./tensorslab_output/
Example enhanced prompt:
An astronaut sitting on the lunar surface, eating a hot dog with mustard,
cinematic lighting, Earth visible in the background, highly detailed,
photorealistic, 8k quality, dramatic shadows from the low sun angle用户请求:"画一个在月球上吃热狗的宇航员"
Agent处理过程:
- 提取核心主体和动作
- 为提示词补充细节(光线、构图、风格、氛围)
- 使用优化后的提示词调用API
- 通过心跳更新跟踪进度
- 下载至
./tensorslab_output/
优化后提示词示例:
An astronaut sitting on the lunar surface, eating a hot dog with mustard,
cinematic lighting, Earth visible in the background, highly detailed,
photorealistic, 8k quality, dramatic shadows from the low sun angle2. Image-to-Image Generation
2. 图片转图片生成
User request: "把 cat.png 的背景换成太空" or "参考 sketch.png 渲染成 3D 模型"
Agent processing:
- Extract image file paths (absolute or relative to current directory)
- Enhance prompt with transformation instructions
- Upload source images with prompt
- Monitor and download results
Parameters for image-to-image:
- : Array of image files (for local upload)
sourceImage - : URL of source image
imageUrl - : Description of desired transformation
prompt
用户请求:"把 cat.png 的背景换成太空" 或 "参考 sketch.png 渲染成 3D 模型"
Agent处理过程:
- 提取图片文件路径(绝对路径或相对于当前目录的路径)
- 为提示词补充转换说明
- 上传源图片并附带提示词
- 跟踪进度并下载结果
图片转图片参数:
- : 图片文件数组(用于本地上传)
sourceImage - : 源图片的URL
imageUrl - : 期望转换效果的描述
prompt
3. Image Editing (General Purpose)
3. 通用图片编辑
General-purpose editing for any local image modifications.
User request examples:
- "把这张图的天空改成日落色"
- "给人物加上墨镜"
- "把头发颜色染成粉色"
Agent processing:
- Extract image file path
- Parse the specific editing instruction (what to change, where)
- Build enhanced prompt with precise editing guidance
- Call API with source image and editing prompt
- Save result to
./tensorslab_output/
Example enhanced prompt:
Change the sky to sunset colors with warm orange and pink gradients,
matching the existing lighting conditions and atmospheric perspective,
seamless blend at the horizon lineFor avatar generation, watermark removal, object erasure, and face replacement scenarios, see references/scenarios.md.
适用于任何本地图片的修改需求。
用户请求示例:
- "把这张图的天空改成日落色"
- "给人物加上墨镜"
- "把头发颜色染成粉色"
Agent处理过程:
- 提取图片文件路径
- 解析具体的编辑指令(修改内容、位置)
- 构建包含精准编辑指引的优化提示词
- 携带源图片和编辑提示词调用API
- 将结果保存至
./tensorslab_output/
优化后提示词示例:
Change the sky to sunset colors with warm orange and pink gradients,
matching the existing lighting conditions and atmospheric perspective,
seamless blend at the horizon line头像生成、水印去除、物体擦除、人脸替换等场景,请查看references/scenarios.md。
4. Resolution Options
4. 分辨率选项
Supported formats:
- Aspect ratios: ,
9:16,16:9,3:4,4:3,1:1,2:33:2 - Resolution levels: ,
2K4K - Specific dimensions: format (e.g.,
WxH,2048x2048)1920x1080- Constraint: Total pixels must be between 3,686,400 and 16,777,216
支持的格式:
- 宽高比: ,
9:16,16:9,3:4,4:3,1:1,2:33:2 - 分辨率级别: ,
2K4K - 自定义尺寸: 格式(例如:
WxH,2048x2048)1920x1080- 限制条件:总像素数必须在3,686,400到16,777,216之间
Using the Script
脚本使用方法
Execute the Python script directly:
bash
undefined直接执行Python脚本:
bash
undefinedText-to-image
文本转图片
python scripts/tensorslab_image.py "a cat on the moon"
python scripts/tensorslab_image.py "a cat on the moon"
With specific resolution
指定分辨率
python scripts/tensorslab_image.py "sunset over mountains" --resolution 16:9
python scripts/tensorslab_image.py "sunset over mountains" --resolution 16:9
Image-to-image
图片转图片
python scripts/tensorslab_image.py "watercolor style" --source cat.png
python scripts/tensorslab_image.py "watercolor style" --source cat.png
Specify model
指定模型
python scripts/tensorslab_image.py "cyberpunk city" --model seedreamv45
python scripts/tensorslab_image.py "cyberpunk city" --model seedreamv45
Custom output directory
自定义输出目录
python scripts/tensorslab_image.py "a beautiful landscape" --output-dir ./my_images
undefinedpython scripts/tensorslab_image.py "a beautiful landscape" --output-dir ./my_images
undefinedTask Status Flow
任务状态流程
| Status | Code | Meaning |
|---|---|---|
| Queued | 1 | Task waiting in queue |
| Processing | 2 | Currently generating |
| Completed | 3 | Done, images ready |
| Failed | 4 | Error occurred |
| 状态 | 代码 | 含义 |
|---|---|---|
| 排队中 | 1 | 任务等待处理 |
| 处理中 | 2 | 正在生成 |
| 已完成 | 3 | 生成完成,图片就绪 |
| 失败 | 4 | 发生错误 |
Error Handling
错误处理
Translate API errors to user-friendly messages:
| Error Code | Meaning | User Message |
|---|---|---|
| 9000 | Insufficient credits | "亲,积分用完啦,请前往 https://test.tensorai.tensorslab.com"/ 充值" |
| 9999 | General error | Show the specific error message |
将API错误转换为用户友好的提示信息:
| 错误代码 | 含义 | 用户提示 |
|---|---|---|
| 9000 | 积分不足 | "亲,积分用完啦,请前往 https://test.tensorai.tensorslab.com/ 充值" |
| 9999 | 通用错误 | 显示具体错误信息 |
Output
输出
All images are saved to output directory with naming pattern:
- Default: (current working directory)
./tensorslab_output/ - Custom: Use or
--output-dirto specify a different path-o - Naming: - e.g.,
{task_id}_{index}.{ext}abcd_1234567890_0.png
After completion, inform user:
🎉 您的图片处理完毕!已存放于 ./tensorslab_output/{filename}所有图片将保存至输出目录,命名规则如下:
- 默认路径:(当前工作目录)
./tensorslab_output/ - 自定义路径:使用或
--output-dir指定其他路径-o - 命名格式:- 例如:
{task_id}_{index}.{ext}abcd_1234567890_0.png
生成完成后,将向用户提示:
🎉 您的图片处理完毕!已存放于 ./tensorslab_output/{filename}Resources
资源
- scripts/tensorslab_image.py: Main API client with full CLI support
- references/api_reference.md: Detailed API documentation
- references/scenarios.md: Advanced usage scenarios (avatar generation, watermark removal, object erasure, face replacement)
- scripts/tensorslab_image.py: 完整支持CLI的主API客户端
- references/api_reference.md: 详细的API文档
- references/scenarios.md: 高级使用场景(头像生成、水印去除、物体擦除、人脸替换)