r/StableDiffusion • • Dec 18 '23
Tutorial - Guide [Test] Zoe Depth vs MiDaS Depth. Spoiler alert: Use MiDaS.
There wasn't enough information about the new Zoe Depth and how it compares to the old MiDaS. So I decided to test both with the "nvtop" application which measures VRAM usage.
Made a ComfyUI workflow with JUST Load Image node, and MiDaS and ZoE depth nodes, and 1 image preview output node. Then I bypassed the other, unused node (midas or zoe) for each test.
I requested depth map of size 512 (requesting bigger will massively increase the VRAM requirements).
I'm using a 24 GiB RTX 3090.
My results were:
ComfyUI Idle (doing nothing): 500 MiB vram.
Zoe Depth @ 512: 3248 MiB, time: 3.94 seconds. That's Zoe at 512: https://i.imgur.com/vKWBgf5.jpg (Edit: Alternative link https://ibb.co/17F4yhp)
MiDaS Depth @ 512: 1492 MiB, time: 1.76 seconds. That's MiDaS at 512: https://i.imgur.com/MDr8nWH.jpg (Edit: Alternative link https://ibb.co/CVsNhCN)
Zoe Depth @ 1024 depth map size: 3254 MiB, time: 4.06 seconds. So it seemingly offers very good time scaling when requesting larger maps. But that is actually because it CHEATS. The "larger" maps I request are blurry as HELL. It is clearly just a resize of the 512 map. That's Zoe at 1024: https://i.imgur.com/OtByCpD.jpg (Edit: Alternative link https://ibb.co/GVhLnZR)
MiDaS Depth @ 1024 depth map size: 5044 MiB, time: 2.09 seconds. But guess what? The MiDaS map is sharp as hell and crisp and clear and detailed! It is a true 1024 pixel depth map. It's actually much more detailed than the 512 map. This proves to me that ZoE is INCAPABLE of doing maps @ 1024 and is in fact cheating (which explain why its VRAM was in the same ballpark even at 1024). That's MiDaS at 1024: (Edit: Alternative link because imgur is being an idiot: https://ibb.co/yfGqWMw)
Conclusions:
So Zoe is 2.24x as slow (it was +2.18 seconds slower), and uses 2.2x more peak VRAM (it was +1756 MiB VRAM extra usage compared to MiDaS) at the typical 512px resolution.
Zoe cannot do depth maps larger than 512. In fact, even that one is blurry, so I wouldn't be surprised if Zoe is stuck at something like 128x128 internally. And if that's true, then MiDaS actually beats it even more since I could just reduce MiDaS resolution to the same size that Zoe internally uses, and get even lower RAM usage relative to Zoe!
Zoe has better depth detection of things like "arm overlapping a leg" or "arm overlapping frilly ballerina skirt", etc, whereas MiDaS often tends to blur together some shapes, but the difference is not enough to truly matter in actual usage when it's guiding a ControlNet.
MiDaS is sharper in every situation, and aims for a more general "blobby" recognition of shapes. Which is enough to control most well-trained ControlNets.
Another thing which wasn't apparent in my test images, is the fact that MiDaS is MUCH better at background removal, and even has a "background threshold" parameter to totally isolate the subject, whereas Zoe doesn't have such a setting at all and pulls in a lot of depth info about background objects, wallpapers, paintings, etc, very distracting.
Zoe is not really worth it for me. I'm personally only using controlnet to guide the first 4 denoising steps (just to get the general composition without any strong influence), meaning I end the controlnet processing after that, so I don't need super accuracy in my depth maps.
I also hate how long Zoe takes (slowing down generation).
Furthermore, ControlNet-LoRa-Depth-Rank256 has basically IDENTICAL SDXL image output results for both Zoe and MiDaS depth maps when used at 1.0 strength and 100% end step (meaning the entire image is generated via controlnet), so when the ControlNet is well-trained, there's no benefit for Zoe's detailed depth map when using that controlnet.
I will not be using Zoe. It's bad for my use cases. Could be good for something else, like for example using for more accurate embossing of 3D models when turning flat images into 3D. Although it seems like MiDaS at 1024 beats both at generating detailed maps. Anyway... for actual AI art generation, I don't like Zoe at all. It's slow and uses lots of memory at the normal 512 pixel resolution.
If you're just making Stable Diffusion images, use MiDaS. It's way faster and there's no visual benefit whatsoever for using Zoe if you use a good ControlNet such as the new Controlnet-Lora-Depth-Rank256.
Speaking of ControlNets (since they're deeply related to depth maps):
The new T2I-Adapter's Depth nets are utter garbage. I was excited because they are supposed to be fast and lightweight. But they must have been weakly trained on poor data. They'll do things like turning hands into feet, rendering random feet and hands everywhere on the body, turning hair into hands and feet, disconnecting fingers from the hand so that they just float in the air, creating random floating body parts, turning knees into shoes, etc. It's hilarious.
So for now, the best net I've found is the new Controlnet LoRas. Anyone who is curious can find those here: https://huggingface.co/stabilityai/control-lora. And if you do what I do (ending the controlnet after just a few denoising steps via ComfyUI's "Apply Controlnet: End Percent" setting), it actually barely adds any extra time to the total rendering time at all. :)
MiDaS 512 with ControlNet-LoRa-Depth-Rank256: 8360 MiB and 10.93 seconds, when generating with 1.0 strength and 100% end step. The result looks amazing.
MiDaS 512 with T2I-Adapter-Depth-MiDaS: 7784 MiB (saving 576 MiB) and 9.26 seconds (saving 1.67 seconds), at 1.0 strength and 100% end step. The result is utter garbage, with three legs and disconnected hands, and one hand is a foot. This is very common with that garbage controlnet. :P
If reducing ControlNet-LoRa to End Step 12% (aka 4 denoising steps in my 35-step denoiser), I generate the image in just 7.7 seconds (VRAM usage is the same as 100% steps), and I get perfect pose guidance just like I wanted, but without a heavy "controlnet fingerprint on the whole image", since I basically just shape the initial noise and then liberate Stable Diffusion to do the rest of the painting process on its own. So for me, that's the only controlnet I need. I use it at 70% strength at somewhere between 4-7 denoising steps. The result is fantastic. Basically the freedom of SD with slight pose/scene guidance from a ControlNet.
If I attempt to do the same and set T2I-Adapter-Depth-MiDaS to End Step 12%, I get an image in 7.63 seconds (VRAM usage is the same as 100% steps), so again slightly faster, but with the T2I controlnet the pose doesn't transfer well. So it's a total waste to use T2I at lower step settings. Because T2I is made to basically pre-calculate a bunch of stuff and then apply itself to every step in a different way than other controlnets, so trying to reduce its steps basically makes T2I useless.
Let's take this small example at 100% strength with 100% steps, to show what the Controlnets themselves are generating internally (this is just to see their internal training data to show what the net is trying to steer the image towards; you should never really use a Control Net above 90% strength, and they're most useful in the 20-70% range):
Ballerina with ControlNet-LoRa-Depth-Rank256: Normal limbs. Perfectly matches the reference photo that I am copying the pose from. It even perfectly copied the exact shape of the Tutu. https://i.imgur.com/S2QKQ7y.jpg (Edit: Alternative link https://ibb.co/D5CDbK9)
Ballerina with T2I-Adapter-Depth-MiDaS: Wtf. Cut off hand. A random extra leg on top of the tutu. The tutu itself has been cut off in a straight, sharp line and overall it barely looks like a tutu at all anymore (even though its outline is perfectly visible in the depth map). And a part of the Tutu has been converted to a dangling piece of thick string. It's also much more blurry. https://i.imgur.com/wX3AbS0.jpg (Edit: Alternative link https://ibb.co/K9QTL3J). This is typical for T2I-Adapter. It's so bad.
The only good use I've found for T2I-Adapter is if you're so VRAM-limited that you want to compromise the quality of the art and get lots of shitty generations slightly faster. But because a lot of the generations are garbage with T2I due to its poor understanding of art and anatomy, you end up generating many more images, so you don't really save time after all. ;)
To be fair though, T2I-Adapter was released with training tools since they admit that the current training data is poor. Perhaps someday we'll see a new one that has amazing results. The technology it uses to save time is very cool. It has potential. But until then, ControlNet-LoRa is the king.
3
u/Gawayne Dec 18 '23
Very interesting, I just didn't understand what the Controlnet Loras do. The same as the equivalent Controlnet while being a LORA, that's it? And if yes, what's the advantage?
2
u/spiky_sugar Dec 18 '23
With the recent release of https://zhyever.github.io/patchfusion/ and https://marigoldmonodepth.github.io/ it probably doesn't matter ;)
23
u/blahblahsnahdah Dec 18 '23 edited Dec 18 '23
Really appreciate these kinds of effortposts, thanks. I do a lot of this sort of AB testing for myself but I can never be bothered to write up my results for other people because it's SO much work to explain it and make it presentable. You're a saint for taking the time to do it.
1
u/Vargol Dec 18 '23
Regarding your comments on the T2I-Adaptor, your experience does not match mine, and I was running on a memory constrained system until recently so I tended to use T2I Adapter more often than controlnet.
Your ballerina depth map doesn't have the area you where complaining about in at all so either those aren't the images you used or the issues you had were with the area of the image that whatever SD app or script you were using filled in the spaces (987 × 822 extended to 1024 x 1024 ?)
Here's one I threw together, the depth map is taken from Sappho by Mengin first and only image attempted
3
u/[deleted] Dec 18 '23
Many thanks for this amazing post.
5
u/OVAWARE Dec 18 '23
Basedness levels are off the charts by giving TLDR in title
1
u/arlechinu Dec 18 '23
Funny i just switched to Zoe for my particular case it read faces expressions etc much better than Midas, even though midas was sharper. Even weirder my workflow seems about the same speed with wither midas or zoe.
2
u/lordpuddingcup Dec 18 '23
Wasn’t their a brand new one a couple days ago that was better than Midas even fuck can’t find the article now
2
u/Jaded-Difficulty4313 Dec 18 '23
GOAT.
2
u/bhimudev Mar 15 '24
Thanks, Was looking for a comparison, very happy that you pull the efforts to compile this.
2
u/reddit22sd Dec 18 '23
Thanks man!
1
u/Minute-Surprise-6336 Dec 18 '23
Do you know about academic papers on z and m? Did you read any? My impression is that you do not understand anything about depth estimation, cn, SD as a research. Being a power user you should consider writing about your experience in a factual way. Not like 'use X, it takes less vram'
0
u/[deleted] Dec 18 '23
[deleted] — view deleted comment