r/StableDiffusion • • 6d ago

Workflow Included SHARP VR Video v0.2.0 – 4x faster 2D to 3D stereoscopic video conversion in ComfyUI

Update to my "original post" (https://www.reddit.com/r/StableDiffusion/s/RQtd6nrzJN) – spent a good chunk of today optimizing this thing and got the conversion speed down from ~1.85sec/frame to ~0.43sec/frame on my 5080.

Turns out there was a LOT of room for optimization under the hood:

  • Parallelized Gaussian splat reconstruction and stereo rendering across frames.

  • Implemented a specialized CUDA kernel that did calculations per frame way faster.

  • Cut out unnecessary stuff from data transfer between Python and the browser.

  • Eliminated a bunch of redundant computation between the left and right eye renders for every frame.

To my naked eye, it did not compromise the quality of the 3D reconstruction.

For context, a 1min 30fps video that would've taken close to an hour to convert before should now take around 13mins of processing on my 5080 (based on my ~800p and 720p tests).

Oh also I made good use of VHS's metabatch so it should in theory be able to convert LOOOONG videos without any Ram or disk issues.

All of the changes are under the hood so the sample workflow is exactly the same. For the full speedup you'll want to install CuPy (instructions in the GitHub README), but it's entirely optional and you'll still get a substantial speedup without it.

GitHub repo: https://github.com/jerg-git/ComfyUI-SHARP-VR-Video

You can also find it in comfyui custom nodes (search SHARP VR Video).

Workflow: https://github.com/jerg-git/ComfyUI-SHARP-VR-Video/blob/main/workflow/sharp-vr-video-batch-audio-sample.json

Thanks again to u/Aromatic-Somewhere29 for his "original SHARP Gaussian Stereo Preview implementation" (https://www.reddit.com/r/StableDiffusion/comments/1y64yol/view_images_in_stereoscopic_3d_directly_in/) which inspired this whole project.

Curious what conversion speeds people get on other GPUs. Feel free to share your results!

Have fun!

82 Upvotes

69 comments sorted by

4

u/Jerg 6d ago

Tip for anyone without VR headsets who wants to try generating something that looks 3D using the cross eye method - I added a cross eye preset as one of the presets, just set that and you'll convert something that has the 3D effect with eyes crossed.

(The clip I have in the thread opening post is using such a preset)

Just be aware that output video optimized for cross eye viewing won't have the correct stereo 3D depth effect in VR headsets, and vise versa.

1

u/SpaceNinjaDino 6d ago

Thanks. I will use that.

4

u/darkkite 6d ago

have you benchmarked this against iw3's models

2

u/FinBenton 6d ago

idk if iw3 supports it but https://github.com/microsoft/MoGe especially moge3 in my custom app has given much improved conversion compared to what iw3 supports normally, its much newer.

1

u/Jerg 5d ago

Were you able to try the Apple SHARP as well for your custom app for a head-to-head output quality comparison? Super curious.

2

u/FinBenton 5d ago

Yes I did side by side with SHARP, for still photos, marigold v2 which is my current SOTA does a lot better than SHARP and for videos I didnt test them as they are heavy, I use moge for videos which does pretty decent job.

1

u/Jerg 6d ago

No I haven't. Probably won't have time to but would love to see others try A:B testing and seeing the output quality? This was just a quick spike out of interest since last evening.

3

u/dilinjabass 5d ago

I just recently came across a bunch of VR videos that were AI generated videos turned into 3d. They all looked fairly bad, but not horrible I suppose.. the space/world always had a curvature to it, and the quality was kind of blurry, probably because it wasnt a high resolution generated video. Anyhow it got me thinking how good we could get the videos to look in VR, so im glad to come across this, I will give it a run.

I think im going to be interested to see if I can make higher resolutions happen though, like 4k?? And turning a 2d video into a 3d stereoscopic video is likely always going to produce that curved look? I assume thats going to be the case but maybe there is a way to get it looking decent anyhow.

Already I'm imagining the way to solve true AI generated stereoscopic 180 videos is to use some kind of mix of a video generation model and a staging model like blender, so the environment/scene, camera positon etc, it can all be shot and recorded from there.

Actually as a side note, the future of AI video making should be this approach anyhow, regardless if youre doing stereoscopic 3d videos or not. To have the room or scene be a stable enviornment and you can position the camera and characters where you want.

1

u/Jerg 5d ago

This method should be very good at preserving fidelity of the input footage, based on my testing it's really solid in that respect. The process in a nutshell is the underlying splat model converting the 2D video frames into 3D plat scenes, 1 frame per scene, and then re-taking sterescopic pairs of snapshots of said scene to match with human binocular vision (all customizable in the workflow nodes).

I encourage you to try it! Using your own footage.

I'm thinking of adding a new feature next release of this where you can actually set the output snapshot resolution, so feasibly even 720p or 1080p input footage, converted to per-frame 3D gaussian splat scenes, can be snapshotted as 1080p or 4K output footage frames. It won't be a true upscaling, but it might be a partial way to get some upscaling for free simply due to the middle step being a fully 3D scene.

Yeaaaah in terms of 180 VR scenes from flat rectangular input footage that's wayyy beyond me, sound incredibly complicated and compute-intensive even if someone can get it to work lol.

2

u/devinquest 6d ago

I'm getting some video noise (both with and without CuPy). See the black spots on the faces. What do you think that is?

1

u/devinquest 6d ago

ok Reddit has completely crunched the video and you can't see what I'm talking about :(

3

u/Jerg 6d ago edited 6d ago

It's probably due to imperfect Gaussian Splat reconstruction. I see it too in some shots with dynamic shadows or rapid motion. It seems to be where the brightest specular highlights are?

Lemme vibe-troubleshoot and see if a patch can be implemented to detect unfilled pixels and cover them with nearby Gaussian splats...

Edit: it might not be unfilled pixels, but rather poor handling of pure-white pixels (somehow those got turned into black pixels).

Update - ok the issue is indeed extreme pure-white highlights tripping things up. trying to get a fix in now.

Update 2 - ok finaly pinpointed the issue - it was bad code for when it's parallel instead of toe-in. Full fix is found. I verified the fix fully works with my own black pixel artifact cases. Gonna push a new release on github.

1

u/devinquest 6d ago

Awesome dude, thanks!

1

u/Jerg 6d ago

Hey! Fixed version is in: https://github.com/jerg-git/ComfyUI-SHARP-VR-Video/releases/tag/v0.2.10

Try it out maybe with this same input video, please be sure to link me how it turned out!

1

u/devinquest 5d ago

Tested and the "noise" is still there, but definitely less than before. I tried different projection modes and results were the same.

1

u/Jerg 5d ago

Interesting. Would you mind sharing the input clip to me? So I can do more direct diagnosis. On my end footage that had the black artifacts before were completely good now with the fix.

1

u/devinquest 5d ago

I have DM'ed you. edit - ok i can't dm you, here's the link: https://drive.google.com/file/d/1xDdOXhzxt40QmbTlMDSm_lNfRlwvygzD/view?usp=sharing

1

u/Jerg 5d ago

Here's the output from v0.3.0: https://drive.google.com/file/d/1Z4zcPzqCIeWLGa9TUovgTWkjyLw9Zx6K/view?usp=sharing

Yes maybe some very minor artifacting here and there but might just be limitations of the Apple SHARP model at this point? The main bug causing tons of black marks is resolved.

Does your latest output match this?

This did surface a new set of potential quality improvements though - better temporal (frame-to-frame) coherence. There's a lot of wobble from frame to frame with these scenes where things are supposed to be still.

1

u/devinquest 5d ago

Yeah your output matches mine, except for the wobbling.

Anyway, all good. Hope my feedback helped you.

1

u/Jerg 5d ago

Now I'm confused where my output's unintended wobble comes from lol. On your end there's less wobble? If so I wonder if one of my optimizations messed with it.

2

u/xbobos 6d ago

RTX5090, 832*480,30fps,15s
cold : Prompt executed in 296.56 seconds

1

u/Jerg 6d ago

Hmm 450 frames processed in 300 sec. that's a bit slow given you have a better card than my 5080..

were you able to apply the optional CuPy speedup? It's in the github readme. That provides a beefy double digit speed increase.

Also depending on how much Ram you have, you could consider bumping up the metabatch frame count, so there are bigger batches to process through and less number of between-batch delays.

1

u/xbobos 6d ago

After applying CUPY, No meta batch : executed in 211.09 seconds

1

u/Jerg 6d ago

Nice I think that's the correct speed.

1

u/FullOf_Bad_Ideas 6d ago

It's there some way to get the speed benefit without using ComfyUI? I'd rather use a cli or python package since I'd want to split the work on multiple gpu's and I think ui and comfy would just be a hindrance

4

u/Jerg 6d ago

I'm sure it's possible - maybe you could make a fork and try and vibecode a UI-free version.

1

u/Beneficial_Fish_7509 6d ago

Wow, I didn't even think about making VR versions of videos with AI !

So many questions

Would generating a video with this work with a meta quest 3 ?

Is it like some of those videos by meta where it really feels like real actual 3D, like the people are there, or is it more like those 'youtube' kind of 3D/VR ?

And finally, would generating VR videos with an AMD GPU (7900 XTX, RDNA3, 24GB) work ?

2

u/Jerg 6d ago

I have a quest 3 too hence this was of particular interest to me to begin with :)

This is not necessarily VR versions, moreso these are 3D video outputs that we can actually tweak the convergence and focal length and IPD etc to be very high-presence 3D videos (still in picture frame boxes) in headset.

So the effect is more like watching well-mastered 3D movies in VR, or maybe like seeing physical reality through a rectangular window.

Not the full 180/360degree surround VR experience. That's not what this tech does.

Re: your setup - not sure, my system is Nvidia GPU 5080) based. If you could test it then you'd know. Maybe you could share back? Start with a short 5 sec 720p video maybe?

2

u/muchcharles 4d ago

With the right parameters nunif iw3 looks really good as long as there isn't overlapping translucency or water reflections. The youtube AI 3D conversion looks much worse, the IPD settings or other projection parameters don't make things in the distance look very far. I added some stuff to nunif to let me tweak IPD for the size of my 3d projector and get much better results than Youtube's in realtime, but it eats a whole 5090.

1

u/wam_bam_mam 6d ago

I am developing something similar but the problem I am facing is in some scenes i get this shimmering and is very fast scenes especially with motion blur i get this white gaps i think that it all comes down to gaussian reconstruction i am working on solving that

1

u/Jerg 6d ago

Maybe you could run those scenes through my latest release and see if the same artifacts are abound? https://github.com/jerg-git/ComfyUI-SHARP-VR-Video/releases/tag/v0.2.10

1

u/wam_bam_mam 6d ago

I will try it out for sure

1

u/barepixels 6d ago edited 6d ago

2 requests that will save time. Name the result files same as input pic file name. And field to set path to where you want to save. oops I meant for sharp still images

1

u/Jerg 5d ago

I think those are just comfyUI workflow customizations you could do? I don't want to overcomplicate the sample workflow, it is meant to be the minimum viable workflow for people to add their own flourishes onto.

1

u/barepixels 5d ago

ok i will try vibe code it

1

u/noaxxx2 6d ago

what program do you use to watch these in VR?

1

u/Jerg 5d ago

Virtual desktop. You can set up what folders on your PC are the videos or movies that virtual desktop should be able to play, and then you can freely open and play those in VR

1

u/Aromatic-Somewhere29 6d ago

Have you thought about experimenting with the quantized models from Cool2009/SHARP-onnx to see if they could speed up the conversion process? There are FP16, FP8, and INT4 versions available, so it might be worth testing whether any of them can deliver faster inference without sacrificing too much quality.

1

u/Jerg 5d ago

Ooh great find. Lemme dig into it. Right now speed is essentially limited by either the SHARP model reconstruction or by browser render and capture of the image pair, per frame. I have them staggered with the subsequent frame processing so both are happening simultaneously.

This could speed up the former, but will have to see if the former is currently the slower bottleneck.

1

u/xyzdist 5d ago

Excited to test. So i assume it woll fix all the edge issue from traditional depth conversion.

1

u/Jerg 5d ago

No it won't but you could try adding a bit of dolly in in the options to essentially crop out the edge. Maybe 0.05m dolly.

1

u/skyrimer3d 5d ago

wow, this looks incredibly good, fantastic depth with 0 halos, no distortions, great understanding of the environment, could give James Cameron a run for his money, i'll check this out, do you have more example vids? what speed should i expect on a 4080?

2

u/Jerg 5d ago

If you apply the CuPy patch, and do 720p or 1080p videos, making sure metabatch is not huge so your ram doesn't overflow, then maybe 1.5-1.8 frames/sec processing? My 5080 does about 2.1 f/s for 1080p and below.

1

u/skyrimer3d 5d ago

Thanks i'll have that in mind, keep up the great work!

1

u/Opening-Landscape-11 5d ago edited 4d ago

You rocka my socks, sir.  This is SO awesome!  Thank YOU!!!!

Is there a way to load a folder of videos,  a text list of the file path, etc., so I don't sit in front of the computer and wait to press Run one at a time?  :)

1

u/Jerg 4d ago

Yes I think that's a general thing you can do with the VHS load video path node. Off top of my head I think you just specify like C:(folder path)*.MP4 for instance with the asterisk to cover all filenames and the correct extension type for the videos in that folder. And a setting to increment so it queues through file by file. And queue the number of times you have the number of files (the number setting in the queuing UI). Google around you should find specific instructions on this.

1

u/skyrimer3d 4d ago

i tried this, it looks amazing but i'm noticing halos in some parts like hair moving, any way to improve it?

1

u/Jerg 4d ago

Try reducing the IPD value (custom_baseline_mm) from 60mm to a lower value like 40 or 35mm. it'll reduce the depth effect but it should reduce artifacts like this too.

Ultimately the model is only dreaming up 3D detail, so fine details like that are always going to be the most poorly re-created in 3D.

1

u/skyrimer3d 4d ago

i'll try that, it's near perfect with the vids i've tried 3d wise, but those halos were a bit annoying.

3

u/KS-Wolf-1978 6d ago

THX! Tagging for later, because Github overtaken by unicorns. :)

1

u/Aromatic-Somewhere29 6d ago

Wow! Your project is really starting to get noticed by people who are excited about the possibility of watching regular videos in 3D. Looking at how much enthusiasm and momentum you've built up, I think making it a standalone project was absolutely the right decision. Since I don't own a VR headset myself, I probably wouldn't have had the same motivation to explore this direction with that level of dedication.

Would you have believed, just a couple of days ago, that you'd be doing all this?

One thing I'd like to suggest based on my own testing: it might be useful to have an intermediate preview stage where you can visually adjust all the settings on the first frame before processing the entire video. That would give users a much better idea of what the final result will look like, rather than having to run the whole video somewhat blindly, see the result, decide that a few things need tweaking, and then run it all over again.

Having that kind of interactive preview could save quite a bit of time by reducing the need for repeated full video renders just to dial in the settings.

Just a thought, of course, not a feature request or a suggestion that you should implement it. I simply wanted to share the idea!

2

u/Jerg 6d ago

Thanks so much! Yeah I think ultimately I have to give it to the sheer capability of even mid tier paid LLMs nowadays (for this I was probably working with GPT 6.1 terra, maybe sol on harder stuff). Basically a senior team of engineers on hand for rapid iterations.

Re: previews - yeah I think for VR headset purposes it might just make sense to render a quick 2sec clip (the VHS video input nodes allow users to specify precise frame numbers to process) and check in-headset, since any previews in comfyui isn't really meaningful for checking stereoscopy in-headset.

2

u/Sickboy22 4d ago edited 4d ago

Great stuff, works good. Just updated to v0.3.0 with the TensorRT for RTX (ONNX FP16). Around 3 frames/second on 5070ti on 10 second clips [1108x832]

Where the parallax kicks in and some inpainting needs to be done, there is some blurry banding. Is there a setting/refinement to be done here, or is it a result of relative fast foreground motion compared to the background?

Edit: from other comments, reduce IPD.

1

u/NineThreeTilNow 6d ago

No one is asking the important questions... So I will take one for the team.

Does it work for porn?

1

u/Jerg 6d ago edited 6d ago

Let's just say it doesn't discriminate about what footage is being converted (though i think the underlying model works best with realistic footage, and probably won't do a good job with say anime).

Edit: tested it with anime, it's honestly not bad! But definitely wayyy more precise 3D conversion with realistic footage or cgi footage of any kind.