import{s as yt,n as _t,o as $t}from"../chunks/scheduler.7bc62968.js";import{S as Tt,i as Mt,g as l,s,r as A,m as v,H as X,A as kt,h as r,f as a,c as i,j as Be,u as E,x as h,n as x,B as Q,k as ut,l as p,y as g,a as n,v as G,d as B,t as U,w as O}from"../chunks/index.2f8492b0.js";import{H as J,E as Rt}from"../chunks/EditOnGithub.2a9ce03a.js";function Lt(Ue){let w,ee,K,te,b,ae,y,Oe=`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.`,ne,_,Xe=`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.`,se,$,Qe=`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.`,ie,T,Je=`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.`,le,M,re,k,Ke=`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.`,oe,f,Ye='<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>',he,o,Ae,Ee,Ge,me,ct='<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>',pe,fe,gt='<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>',de,ue,wt='<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>',ce,ge,vt='<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>',we,ve,xt='<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>',xe,be,bt='<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>',ye,_e,R,et=`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).`,$e,L,Te,d,tt='<img src="https://huggingface.co/datasets/hf-vision/course-assets/resolve/main/PixelNeRF_input.png" alt="Input image of a chair"/>',Me,u,at='<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>',ke,N,nt='The PixelNeRF code can be found on <a href="https://github.com/sxyu/pixel-nerf" rel="nofollow">GitHub</a>.',Re,H,Le,P,st='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>.',Ne,C,it=`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>.`,He,F,Pe,S,lt=`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.`,Ce,j,rt=`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).`,Fe,c,ot='<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>',Se,z,ht=`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.`,je,I,mt='To explore this model further, see the <a href="https://huggingface.co/spaces/cvlab/zero123-live" rel="nofollow">Live Demo</a>.',ze,D,Ie,q,pt='<a href="https://3d-diffusion.github.io/" rel="nofollow">3DiM</a> - X-UNet architecture, with cross-attention between input and noisy frames.',De,Z,ft='<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>.',qe,V,dt='<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.',Ze,W,Ve,Y,We;return b=new J({props:{title:"Novel View Synthesis",local:"novel-view-synthesis",headingTag:"h1"}}),M=new J({props:{title:"PixelNeRF",local:"pixelnerf",headingTag:"h2"}}),L=new J({props:{title:"Results (from the PixelNeRF website)",local:"results-from-the-pixelnerf-website",headingTag:"h3"}}),H=new J({props:{title:"Related methods",local:"related-methods",headingTag:"h3"}}),F=new J({props:{title:"Zero123 (or Zero-1-to-3)",local:"zero123-or-zero-1-to-3",headingTag:"h2"}}),D=new J({props:{title:"Related methods",local:"related-methods",headingTag:"h3"}}),W=new Rt({props:{source:"https://github.com/huggingface/computer-vision-course/blob/main/chapters/en/unit8/3d-vision/nvs.mdx"}}),{c(){w=l("meta"),ee=s(),K=l("p"),te=s(),A(b.$$.fragment),ae=s(),y=l("p"),y.textContent=Oe,ne=s(),_=l("p"),_.textContent=Xe,se=s(),$=l("p"),$.innerHTML=Qe,ie=s(),T=l("p"),T.innerHTML=Je,le=s(),A(M.$$.fragment),re=s(),k=l("p"),k.textContent=Ke,oe=s(),f=l("div"),f.innerHTML=Ye,he=s(),o=l("p"),Ae=v("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."),Ee=l("br"),Ge=v(`
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`),me=new X(!1),pe=v(" in the rendered volume, the corresponding point in the input image(s) is found (by projecting it using the input image camera transformation"),fe=new X(!1),de=v(` ).
The input image features at this point,`),ue=new X(!1),ce=v(` are then found by bilinear interpolation.
Like in the original NeRF, the query point`),ge=new X(!1),we=v(" is positionally encoded and concatentated with the viewing direction"),ve=new X(!1),xe=v(`.
The NeRF network consists of a set of ResNet blocks; the input image features`),be=new X(!1),ye=v(` 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.`),_e=s(),R=l("p"),R.innerHTML=et,$e=s(),A(L.$$.fragment),Te=s(),d=l("div"),d.innerHTML=tt,Me=s(),u=l("div"),u.innerHTML=at,ke=s(),N=l("p"),N.innerHTML=nt,Re=s(),A(H.$$.fragment),Le=s(),P=l("p"),P.innerHTML=st,Ne=s(),C=l("p"),C.innerHTML=it,He=s(),A(F.$$.fragment),Pe=s(),S=l("p"),S.textContent=lt,Ce=s(),j=l("p"),j.innerHTML=rt,Fe=s(),c=l("div"),c.innerHTML=ot,Se=s(),z=l("p"),z.textContent=ht,je=s(),I=l("p"),I.innerHTML=mt,ze=s(),A(D.$$.fragment),Ie=s(),q=l("p"),q.innerHTML=pt,De=s(),Z=l("p"),Z.innerHTML=ft,qe=s(),V=l("p"),V.innerHTML=dt,Ze=s(),A(W.$$.fragment),Ve=s(),Y=l("p"),this.h()},l(e){const t=kt("svelte-u9bgzb",document.head);w=r(t,"META",{name:!0,content:!0}),t.forEach(a),ee=i(e),K=r(e,"P",{}),Be(K).forEach(a),te=i(e),E(b.$$.fragment,e),ae=i(e),y=r(e,"P",{"data-svelte-h":!0}),h(y)!=="svelte-md009s"&&(y.textContent=Oe),ne=i(e),_=r(e,"P",{"data-svelte-h":!0}),h(_)!=="svelte-ip51yg"&&(_.textContent=Xe),se=i(e),$=r(e,"P",{"data-svelte-h":!0}),h($)!=="svelte-1qxehg6"&&($.innerHTML=Qe),ie=i(e),T=r(e,"P",{"data-svelte-h":!0}),h(T)!=="svelte-zc8dx0"&&(T.innerHTML=Je),le=i(e),E(M.$$.fragment,e),re=i(e),k=r(e,"P",{"data-svelte-h":!0}),h(k)!=="svelte-ujrcl0"&&(k.textContent=Ke),oe=i(e),f=r(e,"DIV",{style:!0,"data-svelte-h":!0}),h(f)!=="svelte-1tanwpg"&&(f.innerHTML=Ye),he=i(e),o=r(e,"P",{});var m=Be(o);Ae=x(m,"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."),Ee=r(m,"BR",{}),Ge=x(m,`
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`),me=Q(m,!1),pe=x(m," in the rendered volume, the corresponding point in the input image(s) is found (by projecting it using the input image camera transformation"),fe=Q(m,!1),de=x(m,` ).
The input image features at this point,`),ue=Q(m,!1),ce=x(m,` are then found by bilinear interpolation.
Like in the original NeRF, the query point`),ge=Q(m,!1),we=x(m," is positionally encoded and concatentated with the viewing direction"),ve=Q(m,!1),xe=x(m,`.
The NeRF network consists of a set of ResNet blocks; the input image features`),be=Q(m,!1),ye=x(m,` 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.`),m.forEach(a),_e=i(e),R=r(e,"P",{"data-svelte-h":!0}),h(R)!=="svelte-18yx0n5"&&(R.innerHTML=et),$e=i(e),E(L.$$.fragment,e),Te=i(e),d=r(e,"DIV",{style:!0,"data-svelte-h":!0}),h(d)!=="svelte-otoniy"&&(d.innerHTML=tt),Me=i(e),u=r(e,"DIV",{style:!0,"data-svelte-h":!0}),h(u)!=="svelte-mnkkqu"&&(u.innerHTML=at),ke=i(e),N=r(e,"P",{"data-svelte-h":!0}),h(N)!=="svelte-riq66z"&&(N.innerHTML=nt),Re=i(e),E(H.$$.fragment,e),Le=i(e),P=r(e,"P",{"data-svelte-h":!0}),h(P)!=="svelte-jcdds8"&&(P.innerHTML=st),Ne=i(e),C=r(e,"P",{"data-svelte-h":!0}),h(C)!=="svelte-1o48r44"&&(C.innerHTML=it),He=i(e),E(F.$$.fragment,e),Pe=i(e),S=r(e,"P",{"data-svelte-h":!0}),h(S)!=="svelte-177283l"&&(S.textContent=lt),Ce=i(e),j=r(e,"P",{"data-svelte-h":!0}),h(j)!=="svelte-1royc2j"&&(j.innerHTML=rt),Fe=i(e),c=r(e,"DIV",{style:!0,"data-svelte-h":!0}),h(c)!=="svelte-nqz91t"&&(c.innerHTML=ot),Se=i(e),z=r(e,"P",{"data-svelte-h":!0}),h(z)!=="svelte-5qhqp7"&&(z.textContent=ht),je=i(e),I=r(e,"P",{"data-svelte-h":!0}),h(I)!=="svelte-v1dukf"&&(I.innerHTML=mt),ze=i(e),E(D.$$.fragment,e),Ie=i(e),q=r(e,"P",{"data-svelte-h":!0}),h(q)!=="svelte-w10f2v"&&(q.innerHTML=pt),De=i(e),Z=r(e,"P",{"data-svelte-h":!0}),h(Z)!=="svelte-76rb62"&&(Z.innerHTML=ft),qe=i(e),V=r(e,"P",{"data-svelte-h":!0}),h(V)!=="svelte-19l6sm4"&&(V.innerHTML=dt),Ze=i(e),E(W.$$.fragment,e),Ve=i(e),Y=r(e,"P",{}),Be(Y).forEach(a),this.h()},h(){ut(w,"name","hf:doc:metadata"),ut(w,"content",Nt),p(f,"display","flex"),p(f,"flex-direction","column"),p(f,"align-items","center"),me.a=pe,fe.a=de,ue.a=ce,ge.a=we,ve.a=xe,be.a=ye,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,ee,t),n(e,K,t),n(e,te,t),G(b,e,t),n(e,ae,t),n(e,y,t),n(e,ne,t),n(e,_,t),n(e,se,t),n(e,$,t),n(e,ie,t),n(e,T,t),n(e,le,t),G(M,e,t),n(e,re,t),n(e,k,t),n(e,oe,t),n(e,f,t),n(e,he,t),n(e,o,t),g(o,Ae),g(o,Ee),g(o,Ge),me.m(ct,o),g(o,pe),fe.m(gt,o),g(o,de),ue.m(wt,o),g(o,ce),ge.m(vt,o),g(o,we),ve.m(xt,o),g(o,xe),be.m(bt,o),g(o,ye),n(e,_e,t),n(e,R,t),n(e,$e,t),G(L,e,t),n(e,Te,t),n(e,d,t),n(e,Me,t),n(e,u,t),n(e,ke,t),n(e,N,t),n(e,Re,t),G(H,e,t),n(e,Le,t),n(e,P,t),n(e,Ne,t),n(e,C,t),n(e,He,t),G(F,e,t),n(e,Pe,t),n(e,S,t),n(e,Ce,t),n(e,j,t),n(e,Fe,t),n(e,c,t),n(e,Se,t),n(e,z,t),n(e,je,t),n(e,I,t),n(e,ze,t),G(D,e,t),n(e,Ie,t),n(e,q,t),n(e,De,t),n(e,Z,t),n(e,qe,t),n(e,V,t),n(e,Ze,t),G(W,e,t),n(e,Ve,t),n(e,Y,t),We=!0},p:_t,i(e){We||(B(b.$$.fragment,e),B(M.$$.fragment,e),B(L.$$.fragment,e),B(H.$$.fragment,e),B(F.$$.fragment,e),B(D.$$.fragment,e),B(W.$$.fragment,e),We=!0)},o(e){U(b.$$.fragment,e),U(M.$$.fragment,e),U(L.$$.fragment,e),U(H.$$.fragment,e),U(F.$$.fragment,e),U(D.$$.fragment,e),U(W.$$.fragment,e),We=!1},d(e){e&&(a(ee),a(K),a(te),a(ae),a(y),a(ne),a(_),a(se),a($),a(ie),a(T),a(le),a(re),a(k),a(oe),a(f),a(he),a(o),a(_e),a(R),a($e),a(Te),a(d),a(Me),a(u),a(ke),a(N),a(Re),a(Le),a(P),a(Ne),a(C),a(He),a(Pe),a(S),a(Ce),a(j),a(Fe),a(c),a(Se),a(z),a(je),a(I),a(ze),a(Ie),a(q),a(De),a(Z),a(qe),a(V),a(Ze),a(Ve),a(Y)),a(w),O(b,e),O(M,e),O(L,e),O(H,e),O(F,e),O(D,e),O(W,e)}}}const Nt='{"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 Ht(Ue){return $t(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class St extends Tt{constructor(w){super(),Mt(this,w,Ht,Lt,yt,{})}}export{St as component};
