import{s as Se,o as Ke,n as ae}from"../chunks/scheduler.18a86fab.js";import{S as Oe,i as et,g as h,s as d,r as f,A as tt,h as m,f as a,c,j as se,x as $,u,k as oe,l as nt,y as g,a as l,v as b,d as y,t as _,w as M}from"../chunks/index.98837b22.js";import{T as Qe}from"../chunks/Tip.77304350.js";import{D as we}from"../chunks/Docstring.6758ea23.js";import{C as Te}from"../chunks/CodeBlock.8d0c2e8a.js";import{E as Pe}from"../chunks/ExampleCodeBlock.0c42463f.js";import{H as $e}from"../chunks/Heading.7e7e0c5b.js";import{H as st,a as qe}from"../chunks/HfOption.6641485e.js";import{E as ot}from"../chunks/index.92f616ba.js";function at(w){let t,p="Click on the Depth Anything models in the right sidebar for more examples of how to apply Depth Anything to different vision tasks.";return{c(){t=h("p"),t.textContent=p},l(n){t=m(n,"P",{"data-svelte-h":!0}),$(t)!=="svelte-abaip3"&&(t.textContent=p)},m(n,i){l(n,t,i)},p:ae,d(n){n&&a(t)}}}function rt(w){let t,p;return t=new Te({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwcGlwZWxpbmUlMEElMEFwaXBlJTIwJTNEJTIwcGlwZWxpbmUodGFzayUzRCUyMmRlcHRoLWVzdGltYXRpb24lMjIlMkMlMjBtb2RlbCUzRCUyMkxpaGVZb3VuZyUyRmRlcHRoLWFueXRoaW5nLWJhc2UtaGYlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTJDJTIwZGV2aWNlJTNEMCklMEFwaXBlKCUyMmh0dHAlM0ElMkYlMkZpbWFnZXMuY29jb2RhdGFzZXQub3JnJTJGdmFsMjAxNyUyRjAwMDAwMDAzOTc2OS5qcGclMjIpJTVCJTIyZGVwdGglMjIlNUQ=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipe = pipeline(task=<span class="hljs-string">&quot;depth-estimation&quot;</span>, model=<span class="hljs-string">&quot;LiheYoung/depth-anything-base-hf&quot;</span>, torch_dtype=torch.bfloat16, device=<span class="hljs-number">0</span>)
pipe(<span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>)[<span class="hljs-string">&quot;depth&quot;</span>]`,wrap:!1}}),{c(){f(t.$$.fragment)},l(n){u(t.$$.fragment,n)},m(n,i){b(t,n,i),p=!0},p:ae,i(n){p||(y(t.$$.fragment,n),p=!0)},o(n){_(t.$$.fragment,n),p=!1},d(n){M(t,n)}}}function it(w){let t,p;return t=new Te({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjByZXF1ZXN0cyUwQWltcG9ydCUyMG51bXB5JTIwYXMlMjBucCUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvSW1hZ2VQcm9jZXNzb3IlMkMlMjBBdXRvTW9kZWxGb3JEZXB0aEVzdGltYXRpb24lMEElMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMkxpaGVZb3VuZyUyRmRlcHRoLWFueXRoaW5nLWJhc2UtaGYlMjIpJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JEZXB0aEVzdGltYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMkxpaGVZb3VuZyUyRmRlcHRoLWFueXRoaW5nLWJhc2UtaGYlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUwQXVybCUyMCUzRCUyMCUyMmh0dHAlM0ElMkYlMkZpbWFnZXMuY29jb2RhdGFzZXQub3JnJTJGdmFsMjAxNyUyRjAwMDAwMDAzOTc2OS5qcGclMjIlMEFpbWFnZSUyMCUzRCUyMEltYWdlLm9wZW4ocmVxdWVzdHMuZ2V0KHVybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdyklMEFpbnB1dHMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2VzJTNEaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBJTBBcG9zdF9wcm9jZXNzZWRfb3V0cHV0JTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yLnBvc3RfcHJvY2Vzc19kZXB0aF9lc3RpbWF0aW9uKCUwQSUyMCUyMCUyMCUyMG91dHB1dHMlMkMlMEElMjAlMjAlMjAlMjB0YXJnZXRfc2l6ZXMlM0QlNUIoaW1hZ2UuaGVpZ2h0JTJDJTIwaW1hZ2Uud2lkdGgpJTVEJTJDJTBBKSUwQXByZWRpY3RlZF9kZXB0aCUyMCUzRCUyMHBvc3RfcHJvY2Vzc2VkX291dHB1dCU1QjAlNUQlNUIlMjJwcmVkaWN0ZWRfZGVwdGglMjIlNUQlMEFkZXB0aCUyMCUzRCUyMChwcmVkaWN0ZWRfZGVwdGglMjAtJTIwcHJlZGljdGVkX2RlcHRoLm1pbigpKSUyMCUyRiUyMChwcmVkaWN0ZWRfZGVwdGgubWF4KCklMjAtJTIwcHJlZGljdGVkX2RlcHRoLm1pbigpKSUwQWRlcHRoJTIwJTNEJTIwZGVwdGguZGV0YWNoKCkuY3B1KCkubnVtcHkoKSUyMColMjAyNTUlMEFJbWFnZS5mcm9tYXJyYXkoZGVwdGguYXN0eXBlKCUyMnVpbnQ4JTIyKSk=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, AutoModelForDepthEstimation

image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;LiheYoung/depth-anything-base-hf&quot;</span>)
model = AutoModelForDepthEstimation.from_pretrained(<span class="hljs-string">&quot;LiheYoung/depth-anything-base-hf&quot;</span>, torch_dtype=torch.bfloat16)
url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
inputs = image_processor(images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-keyword">with</span> torch.no_grad():
    outputs = model(**inputs)

post_processed_output = image_processor.post_process_depth_estimation(
    outputs,
    target_sizes=[(image.height, image.width)],
)
predicted_depth = post_processed_output[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;predicted_depth&quot;</span>]
depth = (predicted_depth - predicted_depth.<span class="hljs-built_in">min</span>()) / (predicted_depth.<span class="hljs-built_in">max</span>() - predicted_depth.<span class="hljs-built_in">min</span>())
depth = depth.detach().cpu().numpy() * <span class="hljs-number">255</span>
Image.fromarray(depth.astype(<span class="hljs-string">&quot;uint8&quot;</span>))`,wrap:!1}}),{c(){f(t.$$.fragment)},l(n){u(t.$$.fragment,n)},m(n,i){b(t,n,i),p=!0},p:ae,i(n){p||(y(t.$$.fragment,n),p=!0)},o(n){_(t.$$.fragment,n),p=!1},d(n){M(t,n)}}}function lt(w){let t,p,n,i;return t=new qe({props:{id:"usage",option:"Pipeline",$$slots:{default:[rt]},$$scope:{ctx:w}}}),n=new qe({props:{id:"usage",option:"AutoModel",$$slots:{default:[it]},$$scope:{ctx:w}}}),{c(){f(t.$$.fragment),p=d(),f(n.$$.fragment)},l(r){u(t.$$.fragment,r),p=c(r),u(n.$$.fragment,r)},m(r,o){b(t,r,o),l(r,p,o),b(n,r,o),i=!0},p(r,o){const T={};o&2&&(T.$$scope={dirty:o,ctx:r}),t.$set(T);const Z={};o&2&&(Z.$$scope={dirty:o,ctx:r}),n.$set(Z)},i(r){i||(y(t.$$.fragment,r),y(n.$$.fragment,r),i=!0)},o(r){_(t.$$.fragment,r),_(n.$$.fragment,r),i=!1},d(r){r&&a(p),M(t,r),M(n,r)}}}function pt(w){let t,p="Example:",n,i,r;return i=new Te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERlcHRoQW55dGhpbmdDb25maWclMkMlMjBEZXB0aEFueXRoaW5nRm9yRGVwdGhFc3RpbWF0aW9uJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMERlcHRoQW55dGhpbmclMjBzbWFsbCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBEZXB0aEFueXRoaW5nQ29uZmlnKCklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwbW9kZWwlMjBmcm9tJTIwdGhlJTIwRGVwdGhBbnl0aGluZyUyMHNtYWxsJTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBEZXB0aEFueXRoaW5nRm9yRGVwdGhFc3RpbWF0aW9uKGNvbmZpZ3VyYXRpb24pJTBBJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMG1vZGVsLmNvbmZpZw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DepthAnythingConfig, DepthAnythingForDepthEstimation

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a DepthAnything small style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = DepthAnythingConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the DepthAnything small style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = DepthAnythingForDepthEstimation(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`,wrap:!1}}),{c(){t=h("p"),t.textContent=p,n=d(),f(i.$$.fragment)},l(o){t=m(o,"P",{"data-svelte-h":!0}),$(t)!=="svelte-11lpom8"&&(t.textContent=p),n=c(o),u(i.$$.fragment,o)},m(o,T){l(o,t,T),l(o,n,T),b(i,o,T),r=!0},p:ae,i(o){r||(y(i.$$.fragment,o),r=!0)},o(o){_(i.$$.fragment,o),r=!1},d(o){o&&(a(t),a(n)),M(i,o)}}}function dt(w){let t,p=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){t=h("p"),t.innerHTML=p},l(n){t=m(n,"P",{"data-svelte-h":!0}),$(t)!=="svelte-fincs2"&&(t.innerHTML=p)},m(n,i){l(n,t,i)},p:ae,d(n){n&&a(t)}}}function ct(w){let t,p="Examples:",n,i,r;return i=new Te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMEF1dG9Nb2RlbEZvckRlcHRoRXN0aW1hdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEElMEF1cmwlMjAlM0QlMjAlMjJodHRwJTNBJTJGJTJGaW1hZ2VzLmNvY29kYXRhc2V0Lm9yZyUyRnZhbDIwMTclMkYwMDAwMDAwMzk3NjkuanBnJTIyJTBBaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBJTBBaW1hZ2VfcHJvY2Vzc29yJTIwJTNEJTIwQXV0b0ltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJMaWhlWW91bmclMkZkZXB0aC1hbnl0aGluZy1zbWFsbC1oZiUyMiklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckRlcHRoRXN0aW1hdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyTGloZVlvdW5nJTJGZGVwdGgtYW55dGhpbmctc21hbGwtaGYlMjIpJTBBJTBBJTIzJTIwcHJlcGFyZSUyMGltYWdlJTIwZm9yJTIwdGhlJTIwbW9kZWwlMEFpbnB1dHMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2VzJTNEaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBJTBBJTIzJTIwaW50ZXJwb2xhdGUlMjB0byUyMG9yaWdpbmFsJTIwc2l6ZSUwQXBvc3RfcHJvY2Vzc2VkX291dHB1dCUyMCUzRCUyMGltYWdlX3Byb2Nlc3Nvci5wb3N0X3Byb2Nlc3NfZGVwdGhfZXN0aW1hdGlvbiglMEElMjAlMjAlMjAlMjBvdXRwdXRzJTJDJTBBJTIwJTIwJTIwJTIwdGFyZ2V0X3NpemVzJTNEJTVCKGltYWdlLmhlaWdodCUyQyUyMGltYWdlLndpZHRoKSU1RCUyQyUwQSklMEElMEElMjMlMjB2aXN1YWxpemUlMjB0aGUlMjBwcmVkaWN0aW9uJTBBcHJlZGljdGVkX2RlcHRoJTIwJTNEJTIwcG9zdF9wcm9jZXNzZWRfb3V0cHV0JTVCMCU1RCU1QiUyMnByZWRpY3RlZF9kZXB0aCUyMiU1RCUwQWRlcHRoJTIwJTNEJTIwcHJlZGljdGVkX2RlcHRoJTIwKiUyMDI1NSUyMCUyRiUyMHByZWRpY3RlZF9kZXB0aC5tYXgoKSUwQWRlcHRoJTIwJTNEJTIwZGVwdGguZGV0YWNoKCkuY3B1KCkubnVtcHkoKSUwQWRlcHRoJTIwJTNEJTIwSW1hZ2UuZnJvbWFycmF5KGRlcHRoLmFzdHlwZSglMjJ1aW50OCUyMikp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, AutoModelForDepthEstimation
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;LiheYoung/depth-anything-small-hf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForDepthEstimation.from_pretrained(<span class="hljs-string">&quot;LiheYoung/depth-anything-small-hf&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># prepare image for the model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = image_processor(images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># interpolate to original size</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>post_processed_output = image_processor.post_process_depth_estimation(
<span class="hljs-meta">... </span>    outputs,
<span class="hljs-meta">... </span>    target_sizes=[(image.height, image.width)],
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># visualize the prediction</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_depth = post_processed_output[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;predicted_depth&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>depth = predicted_depth * <span class="hljs-number">255</span> / predicted_depth.<span class="hljs-built_in">max</span>()
<span class="hljs-meta">&gt;&gt;&gt; </span>depth = depth.detach().cpu().numpy()
<span class="hljs-meta">&gt;&gt;&gt; </span>depth = Image.fromarray(depth.astype(<span class="hljs-string">&quot;uint8&quot;</span>))`,wrap:!1}}),{c(){t=h("p"),t.textContent=p,n=d(),f(i.$$.fragment)},l(o){t=m(o,"P",{"data-svelte-h":!0}),$(t)!=="svelte-kvfsh7"&&(t.textContent=p),n=c(o),u(i.$$.fragment,o)},m(o,T){l(o,t,T),l(o,n,T),b(i,o,T),r=!0},p:ae,i(o){r||(y(i.$$.fragment,o),r=!0)},o(o){_(i.$$.fragment,o),r=!1},d(o){o&&(a(t),a(n)),M(i,o)}}}function ht(w){let t,p,n,i,r,o='<div class="flex flex-wrap space-x-1"><img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-DE3412?style=flat&amp;logo=pytorch&amp;logoColor=white"/></div>',T,Z,ie,E,Ge='<a href="https://huggingface.co/papers/2401.10891" rel="nofollow">Depth Anything</a> is designed to be a foundation model for monocular depth estimation (MDE). It is jointly trained on labeled and ~62M unlabeled images to enhance the dataset. It uses a pretrained <a href="./dinov2">DINOv2</a> model as an image encoder to inherit its existing rich semantic priors, and <a href="./dpt">DPT</a> as the decoder. A teacher model is trained on unlabeled images to create pseudo-labels. The student model is trained on a combination of the pseudo-labels and labeled images. To improve the student model’s performance, strong perturbations are added to the unlabeled images to challenge the student model to learn more visual knowledge from the image.',le,I,Ee='You can find all the original Depth Anything checkpoints under the <a href="https://huggingface.co/collections/LiheYoung/depth-anything-release-65b317de04eec72abf6b55aa" rel="nofollow">Depth Anything</a> collection.',pe,B,de,F,Ie='The example below demonstrates how to obtain a depth map with <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> or the <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoModel">AutoModel</a> class.',ce,U,he,x,me,z,Fe='<li><a href="./depth_anything_v2">DepthAnythingV2</a>, released in June 2024, uses the same architecture as Depth Anything and is compatible with all code examples and existing workflows. It uses synthetic data and a larger capacity teacher model to achieve much finer and robust depth predictions.</li>',ge,V,fe,j,H,je,q,xe=`This is the configuration class to store the configuration of a <code>DepthAnythingModel</code>. It is used to instantiate a DepthAnything
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configuration to that of the DepthAnything
<a href="https://huggingface.co/LiheYoung/depth-anything-small-hf" rel="nofollow">LiheYoung/depth-anything-small-hf</a> architecture.`,Je,S,ze=`Configuration objects inherit from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,ke,R,ve,A,X,We,K,Ve=`Serializes this instance to a Python dictionary. Override the default <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig.to_dict">to_dict()</a>. Returns:
<code>Dict[str, any]</code>: Dictionary of all the attributes that make up this configuration instance,`,ue,N,be,J,L,Ce,O,He="Depth Anything Model with a depth estimation head on top (consisting of 3 convolutional layers) e.g. for KITTI, NYUv2.",Ze,ee,Xe=`This model inherits from <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,Be,te,Ne=`This model is also a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass.
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
and behavior.`,Ue,W,Y,Re,ne,Le='The <a href="/docs/transformers/main/en/model_doc/depth_anything#transformers.DepthAnythingForDepthEstimation">DepthAnythingForDepthEstimation</a> forward method, overrides the <code>__call__</code> special method.',Ae,D,De,G,ye,Q,_e,re,Me;return Z=new $e({props:{title:"Depth Anything",local:"depth-anything",headingTag:"h1"}}),B=new Qe({props:{warning:!1,$$slots:{default:[at]},$$scope:{ctx:w}}}),U=new st({props:{id:"usage",options:["Pipeline","AutoModel"],$$slots:{default:[lt]},$$scope:{ctx:w}}}),x=new $e({props:{title:"Notes",local:"notes",headingTag:"h2"}}),V=new $e({props:{title:"DepthAnythingConfig",local:"transformers.DepthAnythingConfig",headingTag:"h2"}}),H=new we({props:{name:"class transformers.DepthAnythingConfig",anchor:"transformers.DepthAnythingConfig",parameters:[{name:"backbone_config",val:" = None"},{name:"backbone",val:" = None"},{name:"use_pretrained_backbone",val:" = False"},{name:"use_timm_backbone",val:" = False"},{name:"backbone_kwargs",val:" = None"},{name:"patch_size",val:" = 14"},{name:"initializer_range",val:" = 0.02"},{name:"reassemble_hidden_size",val:" = 384"},{name:"reassemble_factors",val:" = [4, 2, 1, 0.5]"},{name:"neck_hidden_sizes",val:" = [48, 96, 192, 384]"},{name:"fusion_hidden_size",val:" = 64"},{name:"head_in_index",val:" = -1"},{name:"head_hidden_size",val:" = 32"},{name:"depth_estimation_type",val:" = 'relative'"},{name:"max_depth",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DepthAnythingConfig.backbone_config",description:`<strong>backbone_config</strong> (<code>Union[Dict[str, Any], PretrainedConfig]</code>, <em>optional</em>) &#x2014;
The configuration of the backbone model. Only used in case <code>is_hybrid</code> is <code>True</code> or in case you want to
leverage the <a href="/docs/transformers/main/en/main_classes/backbones#transformers.AutoBackbone">AutoBackbone</a> API.`,name:"backbone_config"},{anchor:"transformers.DepthAnythingConfig.backbone",description:`<strong>backbone</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Name of backbone to use when <code>backbone_config</code> is <code>None</code>. If <code>use_pretrained_backbone</code> is <code>True</code>, this
will load the corresponding pretrained weights from the timm or transformers library. If <code>use_pretrained_backbone</code>
is <code>False</code>, this loads the backbone&#x2019;s config and uses that to initialize the backbone with random weights.`,name:"backbone"},{anchor:"transformers.DepthAnythingConfig.use_pretrained_backbone",description:`<strong>use_pretrained_backbone</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use pretrained weights for the backbone.`,name:"use_pretrained_backbone"},{anchor:"transformers.DepthAnythingConfig.use_timm_backbone",description:`<strong>use_timm_backbone</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use the <code>timm</code> library for the backbone. If set to <code>False</code>, will use the <a href="/docs/transformers/main/en/main_classes/backbones#transformers.AutoBackbone">AutoBackbone</a>
API.`,name:"use_timm_backbone"},{anchor:"transformers.DepthAnythingConfig.backbone_kwargs",description:`<strong>backbone_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
Keyword arguments to be passed to AutoBackbone when loading from a checkpoint
e.g. <code>{&apos;out_indices&apos;: (0, 1, 2, 3)}</code>. Cannot be specified if <code>backbone_config</code> is set.`,name:"backbone_kwargs"},{anchor:"transformers.DepthAnythingConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 14) &#x2014;
The size of the patches to extract from the backbone features.`,name:"patch_size"},{anchor:"transformers.DepthAnythingConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.DepthAnythingConfig.reassemble_hidden_size",description:`<strong>reassemble_hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 384) &#x2014;
The number of input channels of the reassemble layers.`,name:"reassemble_hidden_size"},{anchor:"transformers.DepthAnythingConfig.reassemble_factors",description:`<strong>reassemble_factors</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[4, 2, 1, 0.5]</code>) &#x2014;
The up/downsampling factors of the reassemble layers.`,name:"reassemble_factors"},{anchor:"transformers.DepthAnythingConfig.neck_hidden_sizes",description:`<strong>neck_hidden_sizes</strong> (<code>List[str]</code>, <em>optional</em>, defaults to <code>[48, 96, 192, 384]</code>) &#x2014;
The hidden sizes to project to for the feature maps of the backbone.`,name:"neck_hidden_sizes"},{anchor:"transformers.DepthAnythingConfig.fusion_hidden_size",description:`<strong>fusion_hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 64) &#x2014;
The number of channels before fusion.`,name:"fusion_hidden_size"},{anchor:"transformers.DepthAnythingConfig.head_in_index",description:`<strong>head_in_index</strong> (<code>int</code>, <em>optional</em>, defaults to -1) &#x2014;
The index of the features to use in the depth estimation head.`,name:"head_in_index"},{anchor:"transformers.DepthAnythingConfig.head_hidden_size",description:`<strong>head_hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
The number of output channels in the second convolution of the depth estimation head.`,name:"head_hidden_size"},{anchor:"transformers.DepthAnythingConfig.depth_estimation_type",description:`<strong>depth_estimation_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;relative&quot;</code>) &#x2014;
The type of depth estimation to use. Can be one of <code>[&quot;relative&quot;, &quot;metric&quot;]</code>.`,name:"depth_estimation_type"},{anchor:"transformers.DepthAnythingConfig.max_depth",description:`<strong>max_depth</strong> (<code>float</code>, <em>optional</em>) &#x2014;
The maximum depth to use for the &#x201C;metric&#x201D; depth estimation head. 20 should be used for indoor models
and 80 for outdoor models. For &#x201C;relative&#x201D; depth estimation, this value is ignored.`,name:"max_depth"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/depth_anything/configuration_depth_anything.py#L28"}}),R=new Pe({props:{anchor:"transformers.DepthAnythingConfig.example",$$slots:{default:[pt]},$$scope:{ctx:w}}}),X=new we({props:{name:"to_dict",anchor:"transformers.DepthAnythingConfig.to_dict",parameters:[],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/depth_anything/configuration_depth_anything.py#L154"}}),N=new $e({props:{title:"DepthAnythingForDepthEstimation",local:"transformers.DepthAnythingForDepthEstimation",headingTag:"h2"}}),L=new we({props:{name:"class transformers.DepthAnythingForDepthEstimation",anchor:"transformers.DepthAnythingForDepthEstimation",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.DepthAnythingForDepthEstimation.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/depth_anything#transformers.DepthAnythingForDepthEstimation">DepthAnythingForDepthEstimation</a>) &#x2014;
Model configuration class with all the parameters of the model. Initializing with a config file does not
load the weights associated with the model, only the configuration. Check out the
<a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/depth_anything/modeling_depth_anything.py#L326"}}),Y=new we({props:{name:"forward",anchor:"transformers.DepthAnythingForDepthEstimation.forward",parameters:[{name:"pixel_values",val:": FloatTensor"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.DepthAnythingForDepthEstimation.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) &#x2014;
The tensors corresponding to the input images. Pixel values can be obtained using
<code>{image_processor_class}</code>. See <code>{image_processor_class}.__call__</code> for details (<code>{processor_class}</code> uses
<code>{image_processor_class}</code> for processing images).`,name:"pixel_values"},{anchor:"transformers.DepthAnythingForDepthEstimation.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, height, width)</code>, <em>optional</em>) &#x2014;
Ground truth depth estimation maps for computing the loss.`,name:"labels"},{anchor:"transformers.DepthAnythingForDepthEstimation.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.DepthAnythingForDepthEstimation.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.DepthAnythingForDepthEstimation.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/depth_anything/modeling_depth_anything.py#L344",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.DepthEstimatorOutput"
>transformers.modeling_outputs.DepthEstimatorOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/depth_anything#transformers.DepthAnythingConfig"
>DepthAnythingConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) — Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>predicted_depth</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, height, width)</code>) — Predicted depth for each pixel.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, num_channels, height, width)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, patch_size, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.DepthEstimatorOutput"
>transformers.modeling_outputs.DepthEstimatorOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),D=new Qe({props:{$$slots:{default:[dt]},$$scope:{ctx:w}}}),G=new Pe({props:{anchor:"transformers.DepthAnythingForDepthEstimation.forward.example",$$slots:{default:[ct]},$$scope:{ctx:w}}}),Q=new ot({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/depth_anything.md"}}),{c(){t=h("meta"),p=d(),n=h("p"),i=d(),r=h("div"),r.innerHTML=o,T=d(),f(Z.$$.fragment),ie=d(),E=h("p"),E.innerHTML=Ge,le=d(),I=h("p"),I.innerHTML=Ee,pe=d(),f(B.$$.fragment),de=d(),F=h("p"),F.innerHTML=Ie,ce=d(),f(U.$$.fragment),he=d(),f(x.$$.fragment),me=d(),z=h("ul"),z.innerHTML=Fe,ge=d(),f(V.$$.fragment),fe=d(),j=h("div"),f(H.$$.fragment),je=d(),q=h("p"),q.innerHTML=xe,Je=d(),S=h("p"),S.innerHTML=ze,ke=d(),f(R.$$.fragment),ve=d(),A=h("div"),f(X.$$.fragment),We=d(),K=h("p"),K.innerHTML=Ve,ue=d(),f(N.$$.fragment),be=d(),J=h("div"),f(L.$$.fragment),Ce=d(),O=h("p"),O.textContent=He,Ze=d(),ee=h("p"),ee.innerHTML=Xe,Be=d(),te=h("p"),te.innerHTML=Ne,Ue=d(),W=h("div"),f(Y.$$.fragment),Re=d(),ne=h("p"),ne.innerHTML=Le,Ae=d(),f(D.$$.fragment),De=d(),f(G.$$.fragment),ye=d(),f(Q.$$.fragment),_e=d(),re=h("p"),this.h()},l(e){const s=tt("svelte-u9bgzb",document.head);t=m(s,"META",{name:!0,content:!0}),s.forEach(a),p=c(e),n=m(e,"P",{}),se(n).forEach(a),i=c(e),r=m(e,"DIV",{style:!0,"data-svelte-h":!0}),$(r)!=="svelte-wa5t4p"&&(r.innerHTML=o),T=c(e),u(Z.$$.fragment,e),ie=c(e),E=m(e,"P",{"data-svelte-h":!0}),$(E)!=="svelte-19r763q"&&(E.innerHTML=Ge),le=c(e),I=m(e,"P",{"data-svelte-h":!0}),$(I)!=="svelte-1eiwyw0"&&(I.innerHTML=Ee),pe=c(e),u(B.$$.fragment,e),de=c(e),F=m(e,"P",{"data-svelte-h":!0}),$(F)!=="svelte-1mk72k5"&&(F.innerHTML=Ie),ce=c(e),u(U.$$.fragment,e),he=c(e),u(x.$$.fragment,e),me=c(e),z=m(e,"UL",{"data-svelte-h":!0}),$(z)!=="svelte-1sfp44y"&&(z.innerHTML=Fe),ge=c(e),u(V.$$.fragment,e),fe=c(e),j=m(e,"DIV",{class:!0});var k=se(j);u(H.$$.fragment,k),je=c(k),q=m(k,"P",{"data-svelte-h":!0}),$(q)!=="svelte-30ivap"&&(q.innerHTML=xe),Je=c(k),S=m(k,"P",{"data-svelte-h":!0}),$(S)!=="svelte-o55m63"&&(S.innerHTML=ze),ke=c(k),u(R.$$.fragment,k),ve=c(k),A=m(k,"DIV",{class:!0});var P=se(A);u(X.$$.fragment,P),We=c(P),K=m(P,"P",{"data-svelte-h":!0}),$(K)!=="svelte-f91b28"&&(K.innerHTML=Ve),P.forEach(a),k.forEach(a),ue=c(e),u(N.$$.fragment,e),be=c(e),J=m(e,"DIV",{class:!0});var v=se(J);u(L.$$.fragment,v),Ce=c(v),O=m(v,"P",{"data-svelte-h":!0}),$(O)!=="svelte-1lyww6q"&&(O.textContent=He),Ze=c(v),ee=m(v,"P",{"data-svelte-h":!0}),$(ee)!=="svelte-6pahdo"&&(ee.innerHTML=Xe),Be=c(v),te=m(v,"P",{"data-svelte-h":!0}),$(te)!=="svelte-hswkmf"&&(te.innerHTML=Ne),Ue=c(v),W=m(v,"DIV",{class:!0});var C=se(W);u(Y.$$.fragment,C),Re=c(C),ne=m(C,"P",{"data-svelte-h":!0}),$(ne)!=="svelte-tvw6fn"&&(ne.innerHTML=Le),Ae=c(C),u(D.$$.fragment,C),De=c(C),u(G.$$.fragment,C),C.forEach(a),v.forEach(a),ye=c(e),u(Q.$$.fragment,e),_e=c(e),re=m(e,"P",{}),se(re).forEach(a),this.h()},h(){oe(t,"name","hf:doc:metadata"),oe(t,"content",mt),nt(r,"float","right"),oe(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),oe(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),oe(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),oe(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,s){g(document.head,t),l(e,p,s),l(e,n,s),l(e,i,s),l(e,r,s),l(e,T,s),b(Z,e,s),l(e,ie,s),l(e,E,s),l(e,le,s),l(e,I,s),l(e,pe,s),b(B,e,s),l(e,de,s),l(e,F,s),l(e,ce,s),b(U,e,s),l(e,he,s),b(x,e,s),l(e,me,s),l(e,z,s),l(e,ge,s),b(V,e,s),l(e,fe,s),l(e,j,s),b(H,j,null),g(j,je),g(j,q),g(j,Je),g(j,S),g(j,ke),b(R,j,null),g(j,ve),g(j,A),b(X,A,null),g(A,We),g(A,K),l(e,ue,s),b(N,e,s),l(e,be,s),l(e,J,s),b(L,J,null),g(J,Ce),g(J,O),g(J,Ze),g(J,ee),g(J,Be),g(J,te),g(J,Ue),g(J,W),b(Y,W,null),g(W,Re),g(W,ne),g(W,Ae),b(D,W,null),g(W,De),b(G,W,null),l(e,ye,s),b(Q,e,s),l(e,_e,s),l(e,re,s),Me=!0},p(e,[s]){const k={};s&2&&(k.$$scope={dirty:s,ctx:e}),B.$set(k);const P={};s&2&&(P.$$scope={dirty:s,ctx:e}),U.$set(P);const v={};s&2&&(v.$$scope={dirty:s,ctx:e}),R.$set(v);const C={};s&2&&(C.$$scope={dirty:s,ctx:e}),D.$set(C);const Ye={};s&2&&(Ye.$$scope={dirty:s,ctx:e}),G.$set(Ye)},i(e){Me||(y(Z.$$.fragment,e),y(B.$$.fragment,e),y(U.$$.fragment,e),y(x.$$.fragment,e),y(V.$$.fragment,e),y(H.$$.fragment,e),y(R.$$.fragment,e),y(X.$$.fragment,e),y(N.$$.fragment,e),y(L.$$.fragment,e),y(Y.$$.fragment,e),y(D.$$.fragment,e),y(G.$$.fragment,e),y(Q.$$.fragment,e),Me=!0)},o(e){_(Z.$$.fragment,e),_(B.$$.fragment,e),_(U.$$.fragment,e),_(x.$$.fragment,e),_(V.$$.fragment,e),_(H.$$.fragment,e),_(R.$$.fragment,e),_(X.$$.fragment,e),_(N.$$.fragment,e),_(L.$$.fragment,e),_(Y.$$.fragment,e),_(D.$$.fragment,e),_(G.$$.fragment,e),_(Q.$$.fragment,e),Me=!1},d(e){e&&(a(p),a(n),a(i),a(r),a(T),a(ie),a(E),a(le),a(I),a(pe),a(de),a(F),a(ce),a(he),a(me),a(z),a(ge),a(fe),a(j),a(ue),a(be),a(J),a(ye),a(_e),a(re)),a(t),M(Z,e),M(B,e),M(U,e),M(x,e),M(V,e),M(H),M(R),M(X),M(N,e),M(L),M(Y),M(D),M(G),M(Q,e)}}}const mt='{"title":"Depth Anything","local":"depth-anything","sections":[{"title":"Notes","local":"notes","sections":[],"depth":2},{"title":"DepthAnythingConfig","local":"transformers.DepthAnythingConfig","sections":[],"depth":2},{"title":"DepthAnythingForDepthEstimation","local":"transformers.DepthAnythingForDepthEstimation","sections":[],"depth":2}],"depth":1}';function gt(w){return Ke(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class jt extends Oe{constructor(t){super(),et(this,t,gt,ht,Se,{})}}export{jt as component};
