視覺人工智慧指南

圖像生成中的負面提示

負面提示是描述您不希望在人工智慧生成的圖像中出現什麼的文字。

聆聽此指南AI 語音敘述 · ~3 min

本頁4 分鐘閱讀
  1. 概述
  2. 深入探討
  3. 現實世界的實施
  4. 影像生成中負提示的未來
  5. 付諸實踐
  6. 不斷探索
  7. 常見問題

概述

在 Stable Diffusion 等擴散模型中,它取代了無分類器指導中使用的空提示,因此每個去噪步驟都被推離了該描述。負面提示讓使用者可以直接控制不需要的元素,但它們只適用於運行真正的無分類器指導的模型,並且在過度使用時可能會適得其反。

深入探討

Diffusion models create an image by starting from random noise and removing it over many steps. At each step, the model predicts the noise twice: once conditioned on your prompt and once on an 'unconditional' input, normally an empty prompt. Classifier-free guidance, introduced by Jonathan Ho and Tim Salimans, combines the two. It starts from the unconditional prediction and moves further toward the conditional one, scaled by the guidance scale (often labeled CFG). The result follows the prompt more closely than the raw model would. A negative prompt simply replaces the empty prompt with your negative text. The formula now pushes away from the negative description as it moves toward the positive one. That is why a negative prompt is not a filter or a post-processing step: it shapes every denoising step. The technique spread through community tools such as the AUTOMATIC1111 web interface in 2022. It became especially popular with Stable Diffusion 2.x, whose results many users found improved noticeably with negatives. Negative prompts work best on concrete visual concepts the model knows well: 'blurry', 'text', 'watermark', 'monochrome', or a specific color or object. They work less well as abstract fixes. On many general-purpose models, terms like 'bad anatomy' or 'extra fingers' often do little, because those models rarely saw captions describing such failures. They can also make results worse. A long list pushes the image away from many directions at once. That can reduce variety, wash out or oversaturate colors, and produce stiff compositions, and high guidance scales amplify the effect. Some models, including guidance-distilled and few-step models, skip the unconditional pass entirely. On those, negative prompts are ignored unless the tool turns true CFG back on, which slows generation. A common misconception is that writing 'no cats' in the main prompt excludes cats. Text encoders handle negation poorly, so the phrase can add cats instead.

現實世界的實施

一位產品攝影師生成了手錶的工作室照片,並添加了「文字、浮水印、標誌」作為負面提示,以阻止背景中的假冒品牌。

想要畫出乾淨線條的插畫家會在否定提示中加上「陰影、顏色、真實感」。相反,在主提示中寫入“無陰影”可能會意外添加陰影。

用戶貼上 60 個從論壇複製的術語的負面提示,發現圖像變得平淡且重複。將其修剪為一些有針對性的術語可以恢復多樣性。

有人切換到引導蒸餾模型,並注意到否定提示欄位沒有任何作用,因為預設情況下,模型從不計算否定提示將提供的第二個預測。

影像生成中負提示的未來

隨著模型的改進,負面提示變得不再那麼重要。具有更強大文本編碼器的新系統更忠實地遵循詳細的積極提示,而指導蒸餾模型放棄消極提示支持以換取速度。同時,對引導方法的研究仍在繼續,這些方法可以提供更精細的控制,而不會產生普通 CFG 的副作用,並且一些介面提供單獨的控制來抑製文字或樣式等內容。對於從業者來說,持久的教訓是機械性的:檢查你的模型是否實際上運行了負分支,保持負分支簡短而具體,並針對固定種子測試每個術語,以便您可以看到它真正發生的變化。

付諸實踐

為什麼這很重要

  • 速度與規模. 視覺人工智慧可以大規模自動化檢查、檢測和標記任務。
  • 配裝選擇. 創意團隊可以透過更少的手動修改來更快地建立概念原型。
  • 團隊與工作流程. 操作可以使用以前難以處理的影像和視訊訊號。

留意

  • 如果出處不明,肖像權和同意可能會成為法律風險。
  • 模型表現可能因光照、人口統計和環境的不同而有所不同。
  • 除非監控置信閾值,否則誤報可能會被忽略。

後續步驟

  1. 定義精確度、召回率和錯誤成本的接受標準。
  2. 使用符合實際生產條件的數據進行測試。
  3. 為低置信度或高影響力的預測添加人工審核。
  4. 追蹤模型漂移並在相機或資料集變更後重新驗證。

不斷探索

免費電子報

獲取每日 AI 簡報

每個工作日上午提供三則經過驗證的 AI 新聞,以淺顯易懂的英文撰寫。永久免費,無廣告。

每個工作日一封電子郵件。一鍵取消訂閱。我們絕不出售或分享您的地址。

測試一下自己

接受影像生成測驗中的負面提示

每個答案皆有即時回饋,通過課程後可獲得具備可驗證 ID 的可分享證書。

開始測驗

支持免費的 AI 教育。AI Understanding 是一個 501(c)(3) 非營利組織——絕無廣告,絕無付費牆。 捐款

常見問題

影像生成中的負提示是什麼?

負面提示是描述您不希望在人工智慧生成的圖像中出現什麼的文字。在 Stable Diffusion 等擴散模型中,它取代了無分類器指導中使用的空提示,因此每個去噪步驟都被推離了該描述。負面提示讓使用者可以直接控制不需要的元素,但它們只適用於運行真正的無分類器指導的模型,並且在過度使用時可能會適得其反。

在無分類器指導中,否定提示取代了什麼?

CFG 通常會將提示預測與空提示中的預測進行比較。否定提示取代了空提示的位置,因此指導會遠離該文字。

為什麼在主提示中寫“沒有貓”實際上會產生貓?

編碼器將“貓”視為一個強有力的概念,而很大程度上忽略了“不”。將單字移至否定提示會反轉引導方向。

為什麼無分類器指導會使每步的計算量增加一倍?

每一步都需要兩個噪音預測,每個提示一個,並且使用指導量表將它們組合起來。

根據指南,哪個負面術語最有可能產生強烈、可靠的效果?

負片最適合模型熟悉的具體視覺概念。水印出現在許多訓練圖像中,而諸如“不良解剖結構”之類的失敗描述很少出現在一般標題中。

當您使用否定提示和跳過無條件傳遞的指導蒸餾模型時會發生什麼?

由於沒有無條件或負分支可供計算,負文本無處可去。重新打開真正的 CFG 會以速度為代價來恢復它。