thygate / stable-diffusion-webui-depthmap-script

High Resolution Depth Maps for Stable Diffusion WebUI
MIT License
1.66k stars 153 forks source link

Top/Bottom instead of left/right? #131

Open scruffynerf opened 1 year ago

scruffynerf commented 1 year ago

While SBS is the more common approach, the alternative is Top/Bottom, and it's relatively easy to do: instead of two images side by side, you stack them.

In video, this often results in higher resolution (the longer resolution is preserved fully and the smaller is cut in half (instead of the reverse), leading to greater overall resolution in pixels).

But on a more practical front: if you are doing the usual '180' or 360 panorama', the ratio is 2:1 (twice as wide as tall), but if you stack 2 of them using T/B, then your final image (which is now 180 or 360 stereo panorama) is [magically] a perfectly square image with a ratio of 2:1 and then stacking is 1:2, leading to a 1:1 finally... Which if you think about, is ideal for generating and upscaling in SD.

Example usage: https://renderstuff.com/tools/360-panorama-web-viewer/#panoramic-image-format Free webbased viewer, just make sure your image host is supported.

Havent' yet looked at code, but hopefully the change from SBS to TB code would be pretty easy, and offer a new choice in the UI.

updated: So yes, looking at code , adding this feature should be pretty easy. Will you take a PR for it?

scruffynerf commented 1 year ago

Example of this in action:

00051-4044717039-(360 degree equirectangular panorama_1 2), fantasy forest with floral paths, style-rustmagic-before-highres-fix 00053-4044717039-(360 degree equirectangular panorama_1 2), fantasy forest with floral paths, style-rustmagic_depth 00054-4044717039-(360 degree equirectangular panorama_1 2), fantasy forest with floral paths, style-rustmagic_stereotb

With viewer, click on Stereo, and you can spin around. If you have VR capable gear, you do immersive, and it's in 3d. First attempt, very minor seam where it connects, and the left right separation might need some tweaks in the settings. But totally working proof of concept.

This is entirely done inside A1111 with SD (and depth model, etc), full 360 rendered environment.

GeorgLegato commented 1 year ago

HI guys, very interesting stuff ongoing here. let us collaborate a bit with my PanoramaViewer Extension. https://github.com/GeorgLegato/sd-webui-panorama-viewer I have added method to convert Equirect. => Cubemap (polyhedron net) so inpainting could be easiyl processed on nearly planar tiles. and of course, the panorama viewer is attached into the Graiod Gallery viewer, so user can dream dpeth+prompt+x => 360 panorma and view it immediately "here".

Then, my extension add an dedicated Tab, which content pane is able to show 3d-panorama-Movies. So, if we can get animated depth => equi-movies, you can simply "send to Panorama Viewer"-Tab.

thygate commented 1 year ago

Also check Mickmumpitz's results of using a equirectangular maps in his new video : https://www.youtube.com/watch?v=t-8I7EkIL8c

He's using controlnet to generate equirectangular maps.

drewbaumann commented 1 year ago

@scruffynerf that is really cool! What sort of prompt do you need to create 360 images?

GeorgLegato commented 1 year ago

there are some myths about howto generate 360panoramas using SD. let me bust them: 1.) every model has been trained on equirectangular images. SO every model I tested gives you "bend" images using the prompt "360 full panoraama view" . evidence here: image https://laion-aesthetic.datasette.io/laion-aesthetic-6pls/images?_search=360&_sort=rowid

2.) if you wanna have a bit more control over your "bended image" usa the 360 Lora from civitai. You dont need then the prompt "360 full panorama"; instead you can get as many "curvey corners" as strong you prompt the <Lora:360...: 0:5>

3.) to use a Depth map does not "generate" a 360 equirectangular image; it is a depth map from an already existing (real) 360 image. Since the disturbance is given by the map, yes, it results in something.

4.) equirectangular has better resolution as cubemaps; but the suffer on their poles being warped into a single point often; this happen when the Lora or "360 prompt" is too weak. You can use my Panoramaviewer extension to convert equi to cubemap, fix the poles by inpainting. You lose a bit resolution, actually need to upscale cubemap and then convert back to equi.

check my reddit profile for some tutorials about that.