文章目录
- 一、课程核心思想
- 二、重点知识点
-
- [2.1 什么是 Image Generation?](#2.1 什么是 Image Generation?)
- [2.2 Text-to-Image(文生图)](#2.2 Text-to-Image(文生图))
- [2.3 Image-to-Image(图生图)](#2.3 Image-to-Image(图生图))
- [2.4 Image Editing(图像编辑)](#2.4 Image Editing(图像编辑))
- [2.5 Iterative Image Generation(迭代式图像生成)](#2.5 Iterative Image Generation(迭代式图像生成))
- [2.6 Image Generation 与 Context 的关系](#2.6 Image Generation 与 Context 的关系)
- 三、课程案例与应用分析
-
- [3.1 案例一:生成产品宣传图片](#3.1 案例一:生成产品宣传图片)
- [3.2 案例二:利用草图生成设计概念](#3.2 案例二:利用草图生成设计概念)
- [3.3 案例三:修改已有图片](#3.3 案例三:修改已有图片)
- [四、如何写出更好的 Image Generation Prompt?](#四、如何写出更好的 Image Generation Prompt?)
-
- [4.1 普通 Prompt](#4.1 普通 Prompt)
- [4.2 改进后的 Prompt](#4.2 改进后的 Prompt)
- [4.3 为什么第二个 Prompt 更好?](#4.3 为什么第二个 Prompt 更好?)
- [五、Image Generation 的局限性](#五、Image Generation 的局限性)
-
- [5.1 Prompt Following Errors(指令遵循错误)](#5.1 Prompt Following Errors(指令遵循错误))
- [5.2 Visual Inconsistency(视觉不一致)](#5.2 Visual Inconsistency(视觉不一致))
- [5.3 Editing Drift(编辑漂移)](#5.3 Editing Drift(编辑漂移))
- [5.4 Image Generation 不等于精确设计工具](#5.4 Image Generation 不等于精确设计工具)
- [5.5 Copyright and Privacy(版权与隐私)](#5.5 Copyright and Privacy(版权与隐私))
- 六、重要英文术语
- 七、实践练习
- 八、复习问题
- [九、一页速记版(Quick Review)](#九、一页速记版(Quick Review))
- 参考资源
- [课程 Slides](#课程 Slides)
- The AI Novice and the AI Power User:如何成为 AI 高阶用户
- Pretrained Knowledge:AI 已经掌握哪些知识
- Web Search:如何获取外部信息
- Web Search Sources:如何选择和验证信息来源
- Using Deep Research:如何开展复杂研究
- Lab Overview:如何通过实验比较不同 AI 使用方式
- Brainstorming with AI:使用 AI 进行头脑风暴
- Context:上下文
- AI Desktop Apps:AI 桌面应用
- Reasoning with AI:AI 推理
- Sycophancy:谄媚
- Writing with AI:用 AI 写作
- AI Critique:AI 评价与批判性反馈
- Lab Overview: Brainstorming and Critique:实验介绍:AI 头脑风暴与批判性评价
- Working with Multimedia Data:处理多媒体数据
- Imaging Understanding:图像理解
一、课程核心思想
上一节 P16 介绍了 Image Understanding(图像理解)。我们已经知道,多模态 AI 可以分析图片中的物体、文字、结构和视觉关系。但 AI 不仅能够理解图片,还能够根据用户的要求创造新的图片。
例如:
- 根据文字描述生成插画。
- 为产品设计宣传图片。
- 为演示文稿制作配图。
- 根据草图生成更完整的设计。
- 修改已有图片中的颜色、背景或物体。
- 根据用户反馈不断调整图像效果。
因此,本节介绍 Image Generation(图像生成)。
核心结论:Image Generation 让用户能够通过自然语言表达视觉创意,并利用 AI 快速生成和修改图片。高阶用户不需要一次性写出完美的 Prompt,而是可以通过明确需求、提供参考图片和反复迭代,逐步获得符合目标的视觉成果。
二、重点知识点
2.1 什么是 Image Generation?
Image Generation(图像生成) 是指 AI 根据文字、图片或其他条件生成新的图像内容。最常见的形式是:Text-to-Image(文生图)。即用户输入一段文字描述,AI 根据描述生成图片。
例如:
Generate an illustration of a small
robot studying in a university library.
Style: modern digital illustration.
Lighting: warm and soft.
Composition: the robot sits at a desk
with books and a laptop.
AI 可以根据这些要求生成相应的画面。
Image Understanding vs. Image Generation
| 对比维度 | Image Understanding | Image Generation |
|---|---|---|
| 中文 | 图像理解 | 图像生成 |
| 主要输入 | 已有图片 | 文字、参考图片 |
| 核心任务 | 分析视觉信息 | 创造视觉内容 |
| 典型问题 | 这张图片展示了什么? | 帮我生成一张图片 |
| 主要输出 | 文字分析 | 新图片 |
| 常见应用 | 图片识别、图表分析 | 插画、海报、设计 |
| 主要局限 | 可能识别错误 | 可能不符合要求或产生视觉错误 |
知识点:Image Understanding 主要是从图片中提取信息,而 Image Generation 主要是根据用户要求创造视觉内容。
2.2 Text-to-Image(文生图)
Text-to-Image 是最常见的图像生成方式。用户通过 Prompt 描述希望得到的画面。
例如:
Create a realistic image of a
modern university classroom.
Include:
- Students using laptops
- A professor presenting AI concepts
- A large digital display
- Natural daylight
Style: professional photography.
一个有效的 Image Generation Prompt 可以包含什么?通常可以从以下维度描述:
- Subject(主体):图片中最重要的对象。
- Scene(场景):主体所处的环境。
- Style(风格):图片的视觉表现方式。
- Composition(构图):主体在画面中的位置。
- Lighting(光照):光线方向、强度和氛围。
- Color Palette(配色):整体色彩倾向。
- Aspect Ratio(宽高比):图片的形状。
- Constraints(约束):需要避免或特别注意的内容。
示例 Prompt
Generate an image of a futuristic
AI research laboratory.
Subject:
A researcher working with an AI system.
Scene:
A modern laboratory with large screens
and scientific equipment.
Style:
Photorealistic.
Composition:
Wide-angle view with the researcher
in the foreground.
Lighting:
Soft blue ambient lighting.
Aspect Ratio:
16:9.
Constraints:
No logos or watermarks.
Prompt 结构总结
| Prompt 要素 | 作用 |
|---|---|
| Subject | 确定画面主体 |
| Scene | 确定背景环境 |
| Style | 控制视觉风格 |
| Composition | 控制画面布局 |
| Lighting | 控制光照与氛围 |
| Color Palette | 控制色彩 |
| Aspect Ratio | 控制画面比例 |
| Constraints | 明确限制条件 |
学习启示:图像 Prompt 不需要机械地包含所有要素。应根据实际需求,优先说明对最终画面影响最大的条件。
2.3 Image-to-Image(图生图)
除了根据文字生成图片,AI 还可以使用已有图片作为参考。这种方式通常称为:Image-to-Image(图生图)
例如:用户上传一张简单的房间照片,希望将其改造成现代风格。
可以提出:
Use the uploaded room image
as the starting point.
Redesign the room in a modern
minimalist style.
Requirements:
- Preserve the room layout.
- Keep the windows in their
original positions.
- Replace the furniture.
- Use neutral colors.
- Add warm lighting.
为什么需要参考图片?因为图片可以提供文字难以完整表达的信息。
例如:
- 房间的空间结构。
- 物体之间的位置关系。
- 原有颜色。
- 具体形状。
- 视觉细节。
Text-to-Image vs. Image-to-Image
| 对比维度 | Text-to-Image | Image-to-Image |
|---|---|---|
| 中文 | 文生图 | 图生图 |
| 主要输入 | 文字描述 | 图片与文字指令 |
| 是否有原始画面 | 通常没有 | 有 |
| 主要用途 | 创造新画面 | 修改或参考已有画面 |
| 控制重点 | 描述目标图像 | 保留与修改哪些部分 |
| 常见问题 | 画面不符合想象 | 不应修改的部分发生变化 |
知识点:当你已经拥有接近目标的图片时,使用参考图片进行修改,通常比从零开始重新描述整个画面更加方便。
2.4 Image Editing(图像编辑)
Image Editing(图像编辑) 指利用 AI 修改已有图片。
例如:
- 更换背景。
- 删除物体。
- 添加物体。
- 修改颜色。
- 调整视觉风格。
- 扩展图片边界。
示例一:更换背景
Replace the background with
a modern university campus.
Keep the main subject unchanged.
Preserve realistic lighting
and natural shadows.
示例二:删除物体
Remove the unwanted objects
from the background.
Keep the main subject and
overall composition unchanged.
Fill the removed areas naturally.
示例三:修改风格
Transform this image into
a watercolor illustration.
Preserve the main composition
and recognizable objects.
Use soft colors and
natural watercolor textures.
常见编辑任务
| 英文 | 中文 | 作用 |
|---|---|---|
| Background Replacement | 背景替换 | 更换图片背景 |
| Object Removal | 物体移除 | 删除不需要的对象 |
| Object Addition | 添加物体 | 在图片中增加内容 |
| Style Transfer | 风格迁移 | 改变图片视觉风格 |
| Inpainting | 局部重绘 | 修改图片的指定区域 |
| Outpainting | 画面扩展 | 扩展图片原有边界 |
学习启示:图像编辑 Prompt 应明确说明哪些内容需要改变,以及哪些内容必须保留。
2.5 Iterative Image Generation(迭代式图像生成)
这与 P12 的 Iterative Writing(迭代式写作) 有相似之处。第一次生成的图片不一定完全符合预期。
例如,用户希望制作一张 AI 课程宣传图。
Step 1:生成初始图片
Create a promotional image
for a university AI course.
Style: modern and professional.
Include students and AI-related
visual elements.
Step 2:评价结果
假设第一次生成的图片存在问题:
- 主体不够突出。
- 背景过于复杂。
- 色彩不协调。
- 没有为标题留出空间。
Step 3:提出具体修改要求
Revise the previous image.
Changes:
1. Make the student the main subject.
2. Simplify the background.
3. Use a blue and white color palette.
4. Leave empty space on the left
for a course title.
Preserve the overall visual style.
Step 4:继续迭代
Keep the current composition.
Make the lighting softer
and increase the contrast
between the subject and background.
Do not add any text.
完整流程
Describe Visual Goal
(描述视觉目标)
↓
Generate Initial Image
(生成初始图片)
↓
Evaluate the Result
(评价生成结果)
↓
Identify Problems
(识别问题)
↓
Provide Specific Feedback
(提出具体修改要求)
↓
Regenerate or Edit
(重新生成或编辑)
↓
Final Image
(获得最终图片)
核心知识点:图像生成可以通过多轮交互逐步完善。与其反复从零开始生成,不如在已有结果的基础上提出明确修改要求。
2.6 Image Generation 与 Context 的关系
P08 已经介绍过 Context 的重要性。在图像生成任务中,Context 同样可以提高结果的针对性。
例如:用户希望生成一张网站首页图片。
如果只说:
Generate a website hero image.
AI 不知道:
- 网站属于什么行业。
- 面向哪些用户。
- 品牌的视觉风格。
- 图片将放在什么位置。
- 是否需要为文字留白。
改进后的 Prompt
Create a hero image for
an AI education platform.
Context:
The platform helps university
students learn machine learning.
Target Audience:
University students aged 18--25.
Visual Style:
Modern, clean, and academic.
Color Palette:
Blue, white, and light gray.
Composition:
Place the main visual elements
on the right side.
Leave negative space on the left
for a headline and button.
Aspect Ratio:
16:9.
Context 的作用
| Context 类型 | 具体内容 | 对图片的影响 |
|---|---|---|
| Brand Identity | 品牌定位 | 视觉风格 |
| Target Audience | 目标用户 | 设计语言 |
| Usage Scenario | 使用场景 | 图片尺寸与布局 |
| Color Palette | 配色要求 | 色彩一致性 |
| Reference Image | 参考图片 | 视觉方向 |
| Constraints | 限制条件 | 减少不符合要求的内容 |
学习启示:好的图像生成 Prompt 不只是描述图片中有什么,还应该说明图片为什么被创建、将用于哪里。
三、课程案例与应用分析
核实说明:以下案例是根据 Image Generation 主题设计的教学补充。目前没有足够依据确认它们是吴恩达在 P17 中实际演示的案例。
3.1 案例一:生成产品宣传图片
假设你正在开发一款 AI 学习助手,希望制作产品宣传图。
普通 Prompt
Generate an image for my AI app.
这个 Prompt 缺少具体要求。
改进后的 Prompt
Create a promotional image
for an AI-powered learning assistant.
Scene:
A university student studying
at a desk with a laptop.
Visual Elements:
- Digital learning interface
- Books and study materials
- Subtle AI-inspired graphics
Style:
Modern digital illustration.
Composition:
Place the student on the right.
Leave empty space on the left
for marketing text.
Color Palette:
Blue, white, and soft purple.
Aspect Ratio:
16:9.
Do not include text or logos.
为什么第二个 Prompt 更好?
因为它明确了:
- 图片用途。
- 目标用户。
- 主要主体。
- 视觉风格。
- 构图。
- 配色。
- 图片比例。
知识点:当图片需要用于具体产品或商业场景时,应明确最终用途,而不是只描述一个抽象主题。
3.2 案例二:利用草图生成设计概念
假设你手绘了一个移动应用界面。
可以上传草图并提出:
Use the uploaded sketch
as a reference.
Create a polished mobile app
interface concept.
Requirements:
1. Preserve the main layout.
2. Use a modern visual style.
3. Improve spacing and alignment.
4. Use a consistent color palette.
5. Maintain clear visual hierarchy.
Do not introduce major features
that are not present in the sketch.
为什么这个案例有价值?
因为用户不需要具备专业绘画能力,也可以通过简单草图表达设计意图。AI 可以帮助将初步视觉概念转化为更完整的效果图。但需要注意:生成的 UI 图片不等于可运行的软件界面。如果需要真正可点击、可编辑或可运行的界面,还需要进一步使用设计或编程工具。
3.3 案例三:修改已有图片
假设你有一张产品照片,希望修改背景用于宣传。
Step 1:上传原始图片
图片中包含产品和原始背景。
Step 2:提出修改要求
Edit the uploaded product photo.
Replace the background with
a clean studio environment.
Requirements:
- Keep the product unchanged.
- Preserve the product's proportions.
- Use soft professional lighting.
- Add a natural shadow.
- Do not add text or logos.
Step 3:检查结果
重点检查:
- 产品形状是否发生变化?
- 是否出现不自然的边缘?
- 光照与阴影是否一致?
- 是否修改了不应该改变的细节?
知识点:图像编辑不仅需要检查新内容是否符合要求,还需要检查原始内容是否被意外改变。
四、如何写出更好的 Image Generation Prompt?
4.1 普通 Prompt
Generate a futuristic city.
这个 Prompt 可以生成图片,但视觉方向比较宽泛。
4.2 改进后的 Prompt
Generate a futuristic city
at sunset.
Scene:
A modern city with elevated
transportation systems and
sustainable architecture.
Subject:
A pedestrian walking through
a futuristic urban plaza.
Style:
Cinematic science-fiction concept art.
Composition:
Wide-angle view with strong depth.
Lighting:
Warm sunset light combined
with subtle blue ambient lighting.
Color Palette:
Orange, blue, and dark gray.
Aspect Ratio:
16:9.
Constraints:
- No text
- No logos
- No watermarks
4.3 为什么第二个 Prompt 更好?
| Prompt 要素 | 具体内容 |
|---|---|
| Subject | 城市广场中的行人 |
| Scene | 未来城市 |
| Style | 电影感科幻概念艺术 |
| Composition | 广角、纵深 |
| Lighting | 日落光线与蓝色环境光 |
| Color Palette | 橙、蓝、深灰 |
| Aspect Ratio | 16:9 |
| Constraints | 不添加文字和标志 |
通用 Image Generation Prompt 模板
Create an image for [PURPOSE].
Subject:
[Describe the main subject.]
Scene:
[Describe the environment.]
Style:
[Specify the visual style.]
Composition:
[Describe framing and placement.]
Lighting:
[Specify lighting conditions.]
Color Palette:
[Specify preferred colors.]
Aspect Ratio:
[Specify image dimensions or ratio.]
Constraints:
[List important requirements
and things to avoid.]
重要提醒:更长的 Prompt 不一定产生更好的图片。过多互相冲突的要求,反而可能降低结果质量。
五、Image Generation 的局限性
5.1 Prompt Following Errors(指令遵循错误)
AI 可能无法准确满足所有要求。
例如:用户要求图片中出现五个人,模型却生成了四个人或六个人。
因此,对于精确数量、空间位置和复杂关系,需要仔细检查。
5.2 Visual Inconsistency(视觉不一致)
生成图片可能出现:
- 物体结构不合理。
- 人物手部细节异常。
- 文字拼写错误。
- 光照和阴影不一致。
- 物体之间的空间关系错误。
不同图像模型在这些方面的表现有所不同。
5.3 Editing Drift(编辑漂移)
在多轮修改中,AI 可能意外改变用户希望保留的内容。
例如:用户只要求修改背景,但模型同时改变了产品形状。
因此,可以明确要求:
Only modify the background.
Preserve the subject, pose,
proportions, and composition.
但即使这样,也不能保证所有细节完全不变。
5.4 Image Generation 不等于精确设计工具
生成式 AI 很适合:
- 创意探索。
- 视觉概念设计。
- 初步插画。
- 宣传素材。
- 设计灵感。
但对于需要精确尺寸、可编辑图层、工程结构或真实交互的任务,通常还需要专业工具。
例如:
- Figma
- Photoshop
- Illustrator
- CAD 软件
- 编程开发工具
5.5 Copyright and Privacy(版权与隐私)
使用 AI 生成或编辑图片时,还应考虑:
- 是否有权使用上传的参考图片。
- 是否涉及未经授权的个人肖像。
- 是否可能误导他人相信生成内容是真实照片。
- 商业使用是否符合所用工具的条款。
学习启示:AI 图像生成是创作辅助工具,仍然需要用户负责内容审查和合理使用。
六、重要英文术语
| English | 中文 | 解释 |
|---|---|---|
| Image Generation | 图像生成 | 使用 AI 创建图像 |
| Text-to-Image | 文生图 | 根据文字生成图片 |
| Image-to-Image | 图生图 | 利用参考图片生成新图像 |
| Image Editing | 图像编辑 | 修改已有图片 |
| Generative AI | 生成式人工智能 | 能够生成新内容的 AI |
| Subject | 主体 | 图片中的主要对象 |
| Scene | 场景 | 图片中的环境 |
| Style | 风格 | 图片的视觉表现方式 |
| Composition | 构图 | 画面元素的布局 |
| Lighting | 光照 | 图片中的光线效果 |
| Color Palette | 配色方案 | 图片使用的主要颜色 |
| Aspect Ratio | 宽高比 | 图片宽度与高度的比例 |
| Reference Image | 参考图片 | 用于指导生成的已有图片 |
| Style Transfer | 风格迁移 | 改变图片的视觉风格 |
| Inpainting | 局部重绘 | 修改指定区域 |
| Outpainting | 画面扩展 | 扩展图片边界 |
| Iterative Generation | 迭代式生成 | 多轮修改生成结果 |
| Visual Consistency | 视觉一致性 | 不同视觉元素保持协调 |
| Editing Drift | 编辑漂移 | 修改时意外改变其他内容 |
| Negative Space | 留白 | 为文字或其他元素预留空间 |
七、实践练习
Exercise 1:比较简单与详细 Prompt
首先使用:
Generate an image of a university library.
然后使用:
Generate a modern university library
with students studying at wooden desks.
Style:
Photorealistic.
Lighting:
Warm afternoon sunlight.
Composition:
Wide-angle interior view.
Color Palette:
Warm brown, cream, and soft green.
Aspect Ratio:
16:9.
比较:
- 两次生成的图片有什么区别?
- 哪张图片更符合你的预期?
- 哪些 Prompt 要素影响最明显?
- 是否出现不符合要求的细节?
练习目标:理解视觉描述如何影响图像生成结果。
Exercise 2:练习 Iterative Image Generation
首先生成一张 AI 课程宣传图片。
然后分三轮修改:
- 调整构图。
- 修改配色和光照。
- 简化背景并增加留白。
每轮只修改少量要求。
观察:
- 图片是否逐渐接近目标?
- 哪些内容被意外改变?
- AI 是否保留了原始主体?
- 哪些修改指令最有效?
练习目标:掌握通过多轮反馈完善图像的方法。
Exercise 3:使用参考图片进行编辑
选择一张自己拥有使用权的图片。
上传后使用:
Use the uploaded image as a reference.
Change the visual style
to a clean digital illustration.
Preserve:
1. Main subject
2. Composition
3. Important objects
4. Spatial relationships
Modify:
1. Color palette
2. Lighting
3. Background style
Do not add new objects.
比较修改前后的结果。
练习目标:理解 Image-to-Image 与 Image Editing 的实际应用。
以上练习为根据课程主题设计的教学补充,尚未确认是 P17 的官方实验内容。
八、复习问题
Q1:什么是 Image Generation?
答:利用 AI 根据文字、图片或其他条件生成新的视觉内容。
Q2:Text-to-Image 与 Image-to-Image 有什么区别?
答:Text-to-Image 主要根据文字生成图片;Image-to-Image 则利用已有图片作为参考进行生成或修改。
Q3:一个好的 Image Generation Prompt 通常包含哪些信息?
答:可以包含主体、场景、风格、构图、光照、配色、宽高比和重要约束。
Q4:为什么需要 Iterative Image Generation?
答:因为初次生成的结果可能不符合预期,通过多轮反馈可以逐步调整画面。
Q5:什么是 Editing Drift?
答:在编辑图片时,AI 意外修改了用户原本希望保留的内容。
Q6:为什么 AI 生成的界面图片不能直接当作可运行的软件?
答:因为图片只是视觉呈现,不具备真实的代码结构、数据逻辑和交互功能。
九、一页速记版(Quick Review)
核心思想:Image Generation 让用户能够通过自然语言和参考图片创建、编辑视觉内容。高阶用户需要学会明确视觉目标、提供合适的 Context,并通过多轮迭代完善结果。
三个重要能力:
- Text-to-Image:根据文字描述生成图片。
- Image-to-Image:利用参考图片指导生成。
- Image Editing:修改已有图片中的内容。
三个核心原则:
- Describe the visual goal clearly.
清楚描述希望生成的视觉效果。 - Use reference images when appropriate.
在合适的情况下使用参考图片。 - Iterate and refine instead of expecting perfection immediately.
通过多轮修改逐步完善结果,而不是期待第一次生成就完全符合要求。
P15 → P17 的知识逻辑
P15 --- Working with Multimedia Data
↓
AI 如何处理多媒体数据?
↓
P16 --- Image Understanding
↓
AI 如何理解已有图片?
↓
P17 --- Image Generation
↓
AI 如何生成和编辑图片?
↓
后续课程
如何将多模态能力与实际应用结合?
最终总结:Image Generation 的核心价值,不只是让 AI 快速生成一张图片,而是让用户能够通过自然语言表达创意,并利用多轮反馈控制视觉结果。真正的 AI 高阶用户,会将 AI 图像生成融入设计和创作流程,同时检查输出质量、保持必要的视觉一致性,并了解生成式图像的局限。
参考资源
- 吴恩达《给所有人的人工智能提示词课程|AI Prompting for Everyone》DeepSeek-v4-pro翻译
- DeepLearning.AI --- AI Prompting for Everyone 官方课程
- Full AI Prompting Course with Andrew Ng --- 公开英文转写稿
课程 Slides








