modelscope-zimage-generator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseModelScope Z-Image Generator
ModelScope Z-Image 生成器
Generate images using ModelScope's Z-Image series models.
使用ModelScope的Z-Image系列模型生成图片。
IMPORTANT: Response Format
重要提示:响应格式
After generating an image, you MUST:
- Use the Python script to generate the image
- Respond with ONLY a simple text message like: "Image saved to: /path/to/output.jpg"
- DO NOT include the image URL in your response
- DO NOT try to display or reference the image URL - this will cause errors with non-multimodal models
The user can view the generated image at the file path you provide.
生成图片后,你必须:
- 使用Python脚本生成图片
- 仅回复简单的文本消息,例如:"图片已保存至:/path/to/output.jpg"
- 请勿在回复中包含图片URL
- 请勿尝试展示或引用图片URL - 这会导致非多模态模型出错
用户可以通过你提供的文件路径查看生成的图片。
Prerequisites
前置条件
Get your ModelScope API key from: https://modelscope.cn/my/myaccesstoken
The script will automatically prompt for your API key the first time you use it and offer to save it for future use.
Optional: Manual Configuration
You can also manually configure the API key:
Config file:
bash
mkdir -p ~/.config/modelscope
cat > ~/.config/modelscope/config.json << EOF
{
"api_key": "ms-your-api-key-here"
}
EOFEnvironment variable:
bash
export MODELSCOPE_API_KEY="ms-your-api-key-here"从以下地址获取你的ModelScope API密钥:https://modelscope.cn/my/myaccesstoken
首次使用脚本时,它会自动提示你输入API密钥,并提供保存密钥以便后续使用的选项。
可选:手动配置
你也可以手动配置API密钥:
配置文件:
bash
mkdir -p ~/.config/modelscope
cat > ~/.config/modelscope/config.json << EOF
{
"api_key": "ms-your-api-key-here"
}
EOF环境变量:
bash
export MODELSCOPE_API_KEY="ms-your-api-key-here"Quick Start
快速开始
Use the Python script to generate images:
bash
cd /Users/ningoo/.claude/skills/modelscope-image-generator/scripts
python generate_image.py "A golden cat" output.jpg使用Python脚本生成图片:
bash
cd /Users/ningoo/.claude/skills/modelscope-image-generator/scripts
python generate_image.py "一只金色的猫" output.jpgModels
模型
Available Z-Image models:
- (default, fast generation)
Tongyi-MAI/Z-Image-Turbo - (balanced quality and speed)
Tongyi-MAI/Z-Image - (image editing)
Tongyi-MAI/Z-Image-Edit
可用的Z-Image模型:
- (默认,生成速度快)
Tongyi-MAI/Z-Image-Turbo - (画质与速度平衡)
Tongyi-MAI/Z-Image - (图片编辑)
Tongyi-MAI/Z-Image-Edit
Model Selection Rule
模型选择规则
- If the user explicitly mentions "Z-Image-Turbo", use
Tongyi-MAI/Z-Image-Turbo - If the user explicitly mentions "Z-Image" (without Turbo), use
Tongyi-MAI/Z-Image - Otherwise, use the default
Tongyi-MAI/Z-Image-Turbo
Specify a different model using :
--modelbash
python generate_image.py "A golden cat" output.jpg --model "Tongyi-MAI/Z-Image-Turbo"- 如果用户明确提到"Z-Image-Turbo",使用
Tongyi-MAI/Z-Image-Turbo - 如果用户明确提到"Z-Image"(不带Turbo),使用
Tongyi-MAI/Z-Image - 否则,使用默认的
Tongyi-MAI/Z-Image-Turbo
使用参数指定其他模型:
--modelbash
python generate_image.py "一只金色的猫" output.jpg --model "Tongyi-MAI/Z-Image-Turbo"LoRA Support
LoRA支持
Single LoRA:
python
"loras": "<lora-repo-id>"Multiple LoRAs (weights must sum to 1.0):
python
"loras": {"<lora-id1>": 0.6, "<lora-id2>": 0.4}单个LoRA:
python
"loras": "<lora-repo-id>"多个LoRA(权重总和必须为1.0):
python
"loras": {"<lora-id1>": 0.6, "<lora-id2>": 0.4}API Flow
API流程
- Submit generation request with
X-ModelScope-Async-Mode: true - Receive in response
task_id - Poll with
/v1/tasks/{task_id}X-ModelScope-Task-Type: image_generation - Wait for status or
SUCCEEDFAILED - Download image from URL
output_images[0]
- 提交生成请求时携带
X-ModelScope-Async-Mode: true - 在响应中接收
task_id - 携带轮询
X-ModelScope-Task-Type: image_generation/v1/tasks/{task_id} - 等待状态变为或
SUCCEEDFAILED - 从对应的URL下载图片
output_images[0]