最近、ComfyUIを使い始めまして、悪戦苦闘しているのですが。そこで新しい概念を知って(無理やり勉強させられた感)、いままで理解できていなかったことが腑に落ちることがあったので書いてみたいと思います。(技術的に詳しい人にすれば今更な話ですが。)
潜在空間(latent space)
"AIや機械学習モデルが大量のデータを抽象化し、データの本質的な特徴を圧縮して整理する「意味的な数学空間」"
利用者が普段意識することはないでしょうが、生成AIを使っていれば常にそこにあるものです。技術的にいえば膨大な情報を効率よく処理するためにAI専用に作られた仮想空間でしょうか。(いちいち人間様に"見せる"必要がないので効率的、物事を意味にまで圧縮して扱う)。画像生成においてもコアの処理はここで行われます。いわば超圧縮された情報ノイズの海のようなものですかね。新たな次元、4次元と言ってもいいような気もします。(厨2心をくすぐります。どこでもどあー)
その中で、プロンプト等の指示によりノイズの中から絵を浮き上がらせるわけです。(拡散モデル)
しかし、そこで作られたものは人間には知覚できません。(AI用の次元でAIが作った0と1のデータですから。)
VAE
その橋渡しをするのがVAEと呼ばれるものです。(本来はもっとややこしい概念のようですが)おなじみのピクセルの集合対である画像データに変換して人間にも見れるようにしてくれます。ですので、逆に Image to Image等で画像を入力しなければいけないときはVAEによりエンコードして潜在空間に入力しなければなりません、できた画像はVAEによりデコードして人間に見れるようにするわけです。
VAEという存在は知っていましたが何をしてるのかは全く知らなかったので、それがわかると、なぜ画像がVAEによって少し変化するのかがわかって面白いですね。
(VAEはチェックポイントに組み込み済みのことも多いですが、自分で違うものを選択して画風に影響を与えることもできます。)
(Nvidia PIDというVAEに変わる技術が直近に発表され、これから採用されていくそうです。高性能らしいので楽しみですね。あんまりVRAMくわないといいけどw)
Sampler, Scheduler
潜在空間で情報ノイズから絵を浮き上がらせる手法。ノイズをどのように段階的に取り除いていくかを指定します。結構これにより絵柄の安定度とか画風自体が変化します。(画像の柔らかさと一定の偶然性のあるeuler_aが好みですが、最近は作業ごとに変えるようになりました。ちなみに同じ名前ですがeulerは全く逆の性格です。)
Denoise
潜在空間に画像を入力し処理する際に、どれだけノイズを加えてから再構築するかを指定する値。0だと全く変化せず1だとすべて作り直し。アップスケールやvary的なことをする時の肝になります。
所感
潜在空間(latent space)は、人間の'集合知"やそれによる"夢"(寝てるときにみるやつ)に近いという話も聞きました。とても興味深く、また恐ろしいような気もします。人間の集合知なんてお話にならないような、とんでもない速さで積み上がっていく先鋭化された情報の大塊。そこでAIは一体どんな夢をみるのか。
SF映画なんかでよく自我を持つAIがでてきますが、(大概悪者ですけど)自我を持った瞬間発狂するんじゃなかろうか。w
※グーグルで調べた程度ですので、なにか間違いや手落ちがあればご指摘くだされば幸いです。
I recently started using ComfyUI and have been struggling with it. However, I've learned about new concepts (I was forced to study it, lol), and things I didn't understand before have finally clicked, so I wanted to write about it. (This might be old news to those with technical expertise.)
Latent Space
"AI and machine learning models abstract large amounts of data, compressing and organizing the essential features of that data into a "semantic mathematical space."
While AI users may not usually be aware of it, it's something that's always present when using Generative AI. Technically speaking, it's a virtual space created for AI to efficiently process vast amounts of information. (It's efficient because there's no need to "show" it to humans. Compressing things down to their meaning) In image generation, the core processing takes place here. It's like a super-compressed sea of information noise. You could even call it a new dimension, a fourth dimension.
Within that space, prompts and other instructions make the image emerge from the noise. (Diffusion model)
However, what's created there is imperceptible to humans. (Because it's data of 0s and 1s created by the AI in an AI-specific dimension.)
VAE
The bridge between these two dimention is called a VAE. (It seems to be a much more complicated concept actually, though) It converts the image data into something that humans can see (pixel image data). And Conversely, when you need to input an image using methods like "Image to Image," you must encode a image using a VAE and input it into the latent space. The resulting image is then decoded by the VAE to make it human-readable.
I knew about VAEs, but I had no idea what they did. Understanding that makes it interesting to see why images change slightly after being processed by a VAE.
(VAEs are often built into checkpoints, but you can also select different ones to influence the style.)
(Nvidia recently announced a new technology called PID, which will replace VAE, and it seems it will be adopted from now on. It's supposed to be high-performance, so I'm looking forward to it. I just hope it doesn't consume too much VRAM lol)
Sampler, Scheduler
Names of Techniques for making an image stand out from information noise in latent space. It specifies how the noise is removed step by step. This significantly changes the stability of the image and the style itself. (I prefer euler_a for its soft outputs and a certain degree of randomness, but recently I've started changing it depending on the project. Incidentally, although they have similar names, euler has completely opposite characteristics.)
Denoise
This value specifies how much noise is added before reconstruction when an image is input into the latent space. 0 means no change, while 1 means the entire image is rebuilt. This is crucial when performing upscaling or variation-like operations.
Personal Impression about LATENT SPACE
I've also heard that latent space is similar to human 'collective intelligence' and the resulting 'dreams' (the kind you see while sleeping). It's very interesting and also a little scary. A massive, highly sophisticated mass of information is piling up at an astonishing speed in latent space, far exceeding the collective intelligence of humans. What kind of dreams does AI have in that space? In science fiction, AIs with self-awareness often appear, (and they're usually villains), but wouldn't they go insane the moment they gain self-awareness? haha,
*This article is based on my Google research, so please let me know if there are any mistakes or omissions.

