import{s as _t,n as Tt,o as Mt}from"../chunks/scheduler.35aab934.js";import{S as Lt,i as kt,e as l,s,c as v,q as x,H as Q,h as Rt,a as r,d as a,b as i,f as Oe,g as b,j as m,r as y,u as J,k as gt,v as p,l as g,m as n,n as $,t as _,o as T,p as M}from"../chunks/index.de17b971.js";import{C as Nt}from"../chunks/CopyLLMTxtMenu.48bc5cc2.js";import{H as K,E as Ht}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.8fdece89.js";function Pt(Xe){let w,te,Y,ae,L,ne,k,se,R,Qe=`We’ve seen in the NeRF chapter how, given a large set of images, we can generate a three-dimensional representation of an object.
But sometimes we have only a handful of images or even just one.
Novel View Synthesis (NVS) is a collection of methods to generate views from new camera angles that are plausibly consistent with a set of images.
Once we have a large, consistent set of images we can use NeRF or a similar algorithm to construct a 3D representation.`,ie,N,Je=`Many methods have recently been developed for this task.
However, they can be divided into two general classes - those that generate an intermediate three-dimensional representation, which is rendered from a new viewing direction, and those that directly produce a new image.`,le,H,Ke=`One key difficulty is that this task is almost always underdetermined.
For example, for an image of the back of a sign, there are many possible different things that could be on the front.
Similarly, there could be parts of the object that are occluded, with one part of an object in front of another.
If a model is trained to directly predict (regress) the unseen parts, with a loss penalizing errors in reconstructing held-out views, then by necessity the model will, when it is not clear what should be there, predict a blurry, grey colored region, as noted in <a href="https://jiataogu.me/nerfdiff/" rel="nofollow">NerfDiff</a>.
This has spurred interest in the use of generative, diffusion-based models, which are able to sample from multiple plausible possibilities for the unseen regions.`,re,P,Ye=`Here we will briefly discuss two approaches, which are representative of the two classes.
<a href="https://alexyu.net/pixelnerf" rel="nofollow">PixelNeRF</a> directly predicts a NeRF for the scene from an input image.
<a href="https://zero123.cs.columbia.edu/" rel="nofollow">Zero123</a> adapts the Stable Diffusion latent diffusion model to directly generate new views without an intermediate 3D representation.`,oe,C,me,F,et=`PixelNeRF is a method that directly generates the parameters of a NeRF from one or more images.
In other words, it conditions the NeRF on the input images.
Unlike the original NeRF, which trains a MLP which takes spatial points to a density and color, PixelNeRF uses spatial features generated from the input images.`,he,f,tt='<img src="https://huggingface.co/datasets/hf-vision/course-assets/resolve/main/PixelNeRF_pipeline.png" alt="PixelNeRF diagram"/> <p>Image from: <a href="https://alexyu.net/pixelnerf">PixelNeRF</a></p>',pe,o,Ge,Ue,Be,fe,wt='<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi></mrow><annotation encoding="application/x-tex"> x </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span></span></span></span>',de,ue,vt='<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>π</mi></mrow><annotation encoding="application/x-tex"> \\pi </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span></span></span></span>',ce,ge,xt='<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>W</mi><mo stretchy="false">(</mo><mi>π</mi><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex"> W(\\pi x) </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">W</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span>',we,ve,bt='<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi></mrow><annotation encoding="application/x-tex"> x </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span></span></span></span>',xe,be,yt='<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi></mrow><annotation encoding="application/x-tex"> d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">d</span></span></span></span>',ye,$e,$t='<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>W</mi><mo stretchy="false">(</mo><mi>π</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex"> W(\\pi(x)) </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">W</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">))</span></span></span></span>',_e,Te,S,at=`The original PixelNeRF model was trained on a relatively small set of renderings from the <a href="https://huggingface.co/datasets/ShapeNet/ShapeNetCore" rel="nofollow">ShapeNet</a> dataset.
The model is trained with either one or two input images, and attempts to predict a single novel view from a new camera angle.
The loss is the mean-squared error between the rendered and expected novel views.
A model was trained separately on each class of object (e.g. planes, benches, cars).`,Me,j,Le,d,nt='<img src="https://huggingface.co/datasets/hf-vision/course-assets/resolve/main/PixelNeRF_input.png" alt="Input image of a chair"/>',ke,u,st='<img src="https://huggingface.co/datasets/hf-vision/course-assets/resolve/main/PixelNeRF_output.gif" alt="Rotating gif animation of rendered novel views"/> <p>Image from: <a href="https://alexyu.net/pixelnerf">PixelNeRF</a></p>',Re,z,it='The PixelNeRF code can be found on <a href="https://github.com/sxyu/pixel-nerf" rel="nofollow">GitHub</a>.',Ne,I,He,D,lt='In the <a href="https://arxiv.org/pdf/2307.05663.pdf" rel="nofollow">ObjaverseXL</a> paper, PixelNeRF was trained on a <em>much</em> larger dataset <a href="https://huggingface.co/datasets/allenai/objaverse-xl" rel="nofollow">allenai/objaverse-xl</a>.',Pe,q,rt=`See also - <a href="https://deepmind.google/discover/blog/neural-scene-representation-and-rendering/" rel="nofollow">Generative Query Networks</a>,
<a href="https://www.vincentsitzmann.com/srns/" rel="nofollow">Scene Representation Networks</a>,
<a href="https://arxiv.org/pdf/2311.04400.pdf" rel="nofollow">LRM</a>.`,Ce,Z,Fe,V,ot=`Zero123 takes a different approach, being a diffusion model.
Rather than trying to generate a three-dimensional representation, it instead directly predicts the image from the new views.
The model takes a single input image, and the relative viewpoint transformation between the input and novel view direction.
It attempts to generate a plausible, 3D-consistent image from the novel view direction.`,Se,W,mt=`Zero123 is built upon the <a href="https://arxiv.org/abs/2112.10752" rel="nofollow">Stable Diffusion</a> architecture, and it was trained by fine-tuning existing weights.<br/>
However, it adds a few new twists.
The model actually starts with the weights from <a href="https://huggingface.co/spaces/lambdalabs/stable-diffusion-image-variations" rel="nofollow">Stable Diffusion Image Variations</a>, which uses the CLIP image embeddings (the final hidden state) of the input image to condition the diffusion U-Net, instead of a text prompt.
However, here these CLIP image embeddings are concatenated with the relative viewpoint transformation between the input and novel views.
(This viewpoint change is represented in terms of spherical polar coordinates).`,je,c,ht='<img src="https://huggingface.co/datasets/hf-vision/course-assets/resolve/main/Zero123.png" alt="Zero123"/> <p>Image from: <a href="https://zero123.cs.columbia.edu">https://zero123.cs.columbia.edu</a></p>',ze,E,pt=`The rest of the architecture is the same as Stable Diffusion.
However, the latent representation of the input image is concatenated channel-wise with the noisy latents before being input into the denoising U-Net.`,Ie,A,ft='To explore this model further, see the <a href="https://huggingface.co/spaces/cvlab/zero123-live" rel="nofollow">Live Demo</a>.',De,G,qe,U,dt='<a href="https://3d-diffusion.github.io/" rel="nofollow">3DiM</a> - X-UNet architecture, with cross-attention between input and noisy frames.',Ze,B,ut='<a href="https://arxiv.org/pdf/2311.13617.pdf" rel="nofollow">Zero123-XL</a> - Trained on the larger objaverseXL dataset. See also <a href="https://huggingface.co/stabilityai/stable-zero123" rel="nofollow">Stable Zero 123</a>.',Ve,O,ct='<a href="https://arxiv.org/abs/2310.15110" rel="nofollow">Zero123++</a> - Generates 6 new fixed views, at fixed relative positions to the input view, with reference attention between input and generated images.',We,X,Ee,ee,Ae;return L=new Nt({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),k=new K({props:{title:"Novel View Synthesis",local:"novel-view-synthesis",headingTag:"h1"}}),C=new K({props:{title:"PixelNeRF",local:"pixelnerf",headingTag:"h2"}}),j=new K({props:{title:"Results (from the PixelNeRF website)",local:"results-from-the-pixelnerf-website",headingTag:"h3"}}),I=new K({props:{title:"Related methods",local:"related-methods",headingTag:"h3"}}),Z=new K({props:{title:"Zero123 (or Zero-1-to-3)",local:"zero123-or-zero-1-to-3",headingTag:"h2"}}),G=new K({props:{title:"Related methods",local:"related-methods",headingTag:"h3"}}),X=new Ht({props:{source:"https://github.com/huggingface/computer-vision-course/blob/main/chapters/en/unit8/3d-vision/nvs.mdx"}}),{c(){w=l("meta"),te=s(),Y=l("p"),ae=s(),v(L.$$.fragment),ne=s(),v(k.$$.fragment),se=s(),R=l("p"),R.textContent=Qe,ie=s(),N=l("p"),N.textContent=Je,le=s(),H=l("p"),H.innerHTML=Ke,re=s(),P=l("p"),P.innerHTML=Ye,oe=s(),v(C.$$.fragment),me=s(),F=l("p"),F.textContent=et,he=s(),f=l("div"),f.innerHTML=tt,pe=s(),o=l("p"),Ge=x("The method first passes the input images through a convolutional neural network (ResNet34), bilinearly upsampling features from multiple layers to the same resolution as the input images."),Ue=l("br"),Be=x(`
As in a standard NeRF, the new view is generated by volume rendering.
However, the NeRF itself has a slightly unusual structure.
At each query point`),fe=new Q(!1),de=x(" in the rendered volume, the corresponding point in the input image(s) is found (by projecting it using the input image camera transformation"),ue=new Q(!1),ce=x(` ).
The input image features at this point,`),ge=new Q(!1),we=x(` are then found by bilinear interpolation.
Like in the original NeRF, the query point`),ve=new Q(!1),xe=x(" is positionally encoded and concatentated with the viewing direction"),be=new Q(!1),ye=x(`.
The NeRF network consists of a set of ResNet blocks; the input image features`),$e=new Q(!1),_e=x(` pass through a linear layer, and are added to the features at the start of each of the first three residual blocks.
There are then two more residual blocks to further process these features, before an output layer reduces the number of channels to four (RGB+density).
When multiple input views are supplied, these are processed independently for the first three residual blocks, and then the features are averaged before the last two blocks.`),Te=s(),S=l("p"),S.innerHTML=at,Me=s(),v(j.$$.fragment),Le=s(),d=l("div"),d.innerHTML=nt,ke=s(),u=l("div"),u.innerHTML=st,Re=s(),z=l("p"),z.innerHTML=it,Ne=s(),v(I.$$.fragment),He=s(),D=l("p"),D.innerHTML=lt,Pe=s(),q=l("p"),q.innerHTML=rt,Ce=s(),v(Z.$$.fragment),Fe=s(),V=l("p"),V.textContent=ot,Se=s(),W=l("p"),W.innerHTML=mt,je=s(),c=l("div"),c.innerHTML=ht,ze=s(),E=l("p"),E.textContent=pt,Ie=s(),A=l("p"),A.innerHTML=ft,De=s(),v(G.$$.fragment),qe=s(),U=l("p"),U.innerHTML=dt,Ze=s(),B=l("p"),B.innerHTML=ut,Ve=s(),O=l("p"),O.innerHTML=ct,We=s(),v(X.$$.fragment),Ee=s(),ee=l("p"),this.h()},l(e){const t=Rt("svelte-u9bgzb",document.head);w=r(t,"META",{name:!0,content:!0}),t.forEach(a),te=i(e),Y=r(e,"P",{}),Oe(Y).forEach(a),ae=i(e),b(L.$$.fragment,e),ne=i(e),b(k.$$.fragment,e),se=i(e),R=r(e,"P",{"data-svelte-h":!0}),m(R)!=="svelte-md009s"&&(R.textContent=Qe),ie=i(e),N=r(e,"P",{"data-svelte-h":!0}),m(N)!=="svelte-ip51yg"&&(N.textContent=Je),le=i(e),H=r(e,"P",{"data-svelte-h":!0}),m(H)!=="svelte-1qxehg6"&&(H.innerHTML=Ke),re=i(e),P=r(e,"P",{"data-svelte-h":!0}),m(P)!=="svelte-zc8dx0"&&(P.innerHTML=Ye),oe=i(e),b(C.$$.fragment,e),me=i(e),F=r(e,"P",{"data-svelte-h":!0}),m(F)!=="svelte-ujrcl0"&&(F.textContent=et),he=i(e),f=r(e,"DIV",{style:!0,"data-svelte-h":!0}),m(f)!=="svelte-1tanwpg"&&(f.innerHTML=tt),pe=i(e),o=r(e,"P",{});var h=Oe(o);Ge=y(h,"The method first passes the input images through a convolutional neural network (ResNet34), bilinearly upsampling features from multiple layers to the same resolution as the input images."),Ue=r(h,"BR",{}),Be=y(h,`
As in a standard NeRF, the new view is generated by volume rendering.
However, the NeRF itself has a slightly unusual structure.
At each query point`),fe=J(h,!1),de=y(h," in the rendered volume, the corresponding point in the input image(s) is found (by projecting it using the input image camera transformation"),ue=J(h,!1),ce=y(h,` ).
The input image features at this point,`),ge=J(h,!1),we=y(h,` are then found by bilinear interpolation.
Like in the original NeRF, the query point`),ve=J(h,!1),xe=y(h," is positionally encoded and concatentated with the viewing direction"),be=J(h,!1),ye=y(h,`.
The NeRF network consists of a set of ResNet blocks; the input image features`),$e=J(h,!1),_e=y(h,` pass through a linear layer, and are added to the features at the start of each of the first three residual blocks.
There are then two more residual blocks to further process these features, before an output layer reduces the number of channels to four (RGB+density).
When multiple input views are supplied, these are processed independently for the first three residual blocks, and then the features are averaged before the last two blocks.`),h.forEach(a),Te=i(e),S=r(e,"P",{"data-svelte-h":!0}),m(S)!=="svelte-18yx0n5"&&(S.innerHTML=at),Me=i(e),b(j.$$.fragment,e),Le=i(e),d=r(e,"DIV",{style:!0,"data-svelte-h":!0}),m(d)!=="svelte-otoniy"&&(d.innerHTML=nt),ke=i(e),u=r(e,"DIV",{style:!0,"data-svelte-h":!0}),m(u)!=="svelte-mnkkqu"&&(u.innerHTML=st),Re=i(e),z=r(e,"P",{"data-svelte-h":!0}),m(z)!=="svelte-riq66z"&&(z.innerHTML=it),Ne=i(e),b(I.$$.fragment,e),He=i(e),D=r(e,"P",{"data-svelte-h":!0}),m(D)!=="svelte-jcdds8"&&(D.innerHTML=lt),Pe=i(e),q=r(e,"P",{"data-svelte-h":!0}),m(q)!=="svelte-1o48r44"&&(q.innerHTML=rt),Ce=i(e),b(Z.$$.fragment,e),Fe=i(e),V=r(e,"P",{"data-svelte-h":!0}),m(V)!=="svelte-177283l"&&(V.textContent=ot),Se=i(e),W=r(e,"P",{"data-svelte-h":!0}),m(W)!=="svelte-1royc2j"&&(W.innerHTML=mt),je=i(e),c=r(e,"DIV",{style:!0,"data-svelte-h":!0}),m(c)!=="svelte-nqz91t"&&(c.innerHTML=ht),ze=i(e),E=r(e,"P",{"data-svelte-h":!0}),m(E)!=="svelte-5qhqp7"&&(E.textContent=pt),Ie=i(e),A=r(e,"P",{"data-svelte-h":!0}),m(A)!=="svelte-v1dukf"&&(A.innerHTML=ft),De=i(e),b(G.$$.fragment,e),qe=i(e),U=r(e,"P",{"data-svelte-h":!0}),m(U)!=="svelte-w10f2v"&&(U.innerHTML=dt),Ze=i(e),B=r(e,"P",{"data-svelte-h":!0}),m(B)!=="svelte-76rb62"&&(B.innerHTML=ut),Ve=i(e),O=r(e,"P",{"data-svelte-h":!0}),m(O)!=="svelte-19l6sm4"&&(O.innerHTML=ct),We=i(e),b(X.$$.fragment,e),Ee=i(e),ee=r(e,"P",{}),Oe(ee).forEach(a),this.h()},h(){gt(w,"name","hf:doc:metadata"),gt(w,"content",Ct),p(f,"display","flex"),p(f,"flex-direction","column"),p(f,"align-items","center"),fe.a=de,ue.a=ce,ge.a=we,ve.a=xe,be.a=ye,$e.a=_e,p(d,"display","flex"),p(d,"flex-direction","column"),p(d,"align-items","center"),p(u,"display","flex"),p(u,"flex-direction","column"),p(u,"align-items","center"),p(c,"display","flex"),p(c,"flex-direction","column"),p(c,"align-items","center")},m(e,t){g(document.head,w),n(e,te,t),n(e,Y,t),n(e,ae,t),$(L,e,t),n(e,ne,t),$(k,e,t),n(e,se,t),n(e,R,t),n(e,ie,t),n(e,N,t),n(e,le,t),n(e,H,t),n(e,re,t),n(e,P,t),n(e,oe,t),$(C,e,t),n(e,me,t),n(e,F,t),n(e,he,t),n(e,f,t),n(e,pe,t),n(e,o,t),g(o,Ge),g(o,Ue),g(o,Be),fe.m(wt,o),g(o,de),ue.m(vt,o),g(o,ce),ge.m(xt,o),g(o,we),ve.m(bt,o),g(o,xe),be.m(yt,o),g(o,ye),$e.m($t,o),g(o,_e),n(e,Te,t),n(e,S,t),n(e,Me,t),$(j,e,t),n(e,Le,t),n(e,d,t),n(e,ke,t),n(e,u,t),n(e,Re,t),n(e,z,t),n(e,Ne,t),$(I,e,t),n(e,He,t),n(e,D,t),n(e,Pe,t),n(e,q,t),n(e,Ce,t),$(Z,e,t),n(e,Fe,t),n(e,V,t),n(e,Se,t),n(e,W,t),n(e,je,t),n(e,c,t),n(e,ze,t),n(e,E,t),n(e,Ie,t),n(e,A,t),n(e,De,t),$(G,e,t),n(e,qe,t),n(e,U,t),n(e,Ze,t),n(e,B,t),n(e,Ve,t),n(e,O,t),n(e,We,t),$(X,e,t),n(e,Ee,t),n(e,ee,t),Ae=!0},p:Tt,i(e){Ae||(_(L.$$.fragment,e),_(k.$$.fragment,e),_(C.$$.fragment,e),_(j.$$.fragment,e),_(I.$$.fragment,e),_(Z.$$.fragment,e),_(G.$$.fragment,e),_(X.$$.fragment,e),Ae=!0)},o(e){T(L.$$.fragment,e),T(k.$$.fragment,e),T(C.$$.fragment,e),T(j.$$.fragment,e),T(I.$$.fragment,e),T(Z.$$.fragment,e),T(G.$$.fragment,e),T(X.$$.fragment,e),Ae=!1},d(e){e&&(a(te),a(Y),a(ae),a(ne),a(se),a(R),a(ie),a(N),a(le),a(H),a(re),a(P),a(oe),a(me),a(F),a(he),a(f),a(pe),a(o),a(Te),a(S),a(Me),a(Le),a(d),a(ke),a(u),a(Re),a(z),a(Ne),a(He),a(D),a(Pe),a(q),a(Ce),a(Fe),a(V),a(Se),a(W),a(je),a(c),a(ze),a(E),a(Ie),a(A),a(De),a(qe),a(U),a(Ze),a(B),a(Ve),a(O),a(We),a(Ee),a(ee)),a(w),M(L,e),M(k,e),M(C,e),M(j,e),M(I,e),M(Z,e),M(G,e),M(X,e)}}}const Ct='{"title":"Novel View Synthesis","local":"novel-view-synthesis","sections":[{"title":"PixelNeRF","local":"pixelnerf","sections":[{"title":"Results (from the PixelNeRF website)","local":"results-from-the-pixelnerf-website","sections":[],"depth":3},{"title":"Related methods","local":"related-methods","sections":[],"depth":3}],"depth":2},{"title":"Zero123 (or Zero-1-to-3)","local":"zero123-or-zero-1-to-3","sections":[{"title":"Related methods","local":"related-methods","sections":[],"depth":3}],"depth":2}],"depth":1}';function Ft(Xe){return Mt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Dt extends Lt{constructor(w){super(),kt(this,w,Ft,Pt,_t,{})}}export{Dt as component};
