NVIDIA Image Generation
Generate and edit images using NVIDIA's FLUX models.
Models
| Model | Use Case | Speed | Quality |
|---|
| INLINECODE0 | High-quality text-to-image | Normal | Best |
| INLINECODE1 |
Fast text-to-image | Fast | Good |
|
kontext | Image editing | Normal | Best |
Quick Start
CODEBLOCK0
Parameters
Text-to-Image (dev/schnell)
| Parameter | Short | Default | Description |
|---|
| INLINECODE3 | | (required) | Text description |
| INLINECODE4 |
| output.png | Output file path |
|
--width | | 1024 | Output width in pixels |
|
--height | | 1024 | Output height in pixels |
|
--aspect-ratio |
-ar | 1:1 | Aspect ratio preset |
|
--steps |
-s | 30 | Diffusion steps |
|
--seed | | 0 | Random seed (0=random) |
|
--model |
-m | auto | Model selection |
Image Editing (kontext)
| Parameter | Short | Default | Description |
|---|
| INLINECODE14 | | (required) | Edit instruction |
| INLINECODE15 |
| (required) | Input image path |
|
-o, --output | | output.png | Output file path |
|
--steps |
-s | 30 | Diffusion steps |
|
--cfg | | 3.5 | Guidance scale |
|
--seed | | 0 | Random seed |
Supported Aspect Ratios
| Ratio | Resolution |
|---|
| 1:1 | 1024×1024 |
| 16:9 |
1344×768 |
| 9:16 | 768×1344 |
| 4:3 | 1216×832 |
| 3:4 | 832×1216 |
Examples
Basic Generation
CODEBLOCK1
Wide Format (16:9)
CODEBLOCK2
Portrait Mode (9:16)
CODEBLOCK3
Custom Size
CODEBLOCK4
Fast Generation
CODEBLOCK5
Edit an Image
CODEBLOCK6
Reproducible Results
CODEBLOCK7
Output
The script outputs MEDIA:/path/to/image.png which can be sent directly to chat.
API Key
The API key is embedded in the script. To use a different key, set the NVIDIA_API_KEY environment variable.
NVIDIA 图像生成
使用 NVIDIA 的 FLUX 模型生成和编辑图像。
模型
| 模型 | 用途 | 速度 | 质量 |
|---|
| dev | 高质量文生图 | 正常 | 最佳 |
| schnell |
快速文生图 | 快速 | 良好 |
| kontext | 图像编辑 | 正常 | 最佳 |
快速开始
bash
生成图像
python scripts/generate.py 一只在太空中的可爱猫咪
编辑现有图像
python scripts/generate.py 添加太阳镜 -i photo.jpg -o edited.png
参数
文生图 (dev/schnell)
| 参数 | 简写 | 默认值 | 描述 |
|---|
| prompt | | (必填) | 文本描述 |
| -o, --output |
| output.png | 输出文件路径 |
| --width | | 1024 | 输出宽度(像素) |
| --height | | 1024 | 输出高度(像素) |
| --aspect-ratio | -ar | 1:1 | 宽高比预设 |
| --steps | -s | 30 | 扩散步数 |
| --seed | | 0 | 随机种子(0=随机) |
| --model | -m | auto | 模型选择 |
图像编辑 (kontext)
| 参数 | 简写 | 默认值 | 描述 |
|---|
| prompt | | (必填) | 编辑指令 |
| -i, --input |
| (必填) | 输入图像路径 |
| -o, --output | | output.png | 输出文件路径 |
| --steps | -s | 30 | 扩散步数 |
| --cfg | | 3.5 | 引导尺度 |
| --seed | | 0 | 随机种子 |
支持的宽高比
1344×768 |
| 9:16 | 768×1344 |
| 4:3 | 1216×832 |
| 3:4 | 832×1216 |
示例
基础生成
bash
python scripts/generate.py 日落时的山景
宽屏格式 (16:9)
bash
python scripts/generate.py 全景海滩景观 -ar 16:9
竖屏模式 (9:16)
bash
python scripts/generate.py 专业头像照 -ar 9:16
自定义尺寸
bash
python scripts/generate.py 横幅图像 --width 1344 --height 768
快速生成
bash
python scripts/generate.py 机器人的快速草图 -m schnell
编辑图像
bash
python scripts/generate.py 将背景改为日落 -i input.jpg -o output.png
可复现结果
bash
python scripts/generate.py 一个机器人 --seed 12345
输出
脚本输出 MEDIA:/path/to/image.png,可直接发送到聊天中。
API 密钥
API 密钥已嵌入脚本中。要使用不同的密钥,请设置 NVIDIAAPIKEY 环境变量。