Buckets:
| import"../chunks/DsnmJJEf.js";import{i as Ue,h as xe,C as Ge,H as n,c as We,a as t,D as s,E as Ne,s as Be}from"../chunks/BtE7mKSK.js";import{p as Re,o as ze,s as e,f as m,a as p,b as Xe,c as o,d as Z,n as r,r as i}from"../chunks/jDjavuwI.js";import{E as u}from"../chunks/SrSJA0zO.js";const ke='{"title":"Marigold Computer Vision","local":"marigold-computer-vision","sections":[{"title":"Available Pipelines","local":"available-pipelines","sections":[],"depth":2},{"title":"Available Checkpoints","local":"available-checkpoints","sections":[],"depth":2},{"title":"Depth Prediction","local":"depth-prediction","sections":[],"depth":2},{"title":"Surface Normals Estimation","local":"surface-normals-estimation","sections":[],"depth":2},{"title":"Intrinsic Image Decomposition","local":"intrinsic-image-decomposition","sections":[],"depth":2},{"title":"Speeding up inference","local":"speeding-up-inference","sections":[],"depth":2},{"title":"Maximizing Precision and Ensembling","local":"maximizing-precision-and-ensembling","sections":[],"depth":2},{"title":"Frame-by-frame Video Processing with Temporal Consistency","local":"frame-by-frame-video-processing-with-temporal-consistency","sections":[],"depth":2},{"title":"Marigold for ControlNet","local":"marigold-for-controlnet","sections":[],"depth":2},{"title":"Quantitative Evaluation","local":"quantitative-evaluation","sections":[],"depth":2},{"title":"Using Predictive Uncertainty","local":"using-predictive-uncertainty","sections":[],"depth":2},{"title":"Marigold Depth Prediction API","local":"diffusers.MarigoldDepthPipeline","sections":[],"depth":2},{"title":"Marigold Normals Estimation API","local":"diffusers.MarigoldNormalsPipeline","sections":[],"depth":2},{"title":"Marigold Intrinsic Image Decomposition API","local":"diffusers.MarigoldIntrinsicsPipeline","sections":[],"depth":2}],"depth":1}';var Ve=Z('<meta name="hf:doc:metadata"/>'),v=Z("<p>Examples:</p> <!>",1),qe=Z(`<p></p> <!> <!> <p><img src="https://marigoldmonodepth.github.io/images/teaser_collage_compressed.jpg" alt="marigold"/></p> <p>Marigold was proposed in <a href="https://huggingface.co/papers/2312.02145" rel="nofollow">Repurposing Diffusion-Based Image Generators for Monocular Depth Estimation</a>, | |
| a CVPR 2024 Oral paper by <a href="http://www.kebingxin.com/" rel="nofollow">Bingxin Ke</a>, <a href="https://www.obukhov.ai/" rel="nofollow">Anton Obukhov</a>, <a href="https://shengyuh.github.io/" rel="nofollow">Shengyu Huang</a>, <a href="https://nandometzger.github.io/" rel="nofollow">Nando Metzger</a>, <a href="https://rcdaudt.github.io/" rel="nofollow">Rodrigo Caye Daudt</a>, and <a href="https://scholar.google.com/citations?user=FZuNgqIAAAAJ&hl=en" rel="nofollow">Konrad Schindler</a>. | |
| The core idea is to <strong>repurpose the generative prior of Text-to-Image Latent Diffusion Models (LDMs) for traditional | |
| computer vision tasks</strong>. | |
| This approach was explored by fine-tuning Stable Diffusion for <strong>Monocular Depth Estimation</strong>, as demonstrated in the | |
| teaser above.</p> <p>Marigold was later extended in the follow-up paper, <a href="https://huggingface.co/papers/2312.02145" rel="nofollow">Marigold: Affordable Adaptation of Diffusion-Based Image Generators for Image Analysis</a>, | |
| authored by <a href="http://www.kebingxin.com/" rel="nofollow">Bingxin Ke</a>, <a href="https://www.linkedin.com/in/kevin-qu-b3417621b/?locale=en_US" rel="nofollow">Kevin Qu</a>, <a href="https://tianfwang.github.io/" rel="nofollow">Tianfu Wang</a>, <a href="https://nandometzger.github.io/" rel="nofollow">Nando Metzger</a>, <a href="https://shengyuh.github.io/" rel="nofollow">Shengyu Huang</a>, <a href="https://www.linkedin.com/in/bobboli0202/" rel="nofollow">Bo Li</a>, <a href="https://www.obukhov.ai/" rel="nofollow">Anton Obukhov</a>, and <a href="https://scholar.google.com/citations?user=FZuNgqIAAAAJ&hl=en" rel="nofollow">Konrad Schindler</a>. | |
| This work expanded Marigold to support new modalities such as <strong>Surface Normals</strong> and <strong>Intrinsic Image Decomposition</strong> (IID), introduced a training protocol for <strong>Latent Consistency Models</strong> (LCM), and demonstrated <strong>High-Resolution</strong> (HR) | |
| processing capability.</p> <blockquote class="tip"><p>The early Marigold models (<code>v1-0</code> and earlier) were optimized for best results with at least 10 inference steps. | |
| LCM models were later developed to enable high-quality inference in just 1 to 4 steps. | |
| Marigold models <code>v1-1</code> and later use the DDIM scheduler to achieve optimal | |
| results in as few as 1 to 4 steps.</p></blockquote> <!> <p>Each pipeline is tailored for a specific computer vision task, processing an input RGB image and generating a | |
| corresponding prediction. | |
| Currently, the following computer vision tasks are implemented:</p> <table><thead><tr><th>Pipeline</th><th>Recommended Model Checkpoints</th><th align="center">Spaces (Interactive Apps)</th><th>Predicted Modalities</th></tr></thead><tbody><tr><td><a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/marigold/pipeline_marigold_depth.py" rel="nofollow">MarigoldDepthPipeline</a></td><td><a href="https://huggingface.co/prs-eth/marigold-depth-v1-1" rel="nofollow">prs-eth/marigold-depth-v1-1</a></td><td align="center"><a href="https://huggingface.co/spaces/prs-eth/marigold" rel="nofollow">Depth Estimation</a></td><td><a href="https://en.wikipedia.org/wiki/Depth_map" rel="nofollow">Depth</a>, <a href="https://en.wikipedia.org/wiki/Binocular_disparity" rel="nofollow">Disparity</a></td></tr><tr><td><a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/marigold/pipeline_marigold_normals.py" rel="nofollow">MarigoldNormalsPipeline</a></td><td><a href="https://huggingface.co/prs-eth/marigold-normals-v1-1" rel="nofollow">prs-eth/marigold-normals-v1-1</a></td><td align="center"><a href="https://huggingface.co/spaces/prs-eth/marigold-normals" rel="nofollow">Surface Normals Estimation</a></td><td><a href="https://en.wikipedia.org/wiki/Normal_mapping" rel="nofollow">Surface normals</a></td></tr><tr><td><a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/marigold/pipeline_marigold_intrinsics.py" rel="nofollow">MarigoldIntrinsicsPipeline</a></td><td><a href="https://huggingface.co/prs-eth/marigold-iid-appearance-v1-1" rel="nofollow">prs-eth/marigold-iid-appearance-v1-1</a>,<br/><a href="https://huggingface.co/prs-eth/marigold-iid-lighting-v1-1" rel="nofollow">prs-eth/marigold-iid-lighting-v1-1</a></td><td align="center"><a href="https://huggingface.co/spaces/prs-eth/marigold-iid" rel="nofollow">Intrinsic Image Decomposition</a></td><td><a href="https://en.wikipedia.org/wiki/Albedo" rel="nofollow">Albedo</a>, <a href="https://www.n.aiq3d.com/wiki/roughnessmetalnessao-map" rel="nofollow">Materials</a>, <a href="https://en.wikipedia.org/wiki/Diffuse_reflection" rel="nofollow">Lighting</a></td></tr></tbody></table> <!> <p>All original checkpoints are available under the <a href="https://huggingface.co/prs-eth/" rel="nofollow">PRS-ETH</a> organization on Hugging Face. | |
| They are designed for use with diffusers pipelines and the <a href="https://github.com/prs-eth/marigold" rel="nofollow">original codebase</a>, which can also be used to train | |
| new model checkpoints. | |
| The following is a summary of the recommended checkpoints, all of which produce reliable results with 1 to 4 steps.</p> <table><thead><tr><th>Checkpoint</th><th>Modality</th><th>Comment</th></tr></thead><tbody><tr><td><a href="https://huggingface.co/prs-eth/marigold-depth-v1-1" rel="nofollow">prs-eth/marigold-depth-v1-1</a></td><td>Depth</td><td>Affine-invariant depth prediction assigns each pixel a value between 0 (near plane) and 1 (far plane), with both planes determined by the model during inference.</td></tr><tr><td><a href="https://huggingface.co/prs-eth/marigold-normals-v0-1" rel="nofollow">prs-eth/marigold-normals-v0-1</a></td><td>Normals</td><td>The surface normals predictions are unit-length 3D vectors in the screen space camera, with values in the range from -1 to 1.</td></tr><tr><td><a href="https://huggingface.co/prs-eth/marigold-iid-appearance-v1-1" rel="nofollow">prs-eth/marigold-iid-appearance-v1-1</a></td><td>Intrinsics</td><td>InteriorVerse decomposition is comprised of Albedo and two BRDF material properties: Roughness and Metallicity.</td></tr><tr><td><a href="https://huggingface.co/prs-eth/marigold-iid-lighting-v1-1" rel="nofollow">prs-eth/marigold-iid-lighting-v1-1</a></td><td>Intrinsics</td><td>HyperSim decomposition of an image <!> is comprised of Albedo $A$, Diffuse shading $S$, and Non-diffuse residual $R$: $I = A*S+R$.</td></tr></tbody></table> <blockquote class="tip"><p>Make sure to check out the Schedulers <a href="../../using-diffusers/schedulers">guide</a> to learn how to explore the tradeoff | |
| between scheduler speed and quality, and see the <a href="../../using-diffusers/loading#reuse-a-pipeline">reuse components across pipelines</a> section to learn how to | |
| efficiently load the same components into multiple pipelines. | |
| Also, to know more about reducing the memory usage of this pipeline, refer to the [“Reduce memory usage”] section <a href="./stable_diffusion/svd#reduce-memory-usage">here</a>.</p></blockquote> <blockquote class="warning"><p>Marigold pipelines were designed and tested with the scheduler embedded in the model checkpoint. | |
| The optimal number of inference steps varies by scheduler, with no universal value that works best across all cases. | |
| To accommodate this, the <code>num_inference_steps</code> parameter in the pipeline’s <code>__call__</code> method defaults to <code>None</code> (see the | |
| API reference). | |
| Unless set explicitly, it inherits the value from the <code>default_denoising_steps</code> field in the checkpoint configuration | |
| file (<code>model_index.json</code>). | |
| This ensures high-quality predictions when invoking the pipeline with only the <code>image</code> argument.</p></blockquote> <p>The examples below are mostly given for depth prediction, but they can be universally applied to other supported | |
| modalities. | |
| We showcase the predictions using the same input image of Albert Einstein generated by Midjourney. | |
| This makes it easier to compare visualizations of the predictions across various modalities and checkpoints.</p> <div class="flex gap-4" style="justify-content: center; width: 100%;"><div style="flex: 1 1 50%; max-width: 50%;"><img class="rounded-xl" src="https://marigoldmonodepth.github.io/images/einstein.jpg"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Example input image for all Marigold pipelines</figcaption></div></div> <!> <p>To get a depth prediction, load the <code>prs-eth/marigold-depth-v1-1</code> checkpoint into <a href="/docs/diffusers/pr_14178/en/api/pipelines/marigold#diffusers.MarigoldDepthPipeline">MarigoldDepthPipeline</a>, | |
| put the image through the pipeline, and save the predictions:</p> <!> <p>The <a href="/docs/diffusers/pr_14178/en/api/pipelines/marigold#diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_depth">visualize_depth()</a> function applies one of <a href="https://matplotlib.org/stable/users/explain/colors/colormaps.html" rel="nofollow">matplotlib’s colormaps</a> (<code>Spectral</code> by default) to map the predicted pixel values from a single-channel <code>[0, 1]</code> depth range into an RGB image. | |
| With the <code>Spectral</code> colormap, pixels with near depth are painted red, and far pixels are blue. | |
| The 16-bit PNG file stores the single channel values mapped linearly from the <code>[0, 1]</code> range into <code>[0, 65535]</code>. | |
| Below are the raw and the visualized predictions. The darker and closer areas (mustache) are easier to distinguish in | |
| the visualization.</p> <div class="flex gap-4"><div style="flex: 1 1 50%; max-width: 50%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/marigold/marigold_einstein_lcm_depth_16bit.png"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Predicted depth (16-bit PNG)</figcaption></div> <div style="flex: 1 1 50%; max-width: 50%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/marigold/marigold_einstein_lcm_depth.png"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Predicted depth visualization (Spectral)</figcaption></div></div> <!> <p>Load the <code>prs-eth/marigold-normals-v1-1</code> checkpoint into <a href="/docs/diffusers/pr_14178/en/api/pipelines/marigold#diffusers.MarigoldNormalsPipeline">MarigoldNormalsPipeline</a>, put the image through the | |
| pipeline, and save the predictions:</p> <!> <p>The <a href="/docs/diffusers/pr_14178/en/api/pipelines/marigold#diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_normals">visualize_normals()</a> maps the three-dimensional | |
| prediction with pixel values in the range <code>[-1, 1]</code> into an RGB image. | |
| The visualization function supports flipping surface normals axes to make the visualization compatible with other | |
| choices of the frame of reference. | |
| Conceptually, each pixel is painted according to the surface normal vector in the frame of reference, where <code>X</code> axis | |
| points right, <code>Y</code> axis points up, and <code>Z</code> axis points at the viewer. | |
| Below is the visualized prediction:</p> <div class="flex gap-4" style="justify-content: center; width: 100%;"><div style="flex: 1 1 50%; max-width: 50%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/marigold/marigold_einstein_lcm_normals.png"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Predicted surface normals visualization</figcaption></div></div> <p>In this example, the nose tip almost certainly has a point on the surface, in which the surface normal vector points | |
| straight at the viewer, meaning that its coordinates are <code>[0, 0, 1]</code>. | |
| This vector maps to the RGB <code>[128, 128, 255]</code>, which corresponds to the violet-blue color. | |
| Similarly, a surface normal on the cheek in the right part of the image has a large <code>X</code> component, which increases the | |
| red hue. | |
| Points on the shoulders pointing up with a large <code>Y</code> promote green color.</p> <!> <p>Marigold provides two models for Intrinsic Image Decomposition (IID): “Appearance” and “Lighting”. | |
| Each model produces Albedo maps, derived from InteriorVerse and Hypersim annotations, respectively.</p> <ul><li>The “Appearance” model also estimates Material properties: Roughness and Metallicity.</li> <li>The “Lighting” model generates Diffuse Shading and Non-diffuse Residual.</li></ul> <p>Here is the sample code saving predictions made by the “Appearance” model:</p> <!> <p>Another example demonstrating the predictions made by the “Lighting” model:</p> <!> <p>Both models share the same pipeline while supporting different decomposition types. | |
| The exact decomposition parameterization (e.g., sRGB vs. linear space) is stored in the <code>pipe.target_properties</code> dictionary, which is passed into the <a href="/docs/diffusers/pr_14178/en/api/pipelines/marigold#diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_intrinsics">visualize_intrinsics()</a> function.</p> <p>Below are some examples showcasing the predicted decomposition outputs. | |
| All modalities can be inspected in the <a href="https://huggingface.co/spaces/prs-eth/marigold-iid" rel="nofollow">Intrinsic Image Decomposition</a> Space.</p> <div class="flex gap-4"><div style="flex: 1 1 50%; max-width: 50%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/8c7986eaaab5eb9604eb88336311f46a7b0ff5ab/marigold/marigold_einstein_albedo.png"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Predicted albedo ("Appearance" model)</figcaption></div> <div style="flex: 1 1 50%; max-width: 50%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/8c7986eaaab5eb9604eb88336311f46a7b0ff5ab/marigold/marigold_einstein_diffuse.png"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Predicted diffuse shading ("Lighting" model)</figcaption></div></div> <!> <p>The above quick start snippets are already optimized for quality and speed, loading the checkpoint, utilizing the <code>fp16</code> variant of weights and computation, and performing the default number (4) of denoising diffusion steps. | |
| The first step to accelerate inference, at the expense of prediction quality, is to reduce the denoising diffusion | |
| steps to the minimum:</p> <!> <p>With this change, the <code>pipe</code> call completes in 280ms on RTX 3090 GPU. | |
| Internally, the input image is first encoded using the Stable Diffusion VAE encoder, followed by a single denoising | |
| step performed by the U-Net. | |
| Finally, the prediction latent is decoded with the VAE decoder into pixel space. | |
| In this setup, two out of three module calls are dedicated to converting between the pixel and latent spaces of the LDM. | |
| Since Marigold’s latent space is compatible with Stable Diffusion 2.0, inference can be accelerated by more than 3x, | |
| reducing the call time to 85ms on an RTX 3090, by using a <a href="../models/autoencoder_tiny">lightweight replacement of the SD VAE</a>. | |
| Note that using a lightweight VAE may slightly reduce the visual quality of the predictions.</p> <!> <p>So far, we have optimized the number of diffusion steps and model components. Self-attention operations account for a | |
| significant portion of computations. | |
| Speeding them up can be achieved by using a more efficient attention processor:</p> <!> <p>Finally, as suggested in <a href="../../optimization/fp16#torchcompile">Optimizations</a>, enabling <code>torch.compile</code> can further enhance performance depending on | |
| the target hardware. | |
| However, compilation incurs a significant overhead during the first pipeline invocation, making it beneficial only when | |
| the same pipeline instance is called repeatedly, such as within a loop.</p> <!> <!> <p>Marigold pipelines have a built-in ensembling mechanism combining multiple predictions from different random latents. | |
| This is a brute-force way of improving the precision of predictions, capitalizing on the generative nature of diffusion. | |
| The ensembling path is activated automatically when the <code>ensemble_size</code> argument is set greater or equal than <code>3</code>. | |
| When aiming for maximum precision, it makes sense to adjust <code>num_inference_steps</code> simultaneously with <code>ensemble_size</code>. | |
| The recommended values vary across checkpoints but primarily depend on the scheduler type. | |
| The effect of ensembling is particularly well-seen with surface normals:</p> <!> <div class="flex gap-4"><div style="flex: 1 1 50%; max-width: 50%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/marigold/marigold_einstein_lcm_normals.png"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Surface normals, no ensembling</figcaption></div> <div style="flex: 1 1 50%; max-width: 50%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/marigold/marigold_einstein_normals.png"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Surface normals, with ensembling</figcaption></div></div> <p>As can be seen, all areas with fine-grained structurers, such as hair, got more conservative and on average more | |
| correct predictions. | |
| Such a result is more suitable for precision-sensitive downstream tasks, such as 3D reconstruction.</p> <!> <p>Due to Marigold’s generative nature, each prediction is unique and defined by the random noise sampled for the latent | |
| initialization. | |
| This becomes an obvious drawback compared to traditional end-to-end dense regression networks, as exemplified in the | |
| following videos:</p> <div class="flex gap-4"><div style="flex: 1 1 50%; max-width: 50%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/marigold/marigold_obama.gif"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Input video</figcaption></div> <div style="flex: 1 1 50%; max-width: 50%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/marigold/marigold_obama_depth_independent.gif"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Marigold Depth applied to input video frames independently</figcaption></div></div> <p>To address this issue, it is possible to pass <code>latents</code> argument to the pipelines, which defines the starting point of | |
| diffusion. | |
| Empirically, we found that a convex combination of the very same starting point noise latent and the latent | |
| corresponding to the previous frame prediction give sufficiently smooth results, as implemented in the snippet below:</p> <!> <p>Here, the diffusion process starts from the given computed latent. | |
| The pipeline sets <code>output_latent=True</code> to access <code>out.latent</code> and computes its contribution to the next frame’s latent | |
| initialization. | |
| The result is much more stable now:</p> <div class="flex gap-4"><div style="flex: 1 1 50%; max-width: 50%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/marigold/marigold_obama_depth_independent.gif"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Marigold Depth applied to input video frames independently</figcaption></div> <div style="flex: 1 1 50%; max-width: 50%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/marigold/marigold_obama_depth_consistent.gif"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Marigold Depth with forced latents initialization</figcaption></div></div> <!> <p>A very common application for depth prediction with diffusion models comes in conjunction with ControlNet. | |
| Depth crispness plays a crucial role in obtaining high-quality results from ControlNet. | |
| As seen in comparisons with other methods above, Marigold excels at that task. | |
| The snippet below demonstrates how to load an image, compute depth, and pass it into ControlNet in a compatible format:</p> <!> <div class="flex gap-4"><div style="flex: 1 1 33%; max-width: 33%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_depth_source.png"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Input image</figcaption></div> <div style="flex: 1 1 33%; max-width: 33%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/marigold/motorcycle_controlnet_depth.png"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Depth in the format compatible with ControlNet</figcaption></div> <div style="flex: 1 1 33%; max-width: 33%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/marigold/motorcycle_controlnet_out.png"/> <figcaption class="mt-1 text-center text-sm text-gray-500">ControlNet generation, conditioned on depth and prompt: "high quality photo of a sports bike, city"</figcaption></div></div> <!> <p>To evaluate Marigold quantitatively in standard leaderboards and benchmarks (such as NYU, KITTI, and other datasets), | |
| follow the evaluation protocol outlined in the paper: load the full precision fp32 model and use appropriate values | |
| for <code>num_inference_steps</code> and <code>ensemble_size</code>. | |
| Optionally seed randomness to ensure reproducibility. | |
| Maximizing <code>batch_size</code> will deliver maximum device utilization.</p> <!> <!> <p>The ensembling mechanism built into Marigold pipelines combines multiple predictions obtained from different random | |
| latents. | |
| As a side effect, it can be used to quantify epistemic (model) uncertainty; simply specify <code>ensemble_size</code> greater | |
| or equal than 3 and set <code>output_uncertainty=True</code>. | |
| The resulting uncertainty will be available in the <code>uncertainty</code> field of the output. | |
| It can be visualized as follows:</p> <!> <div class="flex gap-4"><div style="flex: 1 1 33%; max-width: 33%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/marigold/marigold_einstein_depth_uncertainty.png"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Depth uncertainty</figcaption></div> <div style="flex: 1 1 33%; max-width: 33%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/marigold/marigold_einstein_normals_uncertainty.png"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Surface normals uncertainty</figcaption></div> <div style="flex: 1 1 33%; max-width: 33%;"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/4f83035d84a24e5ec44fdda129b1d51eba12ce04/marigold/marigold_einstein_albedo_uncertainty.png"/> <figcaption class="mt-1 text-center text-sm text-gray-500">Albedo uncertainty</figcaption></div></div> <p>The interpretation of uncertainty is easy: higher values (white) correspond to pixels, where the model struggles to | |
| make consistent predictions.</p> <ul><li>The depth model exhibits the most uncertainty around discontinuities, where object depth changes abruptly.</li> <li>The surface normals model is least confident in fine-grained structures like hair and in dark regions such as the | |
| collar area.</li> <li>Albedo uncertainty is represented as an RGB image, as it captures uncertainty independently for each color channel, | |
| unlike depth and surface normals. It is also higher in shaded regions and at discontinuities.</li></ul> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Pipeline for monocular depth estimation using the Marigold method: <a href="https://marigoldmonodepth.github.io" rel="nofollow">https://marigoldmonodepth.github.io</a>.</p> <p>This model inherits from <a href="/docs/diffusers/pr_14178/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a>. Check the superclass documentation for the generic methods the | |
| library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Function invoked when calling the pipeline.</p> <!></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Output class for Marigold monocular depth prediction pipeline.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Visualizes depth maps, such as predictions of the <code>MarigoldDepthPipeline</code>.</p> <p>Returns: <code>list[PIL.Image.Image]</code> with depth maps visualization.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Pipeline for monocular normals estimation using the Marigold method: <a href="https://marigoldmonodepth.github.io" rel="nofollow">https://marigoldmonodepth.github.io</a>.</p> <p>This model inherits from <a href="/docs/diffusers/pr_14178/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a>. Check the superclass documentation for the generic methods the | |
| library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Function invoked when calling the pipeline.</p> <!></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Output class for Marigold monocular normals prediction pipeline.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Visualizes surface normals, such as predictions of the <code>MarigoldNormalsPipeline</code>.</p> <p>Returns: <code>list[PIL.Image.Image]</code> with surface normals visualization.</p></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Pipeline for Intrinsic Image Decomposition (IID) using the Marigold method: <a href="https://marigoldcomputervision.github.io" rel="nofollow">https://marigoldcomputervision.github.io</a>.</p> <p>This model inherits from <a href="/docs/diffusers/pr_14178/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a>. Check the superclass documentation for the generic methods the | |
| library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Function invoked when calling the pipeline.</p> <!> <!></div></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Output class for Marigold Intrinsic Image Decomposition pipeline.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Visualizes intrinsic image decomposition, such as predictions of the <code>MarigoldIntrinsicsPipeline</code>.</p> <p>Returns: <code>list[dict[str, PIL.Image.Image]]</code> with intrinsic image decomposition visualization.</p></div> <!> <p></p>`,1);function Ae(ge,fe){Re(fe,!1),ze(()=>{new URLSearchParams(window.location.search).get("fw")}),Ue();var j=qe();xe("95b4y5",a=>{var d=Ve();Be(d,"content",ke),p(a,d)});var I=e(m(j),2);Ge(I,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var U=e(I,2);n(U,{title:"Marigold Computer Vision",local:"marigold-computer-vision",headingTag:"h1"});var x=e(U,10);n(x,{title:"Available Pipelines",local:"available-pipelines",headingTag:"h2"});var G=e(x,6);n(G,{title:"Available Checkpoints",local:"available-checkpoints",headingTag:"h2"});var h=e(G,4),W=e(o(h)),N=e(o(W),3),B=e(o(N),2),ye=e(o(B));We(ye,()=>'<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi></mrow><annotation encoding="application/x-tex">I</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.0785em;">I</span></span></span></span>'),r(),i(B),i(N),i(W),i(h);var R=e(h,10);n(R,{title:"Depth Prediction",local:"depth-prediction",headingTag:"h2"});var z=e(R,4);t(z,{code:"aW1wb3J0JTIwZGlmZnVzZXJzJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlJTIwJTNEJTIwZGlmZnVzZXJzLk1hcmlnb2xkRGVwdGhQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIycHJzLWV0aCUyRm1hcmlnb2xkLWRlcHRoLXYxLTElMjIlMkMlMjB2YXJpYW50JTNEJTIyZnAxNiUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFpbWFnZSUyMCUzRCUyMGRpZmZ1c2Vycy51dGlscy5sb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGbWFyaWdvbGRtb25vZGVwdGguZ2l0aHViLmlvJTJGaW1hZ2VzJTJGZWluc3RlaW4uanBnJTIyKSUwQSUwQWRlcHRoJTIwJTNEJTIwcGlwZShpbWFnZSklMEElMEF2aXMlMjAlM0QlMjBwaXBlLmltYWdlX3Byb2Nlc3Nvci52aXN1YWxpemVfZGVwdGgoZGVwdGgucHJlZGljdGlvbiklMEF2aXMlNUIwJTVELnNhdmUoJTIyZWluc3RlaW5fZGVwdGgucG5nJTIyKSUwQSUwQWRlcHRoXzE2Yml0JTIwJTNEJTIwcGlwZS5pbWFnZV9wcm9jZXNzb3IuZXhwb3J0X2RlcHRoX3RvXzE2Yml0X3BuZyhkZXB0aC5wcmVkaWN0aW9uKSUwQWRlcHRoXzE2Yml0JTVCMCU1RC5zYXZlKCUyMmVpbnN0ZWluX2RlcHRoXzE2Yml0LnBuZyUyMik=",highlighted:`<span class="hljs-keyword">import</span> diffusers | |
| <span class="hljs-keyword">import</span> torch | |
| pipe = diffusers.MarigoldDepthPipeline.from_pretrained( | |
| <span class="hljs-string">"prs-eth/marigold-depth-v1-1"</span>, variant=<span class="hljs-string">"fp16"</span>, torch_dtype=torch.float16 | |
| ).to(<span class="hljs-string">"cuda"</span>) | |
| image = diffusers.utils.load_image(<span class="hljs-string">"https://marigoldmonodepth.github.io/images/einstein.jpg"</span>) | |
| depth = pipe(image) | |
| vis = pipe.image_processor.visualize_depth(depth.prediction) | |
| vis[<span class="hljs-number">0</span>].save(<span class="hljs-string">"einstein_depth.png"</span>) | |
| depth_16bit = pipe.image_processor.export_depth_to_16bit_png(depth.prediction) | |
| depth_16bit[<span class="hljs-number">0</span>].save(<span class="hljs-string">"einstein_depth_16bit.png"</span>)`,lang:"python",wrap:!1});var X=e(z,6);n(X,{title:"Surface Normals Estimation",local:"surface-normals-estimation",headingTag:"h2"});var k=e(X,4);t(k,{code:"aW1wb3J0JTIwZGlmZnVzZXJzJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlJTIwJTNEJTIwZGlmZnVzZXJzLk1hcmlnb2xkTm9ybWFsc1BpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJwcnMtZXRoJTJGbWFyaWdvbGQtbm9ybWFscy12MS0xJTIyJTJDJTIwdmFyaWFudCUzRCUyMmZwMTYlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBaW1hZ2UlMjAlM0QlMjBkaWZmdXNlcnMudXRpbHMubG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRm1hcmlnb2xkbW9ub2RlcHRoLmdpdGh1Yi5pbyUyRmltYWdlcyUyRmVpbnN0ZWluLmpwZyUyMiklMEElMEFub3JtYWxzJTIwJTNEJTIwcGlwZShpbWFnZSklMEElMEF2aXMlMjAlM0QlMjBwaXBlLmltYWdlX3Byb2Nlc3Nvci52aXN1YWxpemVfbm9ybWFscyhub3JtYWxzLnByZWRpY3Rpb24pJTBBdmlzJTVCMCU1RC5zYXZlKCUyMmVpbnN0ZWluX25vcm1hbHMucG5nJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> diffusers | |
| <span class="hljs-keyword">import</span> torch | |
| pipe = diffusers.MarigoldNormalsPipeline.from_pretrained( | |
| <span class="hljs-string">"prs-eth/marigold-normals-v1-1"</span>, variant=<span class="hljs-string">"fp16"</span>, torch_dtype=torch.float16 | |
| ).to(<span class="hljs-string">"cuda"</span>) | |
| image = diffusers.utils.load_image(<span class="hljs-string">"https://marigoldmonodepth.github.io/images/einstein.jpg"</span>) | |
| normals = pipe(image) | |
| vis = pipe.image_processor.visualize_normals(normals.prediction) | |
| vis[<span class="hljs-number">0</span>].save(<span class="hljs-string">"einstein_normals.png"</span>)`,lang:"python",wrap:!1});var V=e(k,8);n(V,{title:"Intrinsic Image Decomposition",local:"intrinsic-image-decomposition",headingTag:"h2"});var q=e(V,8);t(q,{code:"aW1wb3J0JTIwZGlmZnVzZXJzJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlJTIwJTNEJTIwZGlmZnVzZXJzLk1hcmlnb2xkSW50cmluc2ljc1BpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJwcnMtZXRoJTJGbWFyaWdvbGQtaWlkLWFwcGVhcmFuY2UtdjEtMSUyMiUyQyUyMHZhcmlhbnQlM0QlMjJmcDE2JTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwZGlmZnVzZXJzLnV0aWxzLmxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZtYXJpZ29sZG1vbm9kZXB0aC5naXRodWIuaW8lMkZpbWFnZXMlMkZlaW5zdGVpbi5qcGclMjIpJTBBJTBBaW50cmluc2ljcyUyMCUzRCUyMHBpcGUoaW1hZ2UpJTBBJTBBdmlzJTIwJTNEJTIwcGlwZS5pbWFnZV9wcm9jZXNzb3IudmlzdWFsaXplX2ludHJpbnNpY3MoaW50cmluc2ljcy5wcmVkaWN0aW9uJTJDJTIwcGlwZS50YXJnZXRfcHJvcGVydGllcyklMEF2aXMlNUIwJTVEJTVCJTIyYWxiZWRvJTIyJTVELnNhdmUoJTIyZWluc3RlaW5fYWxiZWRvLnBuZyUyMiklMEF2aXMlNUIwJTVEJTVCJTIycm91Z2huZXNzJTIyJTVELnNhdmUoJTIyZWluc3RlaW5fcm91Z2huZXNzLnBuZyUyMiklMEF2aXMlNUIwJTVEJTVCJTIybWV0YWxsaWNpdHklMjIlNUQuc2F2ZSglMjJlaW5zdGVpbl9tZXRhbGxpY2l0eS5wbmclMjIp",highlighted:`<span class="hljs-keyword">import</span> diffusers | |
| <span class="hljs-keyword">import</span> torch | |
| pipe = diffusers.MarigoldIntrinsicsPipeline.from_pretrained( | |
| <span class="hljs-string">"prs-eth/marigold-iid-appearance-v1-1"</span>, variant=<span class="hljs-string">"fp16"</span>, torch_dtype=torch.float16 | |
| ).to(<span class="hljs-string">"cuda"</span>) | |
| image = diffusers.utils.load_image(<span class="hljs-string">"https://marigoldmonodepth.github.io/images/einstein.jpg"</span>) | |
| intrinsics = pipe(image) | |
| vis = pipe.image_processor.visualize_intrinsics(intrinsics.prediction, pipe.target_properties) | |
| vis[<span class="hljs-number">0</span>][<span class="hljs-string">"albedo"</span>].save(<span class="hljs-string">"einstein_albedo.png"</span>) | |
| vis[<span class="hljs-number">0</span>][<span class="hljs-string">"roughness"</span>].save(<span class="hljs-string">"einstein_roughness.png"</span>) | |
| vis[<span class="hljs-number">0</span>][<span class="hljs-string">"metallicity"</span>].save(<span class="hljs-string">"einstein_metallicity.png"</span>)`,lang:"python",wrap:!1});var E=e(q,4);t(E,{code:"aW1wb3J0JTIwZGlmZnVzZXJzJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlJTIwJTNEJTIwZGlmZnVzZXJzLk1hcmlnb2xkSW50cmluc2ljc1BpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJwcnMtZXRoJTJGbWFyaWdvbGQtaWlkLWxpZ2h0aW5nLXYxLTElMjIlMkMlMjB2YXJpYW50JTNEJTIyZnAxNiUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFpbWFnZSUyMCUzRCUyMGRpZmZ1c2Vycy51dGlscy5sb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGbWFyaWdvbGRtb25vZGVwdGguZ2l0aHViLmlvJTJGaW1hZ2VzJTJGZWluc3RlaW4uanBnJTIyKSUwQSUwQWludHJpbnNpY3MlMjAlM0QlMjBwaXBlKGltYWdlKSUwQSUwQXZpcyUyMCUzRCUyMHBpcGUuaW1hZ2VfcHJvY2Vzc29yLnZpc3VhbGl6ZV9pbnRyaW5zaWNzKGludHJpbnNpY3MucHJlZGljdGlvbiUyQyUyMHBpcGUudGFyZ2V0X3Byb3BlcnRpZXMpJTBBdmlzJTVCMCU1RCU1QiUyMmFsYmVkbyUyMiU1RC5zYXZlKCUyMmVpbnN0ZWluX2FsYmVkby5wbmclMjIpJTBBdmlzJTVCMCU1RCU1QiUyMnNoYWRpbmclMjIlNUQuc2F2ZSglMjJlaW5zdGVpbl9zaGFkaW5nLnBuZyUyMiklMEF2aXMlNUIwJTVEJTVCJTIycmVzaWR1YWwlMjIlNUQuc2F2ZSglMjJlaW5zdGVpbl9yZXNpZHVhbC5wbmclMjIp",highlighted:`<span class="hljs-keyword">import</span> diffusers | |
| <span class="hljs-keyword">import</span> torch | |
| pipe = diffusers.MarigoldIntrinsicsPipeline.from_pretrained( | |
| <span class="hljs-string">"prs-eth/marigold-iid-lighting-v1-1"</span>, variant=<span class="hljs-string">"fp16"</span>, torch_dtype=torch.float16 | |
| ).to(<span class="hljs-string">"cuda"</span>) | |
| image = diffusers.utils.load_image(<span class="hljs-string">"https://marigoldmonodepth.github.io/images/einstein.jpg"</span>) | |
| intrinsics = pipe(image) | |
| vis = pipe.image_processor.visualize_intrinsics(intrinsics.prediction, pipe.target_properties) | |
| vis[<span class="hljs-number">0</span>][<span class="hljs-string">"albedo"</span>].save(<span class="hljs-string">"einstein_albedo.png"</span>) | |
| vis[<span class="hljs-number">0</span>][<span class="hljs-string">"shading"</span>].save(<span class="hljs-string">"einstein_shading.png"</span>) | |
| vis[<span class="hljs-number">0</span>][<span class="hljs-string">"residual"</span>].save(<span class="hljs-string">"einstein_residual.png"</span>)`,lang:"python",wrap:!1});var C=e(E,8);n(C,{title:"Speeding up inference",local:"speeding-up-inference",headingTag:"h2"});var Y=e(C,4);t(Y,{code:"JTIwJTIwaW1wb3J0JTIwZGlmZnVzZXJzJTBBJTIwJTIwaW1wb3J0JTIwdG9yY2glMEElMEElMjAlMjBwaXBlJTIwJTNEJTIwZGlmZnVzZXJzLk1hcmlnb2xkRGVwdGhQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIycHJzLWV0aCUyRm1hcmlnb2xkLWRlcHRoLXYxLTElMjIlMkMlMjB2YXJpYW50JTNEJTIyZnAxNiUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSUyMCUyMCkudG8oJTIyY3VkYSUyMiklMEElMEElMjAlMjBpbWFnZSUyMCUzRCUyMGRpZmZ1c2Vycy51dGlscy5sb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGbWFyaWdvbGRtb25vZGVwdGguZ2l0aHViLmlvJTJGaW1hZ2VzJTJGZWluc3RlaW4uanBnJTIyKSUwQSUyMCUyMCUwQS0lMjBkZXB0aCUyMCUzRCUyMHBpcGUoaW1hZ2UpJTBBJTJCJTIwZGVwdGglMjAlM0QlMjBwaXBlKGltYWdlJTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDEp",highlighted:` import diffusers | |
| import torch | |
| pipe = diffusers.MarigoldDepthPipeline.from_pretrained( | |
| "prs-eth/marigold-depth-v1-1", variant="fp16", torch_dtype=torch.float16 | |
| ).to("cuda") | |
| image = diffusers.utils.load_image("https://marigoldmonodepth.github.io/images/einstein.jpg") | |
| <span class="hljs-deletion">- depth = pipe(image)</span> | |
| <span class="hljs-addition">+ depth = pipe(image, num_inference_steps=1)</span>`,lang:"diff",wrap:!1});var S=e(Y,4);t(S,{code:"JTIwJTIwaW1wb3J0JTIwZGlmZnVzZXJzJTBBJTIwJTIwaW1wb3J0JTIwdG9yY2glMEElMEElMjAlMjBwaXBlJTIwJTNEJTIwZGlmZnVzZXJzLk1hcmlnb2xkRGVwdGhQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIycHJzLWV0aCUyRm1hcmlnb2xkLWRlcHRoLXYxLTElMjIlMkMlMjB2YXJpYW50JTNEJTIyZnAxNiUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSUyMCUyMCkudG8oJTIyY3VkYSUyMiklMEElMEElMkIlMjBwaXBlLnZhZSUyMCUzRCUyMGRpZmZ1c2Vycy5BdXRvZW5jb2RlclRpbnkuZnJvbV9wcmV0cmFpbmVkKCUwQSUyQiUyMCUyMCUyMCUyMCUyMCUyMm1hZGVieW9sbGluJTJGdGFlc2QlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEElMkIlMjApLmN1ZGEoKSUwQSUwQSUyMCUyMGltYWdlJTIwJTNEJTIwZGlmZnVzZXJzLnV0aWxzLmxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZtYXJpZ29sZG1vbm9kZXB0aC5naXRodWIuaW8lMkZpbWFnZXMlMkZlaW5zdGVpbi5qcGclMjIpJTBBJTBBJTIwJTIwZGVwdGglMjAlM0QlMjBwaXBlKGltYWdlJTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDEp",highlighted:` import diffusers | |
| import torch | |
| pipe = diffusers.MarigoldDepthPipeline.from_pretrained( | |
| "prs-eth/marigold-depth-v1-1", variant="fp16", torch_dtype=torch.float16 | |
| ).to("cuda") | |
| <span class="hljs-addition">+ pipe.vae = diffusers.AutoencoderTiny.from_pretrained(</span> | |
| <span class="hljs-addition">+ "madebyollin/taesd", torch_dtype=torch.float16</span> | |
| <span class="hljs-addition">+ ).cuda()</span> | |
| image = diffusers.utils.load_image("https://marigoldmonodepth.github.io/images/einstein.jpg") | |
| depth = pipe(image, num_inference_steps=1)`,lang:"diff",wrap:!1});var A=e(S,4);t(A,{code:"JTIwJTIwaW1wb3J0JTIwZGlmZnVzZXJzJTBBJTIwJTIwaW1wb3J0JTIwdG9yY2glMEElMkIlMjBmcm9tJTIwZGlmZnVzZXJzLm1vZGVscy5hdHRlbnRpb25fcHJvY2Vzc29yJTIwaW1wb3J0JTIwQXR0blByb2Nlc3NvcjJfMCUwQSUwQSUyMCUyMHBpcGUlMjAlM0QlMjBkaWZmdXNlcnMuTWFyaWdvbGREZXB0aFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjJwcnMtZXRoJTJGbWFyaWdvbGQtZGVwdGgtdjEtMSUyMiUyQyUyMHZhcmlhbnQlM0QlMjJmcDE2JTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBJTIwJTIwKS50byglMjJjdWRhJTIyKSUwQSUwQSUyQiUyMHBpcGUudmFlLnNldF9hdHRuX3Byb2Nlc3NvcihBdHRuUHJvY2Vzc29yMl8wKCkpJTIwJTBBJTJCJTIwcGlwZS51bmV0LnNldF9hdHRuX3Byb2Nlc3NvcihBdHRuUHJvY2Vzc29yMl8wKCkpJTBBJTBBJTIwJTIwaW1hZ2UlMjAlM0QlMjBkaWZmdXNlcnMudXRpbHMubG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRm1hcmlnb2xkbW9ub2RlcHRoLmdpdGh1Yi5pbyUyRmltYWdlcyUyRmVpbnN0ZWluLmpwZyUyMiklMEElMEElMjAlMjBkZXB0aCUyMCUzRCUyMHBpcGUoaW1hZ2UlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMSk=",highlighted:` import diffusers | |
| import torch | |
| <span class="hljs-addition">+ from diffusers.models.attention_processor import AttnProcessor2_0</span> | |
| pipe = diffusers.MarigoldDepthPipeline.from_pretrained( | |
| "prs-eth/marigold-depth-v1-1", variant="fp16", torch_dtype=torch.float16 | |
| ).to("cuda") | |
| <span class="hljs-addition">+ pipe.vae.set_attn_processor(AttnProcessor2_0()) </span> | |
| <span class="hljs-addition">+ pipe.unet.set_attn_processor(AttnProcessor2_0())</span> | |
| image = diffusers.utils.load_image("https://marigoldmonodepth.github.io/images/einstein.jpg") | |
| depth = pipe(image, num_inference_steps=1)`,lang:"diff",wrap:!1});var F=e(A,4);t(F,{code:"JTIwJTIwaW1wb3J0JTIwZGlmZnVzZXJzJTBBJTIwJTIwaW1wb3J0JTIwdG9yY2glMEElMjAlMjBmcm9tJTIwZGlmZnVzZXJzLm1vZGVscy5hdHRlbnRpb25fcHJvY2Vzc29yJTIwaW1wb3J0JTIwQXR0blByb2Nlc3NvcjJfMCUwQSUwQSUyMCUyMHBpcGUlMjAlM0QlMjBkaWZmdXNlcnMuTWFyaWdvbGREZXB0aFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjJwcnMtZXRoJTJGbWFyaWdvbGQtZGVwdGgtdjEtMSUyMiUyQyUyMHZhcmlhbnQlM0QlMjJmcDE2JTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBJTIwJTIwKS50byglMjJjdWRhJTIyKSUwQSUwQSUyMCUyMHBpcGUudmFlLnNldF9hdHRuX3Byb2Nlc3NvcihBdHRuUHJvY2Vzc29yMl8wKCkpJTIwJTBBJTIwJTIwcGlwZS51bmV0LnNldF9hdHRuX3Byb2Nlc3NvcihBdHRuUHJvY2Vzc29yMl8wKCkpJTBBJTBBJTJCJTIwcGlwZS52YWUlMjAlM0QlMjB0b3JjaC5jb21waWxlKHBpcGUudmFlJTJDJTIwbW9kZSUzRCUyMnJlZHVjZS1vdmVyaGVhZCUyMiUyQyUyMGZ1bGxncmFwaCUzRFRydWUpJTBBJTJCJTIwcGlwZS51bmV0JTIwJTNEJTIwdG9yY2guY29tcGlsZShwaXBlLnVuZXQlMkMlMjBtb2RlJTNEJTIycmVkdWNlLW92ZXJoZWFkJTIyJTJDJTIwZnVsbGdyYXBoJTNEVHJ1ZSklMEElMEElMjAlMjBpbWFnZSUyMCUzRCUyMGRpZmZ1c2Vycy51dGlscy5sb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGbWFyaWdvbGRtb25vZGVwdGguZ2l0aHViLmlvJTJGaW1hZ2VzJTJGZWluc3RlaW4uanBnJTIyKSUwQSUwQSUyMCUyMGRlcHRoJTIwJTNEJTIwcGlwZShpbWFnZSUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QxKQ==",highlighted:` import diffusers | |
| import torch | |
| from diffusers.models.attention_processor import AttnProcessor2_0 | |
| pipe = diffusers.MarigoldDepthPipeline.from_pretrained( | |
| "prs-eth/marigold-depth-v1-1", variant="fp16", torch_dtype=torch.float16 | |
| ).to("cuda") | |
| pipe.vae.set_attn_processor(AttnProcessor2_0()) | |
| pipe.unet.set_attn_processor(AttnProcessor2_0()) | |
| <span class="hljs-addition">+ pipe.vae = torch.compile(pipe.vae, mode="reduce-overhead", fullgraph=True)</span> | |
| <span class="hljs-addition">+ pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)</span> | |
| image = diffusers.utils.load_image("https://marigoldmonodepth.github.io/images/einstein.jpg") | |
| depth = pipe(image, num_inference_steps=1)`,lang:"diff",wrap:!1});var D=e(F,2);n(D,{title:"Maximizing Precision and Ensembling",local:"maximizing-precision-and-ensembling",headingTag:"h2"});var Q=e(D,4);t(Q,{code:"JTIwJTIwaW1wb3J0JTIwZGlmZnVzZXJzJTBBJTBBJTIwJTIwcGlwZSUyMCUzRCUyMGRpZmZ1c2Vycy5NYXJpZ29sZE5vcm1hbHNQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIycHJzLWV0aCUyRm1hcmlnb2xkLW5vcm1hbHMtdjEtMSUyMikudG8oJTIyY3VkYSUyMiklMEElMEElMjAlMjBpbWFnZSUyMCUzRCUyMGRpZmZ1c2Vycy51dGlscy5sb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGbWFyaWdvbGRtb25vZGVwdGguZ2l0aHViLmlvJTJGaW1hZ2VzJTJGZWluc3RlaW4uanBnJTIyKSUwQSUwQS0lMjBkZXB0aCUyMCUzRCUyMHBpcGUoaW1hZ2UpJTBBJTJCJTIwZGVwdGglMjAlM0QlMjBwaXBlKGltYWdlJTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDEwJTJDJTIwZW5zZW1ibGVfc2l6ZSUzRDUpJTBBJTBBJTIwJTIwdmlzJTIwJTNEJTIwcGlwZS5pbWFnZV9wcm9jZXNzb3IudmlzdWFsaXplX25vcm1hbHMoZGVwdGgucHJlZGljdGlvbiklMEElMjAlMjB2aXMlNUIwJTVELnNhdmUoJTIyZWluc3RlaW5fbm9ybWFscy5wbmclMjIp",highlighted:` import diffusers | |
| pipe = diffusers.MarigoldNormalsPipeline.from_pretrained("prs-eth/marigold-normals-v1-1").to("cuda") | |
| image = diffusers.utils.load_image("https://marigoldmonodepth.github.io/images/einstein.jpg") | |
| <span class="hljs-deletion">- depth = pipe(image)</span> | |
| <span class="hljs-addition">+ depth = pipe(image, num_inference_steps=10, ensemble_size=5)</span> | |
| vis = pipe.image_processor.visualize_normals(depth.prediction) | |
| vis[0].save("einstein_normals.png")`,lang:"diff",wrap:!1});var P=e(Q,6);n(P,{title:"Frame-by-frame Video Processing with Temporal Consistency",local:"frame-by-frame-video-processing-with-temporal-consistency",headingTag:"h2"});var H=e(P,8);t(H,{code:"aW1wb3J0JTIwaW1hZ2VpbyUwQWltcG9ydCUyMGRpZmZ1c2VycyUwQWltcG9ydCUyMHRvcmNoJTBBZnJvbSUyMGRpZmZ1c2Vycy5tb2RlbHMuYXR0ZW50aW9uX3Byb2Nlc3NvciUyMGltcG9ydCUyMEF0dG5Qcm9jZXNzb3IyXzAlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFmcm9tJTIwdHFkbSUyMGltcG9ydCUyMHRxZG0lMEElMEFkZXZpY2UlMjAlM0QlMjAlMjJjdWRhJTIyJTBBcGF0aF9pbiUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZzcGFjZXMlMkZwcnMtZXRoJTJGbWFyaWdvbGQtbGNtJTJGcmVzb2x2ZSUyRmM3YWRiNTQyNzk0N2QyNjgwOTQ0Zjg5OGNkOTFkMzg2YmYwZDQ5MjQlMkZmaWxlcyUyRnZpZGVvJTJGb2JhbWEubXA0JTIyJTBBcGF0aF9vdXQlMjAlM0QlMjAlMjJvYmFtYV9kZXB0aC5naWYlMjIlMEElMEFwaXBlJTIwJTNEJTIwZGlmZnVzZXJzLk1hcmlnb2xkRGVwdGhQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIycHJzLWV0aCUyRm1hcmlnb2xkLWRlcHRoLXYxLTElMjIlMkMlMjB2YXJpYW50JTNEJTIyZnAxNiUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSkudG8oZGV2aWNlKSUwQXBpcGUudmFlJTIwJTNEJTIwZGlmZnVzZXJzLkF1dG9lbmNvZGVyVGlueS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIybWFkZWJ5b2xsaW4lMkZ0YWVzZCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSkudG8oZGV2aWNlKSUwQXBpcGUudW5ldC5zZXRfYXR0bl9wcm9jZXNzb3IoQXR0blByb2Nlc3NvcjJfMCgpKSUwQXBpcGUudmFlJTIwJTNEJTIwdG9yY2guY29tcGlsZShwaXBlLnZhZSUyQyUyMG1vZGUlM0QlMjJyZWR1Y2Utb3ZlcmhlYWQlMjIlMkMlMjBmdWxsZ3JhcGglM0RUcnVlKSUwQXBpcGUudW5ldCUyMCUzRCUyMHRvcmNoLmNvbXBpbGUocGlwZS51bmV0JTJDJTIwbW9kZSUzRCUyMnJlZHVjZS1vdmVyaGVhZCUyMiUyQyUyMGZ1bGxncmFwaCUzRFRydWUpJTBBcGlwZS5zZXRfcHJvZ3Jlc3NfYmFyX2NvbmZpZyhkaXNhYmxlJTNEVHJ1ZSklMEElMEF3aXRoJTIwaW1hZ2Vpby5nZXRfcmVhZGVyKHBhdGhfaW4pJTIwYXMlMjByZWFkZXIlM0ElMEElMjAlMjAlMjAlMjBzaXplJTIwJTNEJTIwcmVhZGVyLmdldF9tZXRhX2RhdGEoKSU1QidzaXplJyU1RCUwQSUyMCUyMCUyMCUyMGxhc3RfZnJhbWVfbGF0ZW50JTIwJTNEJTIwTm9uZSUwQSUyMCUyMCUyMCUyMGxhdGVudF9jb21tb24lMjAlM0QlMjB0b3JjaC5yYW5kbiglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAoMSUyQyUyMDQlMkMlMjA3NjglMjAqJTIwc2l6ZSU1QjElNUQlMjAlMkYlMkYlMjAoOCUyMColMjBtYXgoc2l6ZSkpJTJDJTIwNzY4JTIwKiUyMHNpemUlNUIwJTVEJTIwJTJGJTJGJTIwKDglMjAqJTIwbWF4KHNpemUpKSklMEElMjAlMjAlMjAlMjApLnRvKGRldmljZSUzRGRldmljZSUyQyUyMGR0eXBlJTNEdG9yY2guZmxvYXQxNiklMEElMEElMjAlMjAlMjAlMjBvdXQlMjAlM0QlMjAlNUIlNUQlMEElMjAlMjAlMjAlMjBmb3IlMjBmcmFtZV9pZCUyQyUyMGZyYW1lJTIwaW4lMjB0cWRtKGVudW1lcmF0ZShyZWFkZXIpJTJDJTIwZGVzYyUzRCUyMlByb2Nlc3NpbmclMjBWaWRlbyUyMiklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmcmFtZSUyMCUzRCUyMEltYWdlLmZyb21hcnJheShmcmFtZSklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsYXRlbnRzJTIwJTNEJTIwbGF0ZW50X2NvbW1vbiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGlmJTIwbGFzdF9mcmFtZV9sYXRlbnQlMjBpcyUyMG5vdCUyME5vbmUlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsYXRlbnRzJTIwJTNEJTIwMC45JTIwKiUyMGxhdGVudHMlMjAlMkIlMjAwLjElMjAqJTIwbGFzdF9mcmFtZV9sYXRlbnQlMEElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBkZXB0aCUyMCUzRCUyMHBpcGUoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZnJhbWUlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG1hdGNoX2lucHV0X3Jlc29sdXRpb24lM0RGYWxzZSUyQyUyMCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxhdGVudHMlM0RsYXRlbnRzJTJDJTIwJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwb3V0cHV0X2xhdGVudCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjApJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbGFzdF9mcmFtZV9sYXRlbnQlMjAlM0QlMjBkZXB0aC5sYXRlbnQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXQuYXBwZW5kKHBpcGUuaW1hZ2VfcHJvY2Vzc29yLnZpc3VhbGl6ZV9kZXB0aChkZXB0aC5wcmVkaWN0aW9uKSU1QjAlNUQpJTBBJTBBJTIwJTIwJTIwJTIwZGlmZnVzZXJzLnV0aWxzLmV4cG9ydF90b19naWYob3V0JTJDJTIwcGF0aF9vdXQlMkMlMjBmcHMlM0RyZWFkZXIuZ2V0X21ldGFfZGF0YSgpJTVCJ2ZwcyclNUQp",highlighted:`<span class="hljs-keyword">import</span> imageio | |
| <span class="hljs-keyword">import</span> diffusers | |
| <span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> diffusers.models.attention_processor <span class="hljs-keyword">import</span> AttnProcessor2_0 | |
| <span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image | |
| <span class="hljs-keyword">from</span> tqdm <span class="hljs-keyword">import</span> tqdm | |
| device = <span class="hljs-string">"cuda"</span> | |
| path_in = <span class="hljs-string">"https://huggingface.co/spaces/prs-eth/marigold-lcm/resolve/c7adb5427947d2680944f898cd91d386bf0d4924/files/video/obama.mp4"</span> | |
| path_out = <span class="hljs-string">"obama_depth.gif"</span> | |
| pipe = diffusers.MarigoldDepthPipeline.from_pretrained( | |
| <span class="hljs-string">"prs-eth/marigold-depth-v1-1"</span>, variant=<span class="hljs-string">"fp16"</span>, torch_dtype=torch.float16 | |
| ).to(device) | |
| pipe.vae = diffusers.AutoencoderTiny.from_pretrained( | |
| <span class="hljs-string">"madebyollin/taesd"</span>, torch_dtype=torch.float16 | |
| ).to(device) | |
| pipe.unet.set_attn_processor(AttnProcessor2_0()) | |
| pipe.vae = torch.<span class="hljs-built_in">compile</span>(pipe.vae, mode=<span class="hljs-string">"reduce-overhead"</span>, fullgraph=<span class="hljs-literal">True</span>) | |
| pipe.unet = torch.<span class="hljs-built_in">compile</span>(pipe.unet, mode=<span class="hljs-string">"reduce-overhead"</span>, fullgraph=<span class="hljs-literal">True</span>) | |
| pipe.set_progress_bar_config(disable=<span class="hljs-literal">True</span>) | |
| <span class="hljs-keyword">with</span> imageio.get_reader(path_in) <span class="hljs-keyword">as</span> reader: | |
| size = reader.get_meta_data()[<span class="hljs-string">'size'</span>] | |
| last_frame_latent = <span class="hljs-literal">None</span> | |
| latent_common = torch.randn( | |
| (<span class="hljs-number">1</span>, <span class="hljs-number">4</span>, <span class="hljs-number">768</span> * size[<span class="hljs-number">1</span>] // (<span class="hljs-number">8</span> * <span class="hljs-built_in">max</span>(size)), <span class="hljs-number">768</span> * size[<span class="hljs-number">0</span>] // (<span class="hljs-number">8</span> * <span class="hljs-built_in">max</span>(size))) | |
| ).to(device=device, dtype=torch.float16) | |
| out = [] | |
| <span class="hljs-keyword">for</span> frame_id, frame <span class="hljs-keyword">in</span> tqdm(<span class="hljs-built_in">enumerate</span>(reader), desc=<span class="hljs-string">"Processing Video"</span>): | |
| frame = Image.fromarray(frame) | |
| latents = latent_common | |
| <span class="hljs-keyword">if</span> last_frame_latent <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">None</span>: | |
| latents = <span class="hljs-number">0.9</span> * latents + <span class="hljs-number">0.1</span> * last_frame_latent | |
| depth = pipe( | |
| frame, | |
| num_inference_steps=<span class="hljs-number">1</span>, | |
| match_input_resolution=<span class="hljs-literal">False</span>, | |
| latents=latents, | |
| output_latent=<span class="hljs-literal">True</span>, | |
| ) | |
| last_frame_latent = depth.latent | |
| out.append(pipe.image_processor.visualize_depth(depth.prediction)[<span class="hljs-number">0</span>]) | |
| diffusers.utils.export_to_gif(out, path_out, fps=reader.get_meta_data()[<span class="hljs-string">'fps'</span>])`,lang:"python",wrap:!1});var L=e(H,6);n(L,{title:"Marigold for ControlNet",local:"marigold-for-controlnet",headingTag:"h2"});var K=e(L,4);t(K,{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjBkaWZmdXNlcnMlMEElMEFkZXZpY2UlMjAlM0QlMjAlMjJjdWRhJTIyJTBBZ2VuZXJhdG9yJTIwJTNEJTIwdG9yY2guR2VuZXJhdG9yKGRldmljZSUzRGRldmljZSkubWFudWFsX3NlZWQoMjAyNCklMEFpbWFnZSUyMCUzRCUyMGRpZmZ1c2Vycy51dGlscy5sb2FkX2ltYWdlKCUwQSUyMCUyMCUyMCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRmRpZmZ1c2VycyUyRmNvbnRyb2xuZXRfZGVwdGhfc291cmNlLnBuZyUyMiUwQSklMEElMEFwaXBlJTIwJTNEJTIwZGlmZnVzZXJzLk1hcmlnb2xkRGVwdGhQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIycHJzLWV0aCUyRm1hcmlnb2xkLWRlcHRoLXYxLTElMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB2YXJpYW50JTNEJTIyZnAxNiUyMiUwQSkudG8oZGV2aWNlKSUwQSUwQWRlcHRoX2ltYWdlJTIwJTNEJTIwcGlwZShpbWFnZSUyQyUyMGdlbmVyYXRvciUzRGdlbmVyYXRvcikucHJlZGljdGlvbiUwQWRlcHRoX2ltYWdlJTIwJTNEJTIwcGlwZS5pbWFnZV9wcm9jZXNzb3IudmlzdWFsaXplX2RlcHRoKGRlcHRoX2ltYWdlJTJDJTIwY29sb3JfbWFwJTNEJTIyYmluYXJ5JTIyKSUwQWRlcHRoX2ltYWdlJTVCMCU1RC5zYXZlKCUyMm1vdG9yY3ljbGVfY29udHJvbG5ldF9kZXB0aC5wbmclMjIpJTBBJTBBY29udHJvbG5ldCUyMCUzRCUyMGRpZmZ1c2Vycy5Db250cm9sTmV0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmRpZmZ1c2VycyUyRmNvbnRyb2xuZXQtZGVwdGgtc2R4bC0xLjAlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB2YXJpYW50JTNEJTIyZnAxNiUyMiUwQSkudG8oZGV2aWNlKSUwQXBpcGUlMjAlM0QlMjBkaWZmdXNlcnMuU3RhYmxlRGlmZnVzaW9uWExDb250cm9sTmV0UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMlNHMTYxMjIyJTJGUmVhbFZpc1hMX1Y0LjAlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB2YXJpYW50JTNEJTIyZnAxNiUyMiUyQyUyMGNvbnRyb2xuZXQlM0Rjb250cm9sbmV0JTBBKS50byhkZXZpY2UpJTBBcGlwZS5zY2hlZHVsZXIlMjAlM0QlMjBkaWZmdXNlcnMuRFBNU29sdmVyTXVsdGlzdGVwU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGUuc2NoZWR1bGVyLmNvbmZpZyUyQyUyMHVzZV9rYXJyYXNfc2lnbWFzJTNEVHJ1ZSklMEElMEFjb250cm9sbmV0X291dCUyMCUzRCUyMHBpcGUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEJTIyaGlnaCUyMHF1YWxpdHklMjBwaG90byUyMG9mJTIwYSUyMHNwb3J0cyUyMGJpa2UlMkMlMjBjaXR5JTIyJTJDJTBBJTIwJTIwJTIwJTIwbmVnYXRpdmVfcHJvbXB0JTNEJTIyJTIyJTJDJTBBJTIwJTIwJTIwJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q2LjUlMkMlMEElMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMjUlMkMlMEElMjAlMjAlMjAlMjBpbWFnZSUzRGRlcHRoX2ltYWdlJTJDJTBBJTIwJTIwJTIwJTIwY29udHJvbG5ldF9jb25kaXRpb25pbmdfc2NhbGUlM0QwLjclMkMlMEElMjAlMjAlMjAlMjBjb250cm9sX2d1aWRhbmNlX2VuZCUzRDAuNyUyQyUwQSUyMCUyMCUyMCUyMGdlbmVyYXRvciUzRGdlbmVyYXRvciUyQyUwQSkuaW1hZ2VzJTBBY29udHJvbG5ldF9vdXQlNUIwJTVELnNhdmUoJTIybW90b3JjeWNsZV9jb250cm9sbmV0X291dC5wbmclMjIp",highlighted:`<span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">import</span> diffusers | |
| device = <span class="hljs-string">"cuda"</span> | |
| generator = torch.Generator(device=device).manual_seed(<span class="hljs-number">2024</span>) | |
| image = diffusers.utils.load_image( | |
| <span class="hljs-string">"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_depth_source.png"</span> | |
| ) | |
| pipe = diffusers.MarigoldDepthPipeline.from_pretrained( | |
| <span class="hljs-string">"prs-eth/marigold-depth-v1-1"</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">"fp16"</span> | |
| ).to(device) | |
| depth_image = pipe(image, generator=generator).prediction | |
| depth_image = pipe.image_processor.visualize_depth(depth_image, color_map=<span class="hljs-string">"binary"</span>) | |
| depth_image[<span class="hljs-number">0</span>].save(<span class="hljs-string">"motorcycle_controlnet_depth.png"</span>) | |
| controlnet = diffusers.ControlNetModel.from_pretrained( | |
| <span class="hljs-string">"diffusers/controlnet-depth-sdxl-1.0"</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">"fp16"</span> | |
| ).to(device) | |
| pipe = diffusers.StableDiffusionXLControlNetPipeline.from_pretrained( | |
| <span class="hljs-string">"SG161222/RealVisXL_V4.0"</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">"fp16"</span>, controlnet=controlnet | |
| ).to(device) | |
| pipe.scheduler = diffusers.DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=<span class="hljs-literal">True</span>) | |
| controlnet_out = pipe( | |
| prompt=<span class="hljs-string">"high quality photo of a sports bike, city"</span>, | |
| negative_prompt=<span class="hljs-string">""</span>, | |
| guidance_scale=<span class="hljs-number">6.5</span>, | |
| num_inference_steps=<span class="hljs-number">25</span>, | |
| image=depth_image, | |
| controlnet_conditioning_scale=<span class="hljs-number">0.7</span>, | |
| control_guidance_end=<span class="hljs-number">0.7</span>, | |
| generator=generator, | |
| ).images | |
| controlnet_out[<span class="hljs-number">0</span>].save(<span class="hljs-string">"motorcycle_controlnet_out.png"</span>)`,lang:"python",wrap:!1});var O=e(K,4);n(O,{title:"Quantitative Evaluation",local:"quantitative-evaluation",headingTag:"h2"});var $=e(O,4);t($,{code:"aW1wb3J0JTIwZGlmZnVzZXJzJTBBaW1wb3J0JTIwdG9yY2glMEElMEFkZXZpY2UlMjAlM0QlMjAlMjJjdWRhJTIyJTBBc2VlZCUyMCUzRCUyMDIwMjQlMEElMEFnZW5lcmF0b3IlMjAlM0QlMjB0b3JjaC5HZW5lcmF0b3IoZGV2aWNlJTNEZGV2aWNlKS5tYW51YWxfc2VlZChzZWVkKSUwQXBpcGUlMjAlM0QlMjBkaWZmdXNlcnMuTWFyaWdvbGREZXB0aFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJwcnMtZXRoJTJGbWFyaWdvbGQtZGVwdGgtdjEtMSUyMikudG8oZGV2aWNlKSUwQSUwQWltYWdlJTIwJTNEJTIwZGlmZnVzZXJzLnV0aWxzLmxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZtYXJpZ29sZG1vbm9kZXB0aC5naXRodWIuaW8lMkZpbWFnZXMlMkZlaW5zdGVpbi5qcGclMjIpJTBBJTBBZGVwdGglMjAlM0QlMjBwaXBlKCUwQSUyMCUyMCUyMCUyMGltYWdlJTJDJTIwJTBBJTIwJTIwJTIwJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDQlMkMlMjAlMjAlMjMlMjBzZXQlMjBhY2NvcmRpbmclMjB0byUyMHRoZSUyMGV2YWx1YXRpb24lMjBwcm90b2NvbCUyMGZyb20lMjB0aGUlMjBwYXBlciUwQSUyMCUyMCUyMCUyMGVuc2VtYmxlX3NpemUlM0QxMCUyQyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMyUyMHNldCUyMGFjY29yZGluZyUyMHRvJTIwdGhlJTIwZXZhbHVhdGlvbiUyMHByb3RvY29sJTIwZnJvbSUyMHRoZSUyMHBhcGVyJTBBJTIwJTIwJTIwJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTBBKSUwQSUwQSUyMyUyMGV2YWx1YXRlJTIwbWV0cmljcw==",highlighted:`<span class="hljs-keyword">import</span> diffusers | |
| <span class="hljs-keyword">import</span> torch | |
| device = <span class="hljs-string">"cuda"</span> | |
| seed = <span class="hljs-number">2024</span> | |
| generator = torch.Generator(device=device).manual_seed(seed) | |
| pipe = diffusers.MarigoldDepthPipeline.from_pretrained(<span class="hljs-string">"prs-eth/marigold-depth-v1-1"</span>).to(device) | |
| image = diffusers.utils.load_image(<span class="hljs-string">"https://marigoldmonodepth.github.io/images/einstein.jpg"</span>) | |
| depth = pipe( | |
| image, | |
| num_inference_steps=<span class="hljs-number">4</span>, <span class="hljs-comment"># set according to the evaluation protocol from the paper</span> | |
| ensemble_size=<span class="hljs-number">10</span>, <span class="hljs-comment"># set according to the evaluation protocol from the paper</span> | |
| generator=generator, | |
| ) | |
| <span class="hljs-comment"># evaluate metrics</span>`,lang:"python",wrap:!1});var ee=e($,2);n(ee,{title:"Using Predictive Uncertainty",local:"using-predictive-uncertainty",headingTag:"h2"});var te=e(ee,4);t(te,{code:"aW1wb3J0JTIwZGlmZnVzZXJzJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlJTIwJTNEJTIwZGlmZnVzZXJzLk1hcmlnb2xkRGVwdGhQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIycHJzLWV0aCUyRm1hcmlnb2xkLWRlcHRoLXYxLTElMjIlMkMlMjB2YXJpYW50JTNEJTIyZnAxNiUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFpbWFnZSUyMCUzRCUyMGRpZmZ1c2Vycy51dGlscy5sb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGbWFyaWdvbGRtb25vZGVwdGguZ2l0aHViLmlvJTJGaW1hZ2VzJTJGZWluc3RlaW4uanBnJTIyKSUwQSUwQWRlcHRoJTIwJTNEJTIwcGlwZSglMEElMDlpbWFnZSUyQyUwQSUwOWVuc2VtYmxlX3NpemUlM0QxMCUyQyUyMCUyMCUyMyUyMGFueSUyMG51bWJlciUyMCUzRSUzRCUyMDMlMEElMDlvdXRwdXRfdW5jZXJ0YWludHklM0RUcnVlJTJDJTBBKSUwQSUwQXVuY2VydGFpbnR5JTIwJTNEJTIwcGlwZS5pbWFnZV9wcm9jZXNzb3IudmlzdWFsaXplX3VuY2VydGFpbnR5KGRlcHRoLnVuY2VydGFpbnR5KSUwQXVuY2VydGFpbnR5JTVCMCU1RC5zYXZlKCUyMmVpbnN0ZWluX2RlcHRoX3VuY2VydGFpbnR5LnBuZyUyMik=",highlighted:`<span class="hljs-keyword">import</span> diffusers | |
| <span class="hljs-keyword">import</span> torch | |
| pipe = diffusers.MarigoldDepthPipeline.from_pretrained( | |
| <span class="hljs-string">"prs-eth/marigold-depth-v1-1"</span>, variant=<span class="hljs-string">"fp16"</span>, torch_dtype=torch.float16 | |
| ).to(<span class="hljs-string">"cuda"</span>) | |
| image = diffusers.utils.load_image(<span class="hljs-string">"https://marigoldmonodepth.github.io/images/einstein.jpg"</span>) | |
| depth = pipe( | |
| image, | |
| ensemble_size=<span class="hljs-number">10</span>, <span class="hljs-comment"># any number >= 3</span> | |
| output_uncertainty=<span class="hljs-literal">True</span>, | |
| ) | |
| uncertainty = pipe.image_processor.visualize_uncertainty(depth.uncertainty) | |
| uncertainty[<span class="hljs-number">0</span>].save(<span class="hljs-string">"einstein_depth_uncertainty.png"</span>)`,lang:"python",wrap:!1});var oe=e(te,8);n(oe,{title:"Marigold Depth Prediction API",local:"diffusers.MarigoldDepthPipeline",headingTag:"h2"});var g=e(oe,2),ie=o(g);s(ie,{name:"class diffusers.MarigoldDepthPipeline",anchor:"diffusers.MarigoldDepthPipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/marigold/pipeline_marigold_depth.py#L104",parameters:[{name:"unet",val:": UNet2DConditionModel"},{name:"vae",val:": AutoencoderKL"},{name:"scheduler",val:": diffusers.schedulers.scheduling_ddim.DDIMScheduler | diffusers.schedulers.scheduling_lcm.LCMScheduler"},{name:"text_encoder",val:": CLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"prediction_type",val:": str | None = None"},{name:"scale_invariant",val:": bool | None = True"},{name:"shift_invariant",val:": bool | None = True"},{name:"default_denoising_steps",val:": int | None = None"},{name:"default_processing_resolution",val:": int | None = None"}],parametersDescription:[{anchor:"diffusers.MarigoldDepthPipeline.unet",description:`<strong>unet</strong> (<code>UNet2DConditionModel</code>) — | |
| Conditional U-Net to denoise the depth latent, conditioned on image latent.`,name:"unet"},{anchor:"diffusers.MarigoldDepthPipeline.vae",description:`<strong>vae</strong> (<code>AutoencoderKL</code>) — | |
| Variational Auto-Encoder (VAE) Model to encode and decode images and predictions to and from latent | |
| representations.`,name:"vae"},{anchor:"diffusers.MarigoldDepthPipeline.scheduler",description:`<strong>scheduler</strong> (<code>DDIMScheduler</code> or <code>LCMScheduler</code>) — | |
| A scheduler to be used in combination with <code>unet</code> to denoise the encoded image latents.`,name:"scheduler"},{anchor:"diffusers.MarigoldDepthPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>CLIPTextModel</code>) — | |
| Text-encoder, for empty text embedding.`,name:"text_encoder"},{anchor:"diffusers.MarigoldDepthPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) — | |
| CLIP tokenizer.`,name:"tokenizer"},{anchor:"diffusers.MarigoldDepthPipeline.prediction_type",description:`<strong>prediction_type</strong> (<code>str</code>, <em>optional</em>) — | |
| Type of predictions made by the model.`,name:"prediction_type"},{anchor:"diffusers.MarigoldDepthPipeline.scale_invariant",description:`<strong>scale_invariant</strong> (<code>bool</code>, <em>optional</em>) — | |
| A model property specifying whether the predicted depth maps are scale-invariant. This value must be set in | |
| the model config. When used together with the <code>shift_invariant=True</code> flag, the model is also called | |
| “affine-invariant”. NB: overriding this value is not supported.`,name:"scale_invariant"},{anchor:"diffusers.MarigoldDepthPipeline.shift_invariant",description:`<strong>shift_invariant</strong> (<code>bool</code>, <em>optional</em>) — | |
| A model property specifying whether the predicted depth maps are shift-invariant. This value must be set in | |
| the model config. When used together with the <code>scale_invariant=True</code> flag, the model is also called | |
| “affine-invariant”. NB: overriding this value is not supported.`,name:"shift_invariant"},{anchor:"diffusers.MarigoldDepthPipeline.default_denoising_steps",description:`<strong>default_denoising_steps</strong> (<code>int</code>, <em>optional</em>) — | |
| The minimum number of denoising diffusion steps that are required to produce a prediction of reasonable | |
| quality with the given model. This value must be set in the model config. When the pipeline is called | |
| without explicitly setting <code>num_inference_steps</code>, the default value is used. This is required to ensure | |
| reasonable results with various model flavors compatible with the pipeline, such as those relying on very | |
| short denoising schedules (<code>LCMScheduler</code>) and those with full diffusion schedules (<code>DDIMScheduler</code>).`,name:"default_denoising_steps"},{anchor:"diffusers.MarigoldDepthPipeline.default_processing_resolution",description:`<strong>default_processing_resolution</strong> (<code>int</code>, <em>optional</em>) — | |
| The recommended value of the <code>processing_resolution</code> parameter of the pipeline. This value must be set in | |
| the model config. When the pipeline is called without explicitly setting <code>processing_resolution</code>, the | |
| default value is used. This is required to ensure reasonable results with various model flavors trained | |
| with varying optimal processing resolution values.`,name:"default_processing_resolution"}]});var ne=e(ie,6),se=o(ne);s(se,{name:"__call__",anchor:"diffusers.MarigoldDepthPipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/marigold/pipeline_marigold_depth.py#L347",parameters:[{name:"image",val:": typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]"},{name:"num_inference_steps",val:": int | None = None"},{name:"ensemble_size",val:": int = 1"},{name:"processing_resolution",val:": int | None = None"},{name:"match_input_resolution",val:": bool = True"},{name:"resample_method_input",val:": str = 'bilinear'"},{name:"resample_method_output",val:": str = 'bilinear'"},{name:"batch_size",val:": int = 1"},{name:"ensembling_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"latents",val:": typing.Union[torch.Tensor, list[torch.Tensor], NoneType] = None"},{name:"generator",val:": typing.Union[torch.Generator, list[torch.Generator], NoneType] = None"},{name:"output_type",val:": str = 'np'"},{name:"output_uncertainty",val:": bool = False"},{name:"output_latent",val:": bool = False"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.MarigoldDepthPipeline.__call__.image",description:`<strong>image</strong> (<code>PIL.Image.Image</code>, <code>np.ndarray</code>, <code>torch.Tensor</code>, <code>list[PIL.Image.Image]</code>, <code>list[np.ndarray]</code>), — | |
| <code>list[torch.Tensor]</code>: An input image or images used as an input for the depth estimation task. For | |
| arrays and tensors, the expected value range is between <code>[0, 1]</code>. Passing a batch of images is possible | |
| by providing a four-dimensional array or a tensor. Additionally, a list of images of two- or | |
| three-dimensional arrays or tensors can be passed. In the latter case, all list elements must have the | |
| same width and height.`,name:"image"},{anchor:"diffusers.MarigoldDepthPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Number of denoising diffusion steps during inference. The default value <code>None</code> results in automatic | |
| selection.`,name:"num_inference_steps"},{anchor:"diffusers.MarigoldDepthPipeline.__call__.ensemble_size",description:`<strong>ensemble_size</strong> (<code>int</code>, defaults to <code>1</code>) — | |
| Number of ensemble predictions. Higher values result in measurable improvements and visual degradation.`,name:"ensemble_size"},{anchor:"diffusers.MarigoldDepthPipeline.__call__.processing_resolution",description:`<strong>processing_resolution</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Effective processing resolution. When set to <code>0</code>, matches the larger input image dimension. This | |
| produces crisper predictions, but may also lead to the overall loss of global context. The default | |
| value <code>None</code> resolves to the optimal value from the model config.`,name:"processing_resolution"},{anchor:"diffusers.MarigoldDepthPipeline.__call__.match_input_resolution",description:`<strong>match_input_resolution</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| When enabled, the output prediction is resized to match the input dimensions. When disabled, the longer | |
| side of the output will equal to <code>processing_resolution</code>.`,name:"match_input_resolution"},{anchor:"diffusers.MarigoldDepthPipeline.__call__.resample_method_input",description:`<strong>resample_method_input</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"bilinear"</code>) — | |
| Resampling method used to resize input images to <code>processing_resolution</code>. The accepted values are: | |
| <code>"nearest"</code>, <code>"nearest-exact"</code>, <code>"bilinear"</code>, <code>"bicubic"</code>, or <code>"area"</code>.`,name:"resample_method_input"},{anchor:"diffusers.MarigoldDepthPipeline.__call__.resample_method_output",description:`<strong>resample_method_output</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"bilinear"</code>) — | |
| Resampling method used to resize output predictions to match the input resolution. The accepted values | |
| are <code>"nearest"</code>, <code>"nearest-exact"</code>, <code>"bilinear"</code>, <code>"bicubic"</code>, or <code>"area"</code>.`,name:"resample_method_output"},{anchor:"diffusers.MarigoldDepthPipeline.__call__.batch_size",description:`<strong>batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) — | |
| Batch size; only matters when setting <code>ensemble_size</code> or passing a tensor of images.`,name:"batch_size"},{anchor:"diffusers.MarigoldDepthPipeline.__call__.ensembling_kwargs",description:`<strong>ensembling_kwargs</strong> (<code>dict</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Extra dictionary with arguments for precise ensembling control. The following options are available: | |
| <ul> | |
| <li>reduction (<code>str</code>, <em>optional</em>, defaults to <code>"median"</code>): Defines the ensembling function applied in | |
| every pixel location, can be either <code>"median"</code> or <code>"mean"</code>.</li> | |
| <li>regularizer_strength (<code>float</code>, <em>optional</em>, defaults to <code>0.02</code>): Strength of the regularizer that | |
| pulls the aligned predictions to the unit range from 0 to 1.</li> | |
| <li>max_iter (<code>int</code>, <em>optional</em>, defaults to <code>2</code>): Maximum number of the alignment solver steps. Refer to | |
| <code>scipy.optimize.minimize</code> function, <code>options</code> argument.</li> | |
| <li>tol (<code>float</code>, <em>optional</em>, defaults to <code>1e-3</code>): Alignment solver tolerance. The solver stops when the | |
| tolerance is reached.</li> | |
| <li>max_res (<code>int</code>, <em>optional</em>, defaults to <code>None</code>): Resolution at which the alignment is performed; | |
| <code>None</code> matches the <code>processing_resolution</code>.</li> | |
| </ul>`,name:"ensembling_kwargs"},{anchor:"diffusers.MarigoldDepthPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, or <code>list[torch.Tensor]</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Latent noise tensors to replace the random initialization. These can be taken from the previous | |
| function call’s output.`,name:"latents"},{anchor:"diffusers.MarigoldDepthPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, or <code>list[torch.Generator]</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Random number generator object to ensure reproducibility.`,name:"generator"},{anchor:"diffusers.MarigoldDepthPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"np"</code>) — | |
| Preferred format of the output’s <code>prediction</code> and the optional <code>uncertainty</code> fields. The accepted | |
| values are: <code>"np"</code> (numpy array) or <code>"pt"</code> (torch tensor).`,name:"output_type"},{anchor:"diffusers.MarigoldDepthPipeline.__call__.output_uncertainty",description:`<strong>output_uncertainty</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| When enabled, the output’s <code>uncertainty</code> field contains the predictive uncertainty map, provided that | |
| the <code>ensemble_size</code> argument is set to a value above 2.`,name:"output_uncertainty"},{anchor:"diffusers.MarigoldDepthPipeline.__call__.output_latent",description:`<strong>output_latent</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| When enabled, the output’s <code>latent</code> field contains the latent codes corresponding to the predictions | |
| within the ensemble. These codes can be saved, modified, and used for subsequent calls with the | |
| <code>latents</code> argument.`,name:"output_latent"},{anchor:"diffusers.MarigoldDepthPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether or not to return a <a href="/docs/diffusers/pr_14178/en/api/pipelines/marigold#diffusers.pipelines.marigold.MarigoldDepthOutput">MarigoldDepthOutput</a> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>If <code>return_dict</code> is <code>True</code>, <a | |
| href="/docs/diffusers/pr_14178/en/api/pipelines/marigold#diffusers.pipelines.marigold.MarigoldDepthOutput" | |
| >MarigoldDepthOutput</a> is returned, otherwise a | |
| <code>tuple</code> is returned where the first element is the prediction, the second element is the uncertainty | |
| (or <code>None</code>), and the third is the latent (or <code>None</code>).</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/diffusers/pr_14178/en/api/pipelines/marigold#diffusers.pipelines.marigold.MarigoldDepthOutput" | |
| >MarigoldDepthOutput</a> or <code>tuple</code></p> | |
| `});var Me=e(se,4);u(Me,{anchor:"diffusers.MarigoldDepthPipeline.__call__.example",children:(a,d)=>{var l=v(),c=e(m(l),2);t(c,{code:"aW1wb3J0JTIwZGlmZnVzZXJzJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlJTIwJTNEJTIwZGlmZnVzZXJzLk1hcmlnb2xkRGVwdGhQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIycHJzLWV0aCUyRm1hcmlnb2xkLWRlcHRoLXYxLTElMjIlMkMlMjB2YXJpYW50JTNEJTIyZnAxNiUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFpbWFnZSUyMCUzRCUyMGRpZmZ1c2Vycy51dGlscy5sb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGbWFyaWdvbGRtb25vZGVwdGguZ2l0aHViLmlvJTJGaW1hZ2VzJTJGZWluc3RlaW4uanBnJTIyKSUwQWRlcHRoJTIwJTNEJTIwcGlwZShpbWFnZSklMEElMEF2aXMlMjAlM0QlMjBwaXBlLmltYWdlX3Byb2Nlc3Nvci52aXN1YWxpemVfZGVwdGgoZGVwdGgucHJlZGljdGlvbiklMEF2aXMlNUIwJTVELnNhdmUoJTIyZWluc3RlaW5fZGVwdGgucG5nJTIyKSUwQSUwQWRlcHRoXzE2Yml0JTIwJTNEJTIwcGlwZS5pbWFnZV9wcm9jZXNzb3IuZXhwb3J0X2RlcHRoX3RvXzE2Yml0X3BuZyhkZXB0aC5wcmVkaWN0aW9uKSUwQWRlcHRoXzE2Yml0JTVCMCU1RC5zYXZlKCUyMmVpbnN0ZWluX2RlcHRoXzE2Yml0LnBuZyUyMik=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> diffusers | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span>pipe = diffusers.MarigoldDepthPipeline.from_pretrained( | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"prs-eth/marigold-depth-v1-1"</span>, variant=<span class="hljs-string">"fp16"</span>, torch_dtype=torch.float16 | |
| <span class="hljs-meta">... </span>).to(<span class="hljs-string">"cuda"</span>) | |
| <span class="hljs-meta">>>> </span>image = diffusers.utils.load_image(<span class="hljs-string">"https://marigoldmonodepth.github.io/images/einstein.jpg"</span>) | |
| <span class="hljs-meta">>>> </span>depth = pipe(image) | |
| <span class="hljs-meta">>>> </span>vis = pipe.image_processor.visualize_depth(depth.prediction) | |
| <span class="hljs-meta">>>> </span>vis[<span class="hljs-number">0</span>].save(<span class="hljs-string">"einstein_depth.png"</span>) | |
| <span class="hljs-meta">>>> </span>depth_16bit = pipe.image_processor.export_depth_to_16bit_png(depth.prediction) | |
| <span class="hljs-meta">>>> </span>depth_16bit[<span class="hljs-number">0</span>].save(<span class="hljs-string">"einstein_depth_16bit.png"</span>)`,lang:"py",wrap:!1}),p(a,l)},$$slots:{default:!0}}),i(ne),i(g);var f=e(g,2),be=o(f);s(be,{name:"class diffusers.pipelines.marigold.MarigoldDepthOutput",anchor:"diffusers.pipelines.marigold.MarigoldDepthOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/marigold/pipeline_marigold_depth.py#L83",parameters:[{name:"prediction",val:": typing.Union[numpy.ndarray, torch.Tensor]"},{name:"uncertainty",val:": typing.Union[NoneType, numpy.ndarray, torch.Tensor]"},{name:"latent",val:": typing.Optional[torch.Tensor]"}],parametersDescription:[{anchor:"diffusers.pipelines.marigold.MarigoldDepthOutput.prediction",description:`<strong>prediction</strong> (<code>np.ndarray</code>, <code>torch.Tensor</code>) — | |
| Predicted depth maps with values in the range [0, 1]. The shape is <code>numimages × 1 × height × width</code> for | |
| <code>torch.Tensor</code> or <code>numimages × height × width × 1</code> for <code>np.ndarray</code>.`,name:"prediction"},{anchor:"diffusers.pipelines.marigold.MarigoldDepthOutput.uncertainty",description:`<strong>uncertainty</strong> (<code>None</code>, <code>np.ndarray</code>, <code>torch.Tensor</code>) — | |
| Uncertainty maps computed from the ensemble, with values in the range [0, 1]. The shape is <code>numimages × 1 × height × width</code> for <code>torch.Tensor</code> or <code>numimages × height × width × 1</code> for <code>np.ndarray</code>.`,name:"uncertainty"},{anchor:"diffusers.pipelines.marigold.MarigoldDepthOutput.latent",description:`<strong>latent</strong> (<code>None</code>, <code>torch.Tensor</code>) — | |
| Latent features corresponding to the predictions, compatible with the <code>latents</code> argument of the pipeline. | |
| The shape is <code>numimages * numensemble × 4 × latentheight × latentwidth</code>.`,name:"latent"}]}),r(2),i(f);var y=e(f,2),_e=o(y);s(_e,{name:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_depth",anchor:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_depth",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/marigold/marigold_image_processing.py#L387",parameters:[{name:"depth",val:": typing.Union[PIL.Image.Image, torch.Tensor, numpy.ndarray, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]"},{name:"val_min",val:": float = 0.0"},{name:"val_max",val:": float = 1.0"},{name:"color_map",val:": str = 'Spectral'"}],parametersDescription:[{anchor:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_depth.depth",description:"<strong>depth</strong> (<code>PIL.Image.Image | np.ndarray | torch.Tensor | list[PIL.Image.Image, list[np.ndarray], -- list[torch.Tensor]]</code>): Depth maps.",name:"depth"},{anchor:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_depth.val_min",description:"<strong>val_min</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.0</code>) — Minimum value of the visualized depth range.",name:"val_min"},{anchor:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_depth.val_max",description:"<strong>val_max</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1.0</code>) — Maximum value of the visualized depth range.",name:"val_max"},{anchor:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_depth.color_map",description:`<strong>color_map</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"Spectral"</code>) — Color map used to convert a single-channel | |
| depth prediction into colored representation.`,name:"color_map"}]}),r(4),i(y);var ae=e(y,2);n(ae,{title:"Marigold Normals Estimation API",local:"diffusers.MarigoldNormalsPipeline",headingTag:"h2"});var M=e(ae,2),le=o(M);s(le,{name:"class diffusers.MarigoldNormalsPipeline",anchor:"diffusers.MarigoldNormalsPipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/marigold/pipeline_marigold_normals.py#L99",parameters:[{name:"unet",val:": UNet2DConditionModel"},{name:"vae",val:": AutoencoderKL"},{name:"scheduler",val:": diffusers.schedulers.scheduling_ddim.DDIMScheduler | diffusers.schedulers.scheduling_lcm.LCMScheduler"},{name:"text_encoder",val:": CLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"prediction_type",val:": str | None = None"},{name:"use_full_z_range",val:": bool | None = True"},{name:"default_denoising_steps",val:": int | None = None"},{name:"default_processing_resolution",val:": int | None = None"}],parametersDescription:[{anchor:"diffusers.MarigoldNormalsPipeline.unet",description:`<strong>unet</strong> (<code>UNet2DConditionModel</code>) — | |
| Conditional U-Net to denoise the normals latent, conditioned on image latent.`,name:"unet"},{anchor:"diffusers.MarigoldNormalsPipeline.vae",description:`<strong>vae</strong> (<code>AutoencoderKL</code>) — | |
| Variational Auto-Encoder (VAE) Model to encode and decode images and predictions to and from latent | |
| representations.`,name:"vae"},{anchor:"diffusers.MarigoldNormalsPipeline.scheduler",description:`<strong>scheduler</strong> (<code>DDIMScheduler</code> or <code>LCMScheduler</code>) — | |
| A scheduler to be used in combination with <code>unet</code> to denoise the encoded image latents.`,name:"scheduler"},{anchor:"diffusers.MarigoldNormalsPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>CLIPTextModel</code>) — | |
| Text-encoder, for empty text embedding.`,name:"text_encoder"},{anchor:"diffusers.MarigoldNormalsPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) — | |
| CLIP tokenizer.`,name:"tokenizer"},{anchor:"diffusers.MarigoldNormalsPipeline.prediction_type",description:`<strong>prediction_type</strong> (<code>str</code>, <em>optional</em>) — | |
| Type of predictions made by the model.`,name:"prediction_type"},{anchor:"diffusers.MarigoldNormalsPipeline.use_full_z_range",description:`<strong>use_full_z_range</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether the normals predicted by this model utilize the full range of the Z dimension, or only its positive | |
| half.`,name:"use_full_z_range"},{anchor:"diffusers.MarigoldNormalsPipeline.default_denoising_steps",description:`<strong>default_denoising_steps</strong> (<code>int</code>, <em>optional</em>) — | |
| The minimum number of denoising diffusion steps that are required to produce a prediction of reasonable | |
| quality with the given model. This value must be set in the model config. When the pipeline is called | |
| without explicitly setting <code>num_inference_steps</code>, the default value is used. This is required to ensure | |
| reasonable results with various model flavors compatible with the pipeline, such as those relying on very | |
| short denoising schedules (<code>LCMScheduler</code>) and those with full diffusion schedules (<code>DDIMScheduler</code>).`,name:"default_denoising_steps"},{anchor:"diffusers.MarigoldNormalsPipeline.default_processing_resolution",description:`<strong>default_processing_resolution</strong> (<code>int</code>, <em>optional</em>) — | |
| The recommended value of the <code>processing_resolution</code> parameter of the pipeline. This value must be set in | |
| the model config. When the pipeline is called without explicitly setting <code>processing_resolution</code>, the | |
| default value is used. This is required to ensure reasonable results with various model flavors trained | |
| with varying optimal processing resolution values.`,name:"default_processing_resolution"}]});var re=e(le,6),de=o(re);s(de,{name:"__call__",anchor:"diffusers.MarigoldNormalsPipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/marigold/pipeline_marigold_normals.py#L332",parameters:[{name:"image",val:": typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]"},{name:"num_inference_steps",val:": int | None = None"},{name:"ensemble_size",val:": int = 1"},{name:"processing_resolution",val:": int | None = None"},{name:"match_input_resolution",val:": bool = True"},{name:"resample_method_input",val:": str = 'bilinear'"},{name:"resample_method_output",val:": str = 'bilinear'"},{name:"batch_size",val:": int = 1"},{name:"ensembling_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"latents",val:": typing.Union[torch.Tensor, list[torch.Tensor], NoneType] = None"},{name:"generator",val:": typing.Union[torch.Generator, list[torch.Generator], NoneType] = None"},{name:"output_type",val:": str = 'np'"},{name:"output_uncertainty",val:": bool = False"},{name:"output_latent",val:": bool = False"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.MarigoldNormalsPipeline.__call__.image",description:`<strong>image</strong> (<code>PIL.Image.Image</code>, <code>np.ndarray</code>, <code>torch.Tensor</code>, <code>list[PIL.Image.Image]</code>, <code>list[np.ndarray]</code>), — | |
| <code>list[torch.Tensor]</code>: An input image or images used as an input for the normals estimation task. For | |
| arrays and tensors, the expected value range is between <code>[0, 1]</code>. Passing a batch of images is possible | |
| by providing a four-dimensional array or a tensor. Additionally, a list of images of two- or | |
| three-dimensional arrays or tensors can be passed. In the latter case, all list elements must have the | |
| same width and height.`,name:"image"},{anchor:"diffusers.MarigoldNormalsPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Number of denoising diffusion steps during inference. The default value <code>None</code> results in automatic | |
| selection.`,name:"num_inference_steps"},{anchor:"diffusers.MarigoldNormalsPipeline.__call__.ensemble_size",description:`<strong>ensemble_size</strong> (<code>int</code>, defaults to <code>1</code>) — | |
| Number of ensemble predictions. Higher values result in measurable improvements and visual degradation.`,name:"ensemble_size"},{anchor:"diffusers.MarigoldNormalsPipeline.__call__.processing_resolution",description:`<strong>processing_resolution</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Effective processing resolution. When set to <code>0</code>, matches the larger input image dimension. This | |
| produces crisper predictions, but may also lead to the overall loss of global context. The default | |
| value <code>None</code> resolves to the optimal value from the model config.`,name:"processing_resolution"},{anchor:"diffusers.MarigoldNormalsPipeline.__call__.match_input_resolution",description:`<strong>match_input_resolution</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| When enabled, the output prediction is resized to match the input dimensions. When disabled, the longer | |
| side of the output will equal to <code>processing_resolution</code>.`,name:"match_input_resolution"},{anchor:"diffusers.MarigoldNormalsPipeline.__call__.resample_method_input",description:`<strong>resample_method_input</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"bilinear"</code>) — | |
| Resampling method used to resize input images to <code>processing_resolution</code>. The accepted values are: | |
| <code>"nearest"</code>, <code>"nearest-exact"</code>, <code>"bilinear"</code>, <code>"bicubic"</code>, or <code>"area"</code>.`,name:"resample_method_input"},{anchor:"diffusers.MarigoldNormalsPipeline.__call__.resample_method_output",description:`<strong>resample_method_output</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"bilinear"</code>) — | |
| Resampling method used to resize output predictions to match the input resolution. The accepted values | |
| are <code>"nearest"</code>, <code>"nearest-exact"</code>, <code>"bilinear"</code>, <code>"bicubic"</code>, or <code>"area"</code>.`,name:"resample_method_output"},{anchor:"diffusers.MarigoldNormalsPipeline.__call__.batch_size",description:`<strong>batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) — | |
| Batch size; only matters when setting <code>ensemble_size</code> or passing a tensor of images.`,name:"batch_size"},{anchor:"diffusers.MarigoldNormalsPipeline.__call__.ensembling_kwargs",description:`<strong>ensembling_kwargs</strong> (<code>dict</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Extra dictionary with arguments for precise ensembling control. The following options are available: | |
| <ul> | |
| <li>reduction (<code>str</code>, <em>optional</em>, defaults to <code>"closest"</code>): Defines the ensembling function applied in | |
| every pixel location, can be either <code>"closest"</code> or <code>"mean"</code>.</li> | |
| </ul>`,name:"ensembling_kwargs"},{anchor:"diffusers.MarigoldNormalsPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Latent noise tensors to replace the random initialization. These can be taken from the previous | |
| function call’s output.`,name:"latents"},{anchor:"diffusers.MarigoldNormalsPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, or <code>list[torch.Generator]</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Random number generator object to ensure reproducibility.`,name:"generator"},{anchor:"diffusers.MarigoldNormalsPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"np"</code>) — | |
| Preferred format of the output’s <code>prediction</code> and the optional <code>uncertainty</code> fields. The accepted | |
| values are: <code>"np"</code> (numpy array) or <code>"pt"</code> (torch tensor).`,name:"output_type"},{anchor:"diffusers.MarigoldNormalsPipeline.__call__.output_uncertainty",description:`<strong>output_uncertainty</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| When enabled, the output’s <code>uncertainty</code> field contains the predictive uncertainty map, provided that | |
| the <code>ensemble_size</code> argument is set to a value above 2.`,name:"output_uncertainty"},{anchor:"diffusers.MarigoldNormalsPipeline.__call__.output_latent",description:`<strong>output_latent</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| When enabled, the output’s <code>latent</code> field contains the latent codes corresponding to the predictions | |
| within the ensemble. These codes can be saved, modified, and used for subsequent calls with the | |
| <code>latents</code> argument.`,name:"output_latent"},{anchor:"diffusers.MarigoldNormalsPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether or not to return a <a href="/docs/diffusers/pr_14178/en/api/pipelines/marigold#diffusers.pipelines.marigold.MarigoldNormalsOutput">MarigoldNormalsOutput</a> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>If <code>return_dict</code> is <code>True</code>, <a | |
| href="/docs/diffusers/pr_14178/en/api/pipelines/marigold#diffusers.pipelines.marigold.MarigoldNormalsOutput" | |
| >MarigoldNormalsOutput</a> is returned, otherwise a | |
| <code>tuple</code> is returned where the first element is the prediction, the second element is the uncertainty | |
| (or <code>None</code>), and the third is the latent (or <code>None</code>).</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/diffusers/pr_14178/en/api/pipelines/marigold#diffusers.pipelines.marigold.MarigoldNormalsOutput" | |
| >MarigoldNormalsOutput</a> or <code>tuple</code></p> | |
| `});var Je=e(de,4);u(Je,{anchor:"diffusers.MarigoldNormalsPipeline.__call__.example",children:(a,d)=>{var l=v(),c=e(m(l),2);t(c,{code:"aW1wb3J0JTIwZGlmZnVzZXJzJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlJTIwJTNEJTIwZGlmZnVzZXJzLk1hcmlnb2xkTm9ybWFsc1BpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJwcnMtZXRoJTJGbWFyaWdvbGQtbm9ybWFscy12MS0xJTIyJTJDJTIwdmFyaWFudCUzRCUyMmZwMTYlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBaW1hZ2UlMjAlM0QlMjBkaWZmdXNlcnMudXRpbHMubG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRm1hcmlnb2xkbW9ub2RlcHRoLmdpdGh1Yi5pbyUyRmltYWdlcyUyRmVpbnN0ZWluLmpwZyUyMiklMEFub3JtYWxzJTIwJTNEJTIwcGlwZShpbWFnZSklMEElMEF2aXMlMjAlM0QlMjBwaXBlLmltYWdlX3Byb2Nlc3Nvci52aXN1YWxpemVfbm9ybWFscyhub3JtYWxzLnByZWRpY3Rpb24pJTBBdmlzJTVCMCU1RC5zYXZlKCUyMmVpbnN0ZWluX25vcm1hbHMucG5nJTIyKQ==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> diffusers | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span>pipe = diffusers.MarigoldNormalsPipeline.from_pretrained( | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"prs-eth/marigold-normals-v1-1"</span>, variant=<span class="hljs-string">"fp16"</span>, torch_dtype=torch.float16 | |
| <span class="hljs-meta">... </span>).to(<span class="hljs-string">"cuda"</span>) | |
| <span class="hljs-meta">>>> </span>image = diffusers.utils.load_image(<span class="hljs-string">"https://marigoldmonodepth.github.io/images/einstein.jpg"</span>) | |
| <span class="hljs-meta">>>> </span>normals = pipe(image) | |
| <span class="hljs-meta">>>> </span>vis = pipe.image_processor.visualize_normals(normals.prediction) | |
| <span class="hljs-meta">>>> </span>vis[<span class="hljs-number">0</span>].save(<span class="hljs-string">"einstein_normals.png"</span>)`,lang:"py",wrap:!1}),p(a,l)},$$slots:{default:!0}}),i(re),i(M);var b=e(M,2),we=o(b);s(we,{name:"class diffusers.pipelines.marigold.MarigoldNormalsOutput",anchor:"diffusers.pipelines.marigold.MarigoldNormalsOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/marigold/pipeline_marigold_normals.py#L78",parameters:[{name:"prediction",val:": typing.Union[numpy.ndarray, torch.Tensor]"},{name:"uncertainty",val:": typing.Union[NoneType, numpy.ndarray, torch.Tensor]"},{name:"latent",val:": typing.Optional[torch.Tensor]"}],parametersDescription:[{anchor:"diffusers.pipelines.marigold.MarigoldNormalsOutput.prediction",description:`<strong>prediction</strong> (<code>np.ndarray</code>, <code>torch.Tensor</code>) — | |
| Predicted normals with values in the range [-1, 1]. The shape is <code>numimages × 3 × height × width</code> for | |
| <code>torch.Tensor</code> or <code>numimages × height × width × 3</code> for <code>np.ndarray</code>.`,name:"prediction"},{anchor:"diffusers.pipelines.marigold.MarigoldNormalsOutput.uncertainty",description:`<strong>uncertainty</strong> (<code>None</code>, <code>np.ndarray</code>, <code>torch.Tensor</code>) — | |
| Uncertainty maps computed from the ensemble, with values in the range [0, 1]. The shape is <code>numimages × 1 × height × width</code> for <code>torch.Tensor</code> or <code>numimages × height × width × 1</code> for <code>np.ndarray</code>.`,name:"uncertainty"},{anchor:"diffusers.pipelines.marigold.MarigoldNormalsOutput.latent",description:`<strong>latent</strong> (<code>None</code>, <code>torch.Tensor</code>) — | |
| Latent features corresponding to the predictions, compatible with the <code>latents</code> argument of the pipeline. | |
| The shape is <code>numimages * numensemble × 4 × latentheight × latentwidth</code>.`,name:"latent"}]}),r(2),i(b);var _=e(b,2),Te=o(_);s(Te,{name:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_normals",anchor:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_normals",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/marigold/marigold_image_processing.py#L486",parameters:[{name:"normals",val:": typing.Union[numpy.ndarray, torch.Tensor, list[numpy.ndarray], list[torch.Tensor]]"},{name:"flip_x",val:": bool = False"},{name:"flip_y",val:": bool = False"},{name:"flip_z",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_normals.normals",description:`<strong>normals</strong> (<code>np.ndarray | torch.Tensor | list[np.ndarray, list[torch.Tensor]]</code>) — | |
| Surface normals.`,name:"normals"},{anchor:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_normals.flip_x",description:`<strong>flip_x</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — Flips the X axis of the normals frame of reference. | |
| Default direction is right.`,name:"flip_x"},{anchor:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_normals.flip_y",description:`<strong>flip_y</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — Flips the Y axis of the normals frame of reference. | |
| Default direction is top.`,name:"flip_y"},{anchor:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_normals.flip_z",description:`<strong>flip_z</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — Flips the Z axis of the normals frame of reference. | |
| Default direction is facing the observer.`,name:"flip_z"}]}),r(4),i(_);var ce=e(_,2);n(ce,{title:"Marigold Intrinsic Image Decomposition API",local:"diffusers.MarigoldIntrinsicsPipeline",headingTag:"h2"});var J=e(ce,2),pe=o(J);s(pe,{name:"class diffusers.MarigoldIntrinsicsPipeline",anchor:"diffusers.MarigoldIntrinsicsPipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/marigold/pipeline_marigold_intrinsics.py#L120",parameters:[{name:"unet",val:": UNet2DConditionModel"},{name:"vae",val:": AutoencoderKL"},{name:"scheduler",val:": diffusers.schedulers.scheduling_ddim.DDIMScheduler | diffusers.schedulers.scheduling_lcm.LCMScheduler"},{name:"text_encoder",val:": CLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"prediction_type",val:": str | None = None"},{name:"target_properties",val:": dict[str, typing.Any] | None = None"},{name:"default_denoising_steps",val:": int | None = None"},{name:"default_processing_resolution",val:": int | None = None"}],parametersDescription:[{anchor:"diffusers.MarigoldIntrinsicsPipeline.unet",description:`<strong>unet</strong> (<code>UNet2DConditionModel</code>) — | |
| Conditional U-Net to denoise the targets latent, conditioned on image latent.`,name:"unet"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.vae",description:`<strong>vae</strong> (<code>AutoencoderKL</code>) — | |
| Variational Auto-Encoder (VAE) Model to encode and decode images and predictions to and from latent | |
| representations.`,name:"vae"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.scheduler",description:`<strong>scheduler</strong> (<code>DDIMScheduler</code> or <code>LCMScheduler</code>) — | |
| A scheduler to be used in combination with <code>unet</code> to denoise the encoded image latents.`,name:"scheduler"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>CLIPTextModel</code>) — | |
| Text-encoder, for empty text embedding.`,name:"text_encoder"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) — | |
| CLIP tokenizer.`,name:"tokenizer"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.prediction_type",description:`<strong>prediction_type</strong> (<code>str</code>, <em>optional</em>) — | |
| Type of predictions made by the model.`,name:"prediction_type"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.target_properties",description:`<strong>target_properties</strong> (<code>dict[str, Any]</code>, <em>optional</em>) — | |
| Properties of the predicted modalities, such as <code>target_names</code>, a <code>list[str]</code> used to define the number, | |
| order and names of the predicted modalities, and any other metadata that may be required to interpret the | |
| predictions.`,name:"target_properties"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.default_denoising_steps",description:`<strong>default_denoising_steps</strong> (<code>int</code>, <em>optional</em>) — | |
| The minimum number of denoising diffusion steps that are required to produce a prediction of reasonable | |
| quality with the given model. This value must be set in the model config. When the pipeline is called | |
| without explicitly setting <code>num_inference_steps</code>, the default value is used. This is required to ensure | |
| reasonable results with various model flavors compatible with the pipeline, such as those relying on very | |
| short denoising schedules (<code>LCMScheduler</code>) and those with full diffusion schedules (<code>DDIMScheduler</code>).`,name:"default_denoising_steps"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.default_processing_resolution",description:`<strong>default_processing_resolution</strong> (<code>int</code>, <em>optional</em>) — | |
| The recommended value of the <code>processing_resolution</code> parameter of the pipeline. This value must be set in | |
| the model config. When the pipeline is called without explicitly setting <code>processing_resolution</code>, the | |
| default value is used. This is required to ensure reasonable results with various model flavors trained | |
| with varying optimal processing resolution values.`,name:"default_processing_resolution"}]});var me=e(pe,6),ue=o(me);s(ue,{name:"__call__",anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/marigold/pipeline_marigold_intrinsics.py#L359",parameters:[{name:"image",val:": typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]"},{name:"num_inference_steps",val:": int | None = None"},{name:"ensemble_size",val:": int = 1"},{name:"processing_resolution",val:": int | None = None"},{name:"match_input_resolution",val:": bool = True"},{name:"resample_method_input",val:": str = 'bilinear'"},{name:"resample_method_output",val:": str = 'bilinear'"},{name:"batch_size",val:": int = 1"},{name:"ensembling_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"latents",val:": typing.Union[torch.Tensor, list[torch.Tensor], NoneType] = None"},{name:"generator",val:": typing.Union[torch.Generator, list[torch.Generator], NoneType] = None"},{name:"output_type",val:": str = 'np'"},{name:"output_uncertainty",val:": bool = False"},{name:"output_latent",val:": bool = False"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.image",description:`<strong>image</strong> (<code>PIL.Image.Image</code>, <code>np.ndarray</code>, <code>torch.Tensor</code>, <code>list[PIL.Image.Image]</code>, <code>list[np.ndarray]</code>), — | |
| <code>list[torch.Tensor]</code>: An input image or images used as an input for the intrinsic decomposition task. | |
| For arrays and tensors, the expected value range is between <code>[0, 1]</code>. Passing a batch of images is | |
| possible by providing a four-dimensional array or a tensor. Additionally, a list of images of two- or | |
| three-dimensional arrays or tensors can be passed. In the latter case, all list elements must have the | |
| same width and height.`,name:"image"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Number of denoising diffusion steps during inference. The default value <code>None</code> results in automatic | |
| selection.`,name:"num_inference_steps"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.ensemble_size",description:`<strong>ensemble_size</strong> (<code>int</code>, defaults to <code>1</code>) — | |
| Number of ensemble predictions. Higher values result in measurable improvements and visual degradation.`,name:"ensemble_size"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.processing_resolution",description:`<strong>processing_resolution</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Effective processing resolution. When set to <code>0</code>, matches the larger input image dimension. This | |
| produces crisper predictions, but may also lead to the overall loss of global context. The default | |
| value <code>None</code> resolves to the optimal value from the model config.`,name:"processing_resolution"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.match_input_resolution",description:`<strong>match_input_resolution</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| When enabled, the output prediction is resized to match the input dimensions. When disabled, the longer | |
| side of the output will equal to <code>processing_resolution</code>.`,name:"match_input_resolution"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.resample_method_input",description:`<strong>resample_method_input</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"bilinear"</code>) — | |
| Resampling method used to resize input images to <code>processing_resolution</code>. The accepted values are: | |
| <code>"nearest"</code>, <code>"nearest-exact"</code>, <code>"bilinear"</code>, <code>"bicubic"</code>, or <code>"area"</code>.`,name:"resample_method_input"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.resample_method_output",description:`<strong>resample_method_output</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"bilinear"</code>) — | |
| Resampling method used to resize output predictions to match the input resolution. The accepted values | |
| are <code>"nearest"</code>, <code>"nearest-exact"</code>, <code>"bilinear"</code>, <code>"bicubic"</code>, or <code>"area"</code>.`,name:"resample_method_output"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.batch_size",description:`<strong>batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) — | |
| Batch size; only matters when setting <code>ensemble_size</code> or passing a tensor of images.`,name:"batch_size"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.ensembling_kwargs",description:`<strong>ensembling_kwargs</strong> (<code>dict</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Extra dictionary with arguments for precise ensembling control. The following options are available: | |
| <ul> | |
| <li>reduction (<code>str</code>, <em>optional</em>, defaults to <code>"median"</code>): Defines the ensembling function applied in | |
| every pixel location, can be either <code>"median"</code> or <code>"mean"</code>.</li> | |
| </ul>`,name:"ensembling_kwargs"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Latent noise tensors to replace the random initialization. These can be taken from the previous | |
| function call’s output.`,name:"latents"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, or <code>list[torch.Generator]</code>, <em>optional</em>, defaults to <code>None</code>) — | |
| Random number generator object to ensure reproducibility.`,name:"generator"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"np"</code>) — | |
| Preferred format of the output’s <code>prediction</code> and the optional <code>uncertainty</code> fields. The accepted | |
| values are: <code>"np"</code> (numpy array) or <code>"pt"</code> (torch tensor).`,name:"output_type"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.output_uncertainty",description:`<strong>output_uncertainty</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| When enabled, the output’s <code>uncertainty</code> field contains the predictive uncertainty map, provided that | |
| the <code>ensemble_size</code> argument is set to a value above 2.`,name:"output_uncertainty"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.output_latent",description:`<strong>output_latent</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| When enabled, the output’s <code>latent</code> field contains the latent codes corresponding to the predictions | |
| within the ensemble. These codes can be saved, modified, and used for subsequent calls with the | |
| <code>latents</code> argument.`,name:"output_latent"},{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether or not to return a <a href="/docs/diffusers/pr_14178/en/api/pipelines/marigold#diffusers.pipelines.marigold.MarigoldIntrinsicsOutput">MarigoldIntrinsicsOutput</a> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>If <code>return_dict</code> is <code>True</code>, <a | |
| href="/docs/diffusers/pr_14178/en/api/pipelines/marigold#diffusers.pipelines.marigold.MarigoldIntrinsicsOutput" | |
| >MarigoldIntrinsicsOutput</a> is returned, otherwise a | |
| <code>tuple</code> is returned where the first element is the prediction, the second element is the uncertainty | |
| (or <code>None</code>), and the third is the latent (or <code>None</code>).</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><a | |
| href="/docs/diffusers/pr_14178/en/api/pipelines/marigold#diffusers.pipelines.marigold.MarigoldIntrinsicsOutput" | |
| >MarigoldIntrinsicsOutput</a> or <code>tuple</code></p> | |
| `});var he=e(ue,4);u(he,{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.example",children:(a,d)=>{var l=v(),c=e(m(l),2);t(c,{code:"aW1wb3J0JTIwZGlmZnVzZXJzJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlJTIwJTNEJTIwZGlmZnVzZXJzLk1hcmlnb2xkSW50cmluc2ljc1BpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJwcnMtZXRoJTJGbWFyaWdvbGQtaWlkLWFwcGVhcmFuY2UtdjEtMSUyMiUyQyUyMHZhcmlhbnQlM0QlMjJmcDE2JTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwZGlmZnVzZXJzLnV0aWxzLmxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZtYXJpZ29sZG1vbm9kZXB0aC5naXRodWIuaW8lMkZpbWFnZXMlMkZlaW5zdGVpbi5qcGclMjIpJTBBaW50cmluc2ljcyUyMCUzRCUyMHBpcGUoaW1hZ2UpJTBBJTBBdmlzJTIwJTNEJTIwcGlwZS5pbWFnZV9wcm9jZXNzb3IudmlzdWFsaXplX2ludHJpbnNpY3MoaW50cmluc2ljcy5wcmVkaWN0aW9uJTJDJTIwcGlwZS50YXJnZXRfcHJvcGVydGllcyklMEF2aXMlNUIwJTVEJTVCJTIyYWxiZWRvJTIyJTVELnNhdmUoJTIyZWluc3RlaW5fYWxiZWRvLnBuZyUyMiklMEF2aXMlNUIwJTVEJTVCJTIycm91Z2huZXNzJTIyJTVELnNhdmUoJTIyZWluc3RlaW5fcm91Z2huZXNzLnBuZyUyMiklMEF2aXMlNUIwJTVEJTVCJTIybWV0YWxsaWNpdHklMjIlNUQuc2F2ZSglMjJlaW5zdGVpbl9tZXRhbGxpY2l0eS5wbmclMjIp",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> diffusers | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span>pipe = diffusers.MarigoldIntrinsicsPipeline.from_pretrained( | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"prs-eth/marigold-iid-appearance-v1-1"</span>, variant=<span class="hljs-string">"fp16"</span>, torch_dtype=torch.float16 | |
| <span class="hljs-meta">... </span>).to(<span class="hljs-string">"cuda"</span>) | |
| <span class="hljs-meta">>>> </span>image = diffusers.utils.load_image(<span class="hljs-string">"https://marigoldmonodepth.github.io/images/einstein.jpg"</span>) | |
| <span class="hljs-meta">>>> </span>intrinsics = pipe(image) | |
| <span class="hljs-meta">>>> </span>vis = pipe.image_processor.visualize_intrinsics(intrinsics.prediction, pipe.target_properties) | |
| <span class="hljs-meta">>>> </span>vis[<span class="hljs-number">0</span>][<span class="hljs-string">"albedo"</span>].save(<span class="hljs-string">"einstein_albedo.png"</span>) | |
| <span class="hljs-meta">>>> </span>vis[<span class="hljs-number">0</span>][<span class="hljs-string">"roughness"</span>].save(<span class="hljs-string">"einstein_roughness.png"</span>) | |
| <span class="hljs-meta">>>> </span>vis[<span class="hljs-number">0</span>][<span class="hljs-string">"metallicity"</span>].save(<span class="hljs-string">"einstein_metallicity.png"</span>)`,lang:"py",wrap:!1}),p(a,l)},$$slots:{default:!0}});var ve=e(he,2);u(ve,{anchor:"diffusers.MarigoldIntrinsicsPipeline.__call__.example-2",children:(a,d)=>{t(a,{code:"aW1wb3J0JTIwZGlmZnVzZXJzJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlJTIwJTNEJTIwZGlmZnVzZXJzLk1hcmlnb2xkSW50cmluc2ljc1BpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJwcnMtZXRoJTJGbWFyaWdvbGQtaWlkLWxpZ2h0aW5nLXYxLTElMjIlMkMlMjB2YXJpYW50JTNEJTIyZnAxNiUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFpbWFnZSUyMCUzRCUyMGRpZmZ1c2Vycy51dGlscy5sb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGbWFyaWdvbGRtb25vZGVwdGguZ2l0aHViLmlvJTJGaW1hZ2VzJTJGZWluc3RlaW4uanBnJTIyKSUwQWludHJpbnNpY3MlMjAlM0QlMjBwaXBlKGltYWdlKSUwQSUwQXZpcyUyMCUzRCUyMHBpcGUuaW1hZ2VfcHJvY2Vzc29yLnZpc3VhbGl6ZV9pbnRyaW5zaWNzKGludHJpbnNpY3MucHJlZGljdGlvbiUyQyUyMHBpcGUudGFyZ2V0X3Byb3BlcnRpZXMpJTBBdmlzJTVCMCU1RCU1QiUyMmFsYmVkbyUyMiU1RC5zYXZlKCUyMmVpbnN0ZWluX2FsYmVkby5wbmclMjIpJTBBdmlzJTVCMCU1RCU1QiUyMnNoYWRpbmclMjIlNUQuc2F2ZSglMjJlaW5zdGVpbl9zaGFkaW5nLnBuZyUyMiklMEF2aXMlNUIwJTVEJTVCJTIycmVzaWR1YWwlMjIlNUQuc2F2ZSglMjJlaW5zdGVpbl9yZXNpZHVhbC5wbmclMjIp",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> diffusers | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span>pipe = diffusers.MarigoldIntrinsicsPipeline.from_pretrained( | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"prs-eth/marigold-iid-lighting-v1-1"</span>, variant=<span class="hljs-string">"fp16"</span>, torch_dtype=torch.float16 | |
| <span class="hljs-meta">... </span>).to(<span class="hljs-string">"cuda"</span>) | |
| <span class="hljs-meta">>>> </span>image = diffusers.utils.load_image(<span class="hljs-string">"https://marigoldmonodepth.github.io/images/einstein.jpg"</span>) | |
| <span class="hljs-meta">>>> </span>intrinsics = pipe(image) | |
| <span class="hljs-meta">>>> </span>vis = pipe.image_processor.visualize_intrinsics(intrinsics.prediction, pipe.target_properties) | |
| <span class="hljs-meta">>>> </span>vis[<span class="hljs-number">0</span>][<span class="hljs-string">"albedo"</span>].save(<span class="hljs-string">"einstein_albedo.png"</span>) | |
| <span class="hljs-meta">>>> </span>vis[<span class="hljs-number">0</span>][<span class="hljs-string">"shading"</span>].save(<span class="hljs-string">"einstein_shading.png"</span>) | |
| <span class="hljs-meta">>>> </span>vis[<span class="hljs-number">0</span>][<span class="hljs-string">"residual"</span>].save(<span class="hljs-string">"einstein_residual.png"</span>)`,lang:"py",wrap:!1})},$$slots:{default:!0}}),i(me),i(J);var w=e(J,2),Ze=o(w);s(Ze,{name:"class diffusers.pipelines.marigold.MarigoldIntrinsicsOutput",anchor:"diffusers.pipelines.marigold.MarigoldIntrinsicsOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/marigold/pipeline_marigold_intrinsics.py#L96",parameters:[{name:"prediction",val:": typing.Union[numpy.ndarray, torch.Tensor]"},{name:"uncertainty",val:": typing.Union[NoneType, numpy.ndarray, torch.Tensor]"},{name:"latent",val:": typing.Optional[torch.Tensor]"}],parametersDescription:[{anchor:"diffusers.pipelines.marigold.MarigoldIntrinsicsOutput.prediction",description:`<strong>prediction</strong> (<code>np.ndarray</code>, <code>torch.Tensor</code>) — | |
| Predicted image intrinsics with values in the range [0, 1]. The shape is <code>(numimages * numtargets) × 3 × height × width</code> for <code>torch.Tensor</code> or <code>(numimages * numtargets) × height × width × 3</code> for <code>np.ndarray</code>, | |
| where <code>numtargets</code> corresponds to the number of predicted target modalities of the intrinsic image | |
| decomposition.`,name:"prediction"},{anchor:"diffusers.pipelines.marigold.MarigoldIntrinsicsOutput.uncertainty",description:`<strong>uncertainty</strong> (<code>None</code>, <code>np.ndarray</code>, <code>torch.Tensor</code>) — | |
| Uncertainty maps computed from the ensemble, with values in the range [0, 1]. The shape is <code>(numimages * numtargets) × 3 × height × width</code> for <code>torch.Tensor</code> or <code>(numimages * numtargets) × height × width × 3</code> for | |
| <code>np.ndarray</code>.`,name:"uncertainty"},{anchor:"diffusers.pipelines.marigold.MarigoldIntrinsicsOutput.latent",description:`<strong>latent</strong> (<code>None</code>, <code>torch.Tensor</code>) — | |
| Latent features corresponding to the predictions, compatible with the <code>latents</code> argument of the pipeline. | |
| The shape is <code>(numimages * numensemble) × (numtargets * 4) × latentheight × latentwidth</code>.`,name:"latent"}]}),r(2),i(w);var T=e(w,2),je=o(T);s(je,{name:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_intrinsics",anchor:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_intrinsics",source:"https://github.com/huggingface/diffusers/blob/vr_14178/src/diffusers/pipelines/marigold/marigold_image_processing.py#L542",parameters:[{name:"prediction",val:": typing.Union[numpy.ndarray, torch.Tensor, list[numpy.ndarray], list[torch.Tensor]]"},{name:"target_properties",val:": dict"},{name:"color_map",val:": str | dict[str, str] = 'binary'"}],parametersDescription:[{anchor:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_intrinsics.prediction",description:`<strong>prediction</strong> (<code>np.ndarray | torch.Tensor | list[np.ndarray, list[torch.Tensor]]</code>) — | |
| Intrinsic image decomposition.`,name:"prediction"},{anchor:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_intrinsics.target_properties",description:`<strong>target_properties</strong> (<code>dict[str, Any]</code>) — | |
| Decomposition properties. Expected entries: <code>target_names: list[str]</code> and a dictionary with keys | |
| <code>prediction_space: str</code>, <code>sub_target_names: list[str | Null]</code> (must have 3 entries, null for missing | |
| modalities), <code>up_to_scale: bool</code>, one for each target and sub-target.`,name:"target_properties"},{anchor:"diffusers.pipelines.marigold.MarigoldImageProcessor.visualize_intrinsics.color_map",description:`<strong>color_map</strong> (<code>str | dict[str, str]</code>, <em>optional</em>, defaults to <code>"Spectral"</code>) — | |
| Color map used to convert a single-channel predictions into colored representations. When a dictionary | |
| is passed, each modality can be colored with its own color map.`,name:"color_map"}]}),r(4),i(T);var Ie=e(T,2);Ne(Ie,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/marigold.md"}),r(2),p(ge,j),Xe()}export{Ae as component}; | |
Xet Storage Details
- Size:
- 123 kB
- Xet hash:
- 32a2341601fb2c750ac394ccdcfa75ec73ac38689a0a15795a272096d8d8647f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.