Socket
Socket
Sign inDemoInstall

@tensorflow-models/depth-estimation

Package Overview
Dependencies
1
Maintainers
9
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @tensorflow-models/depth-estimation

Pretrained depth model


Version published
Weekly downloads
5
decreased by-64.29%
Maintainers
9
Install size
822 kB
Created
Weekly downloads
 

Readme

Source

Depth Estimation

This package provides models for running depth estimation in TensorFlow.js.

Currently, we provide 1 model option:

AR Portrait Depth API

This AR portrait depth model estimates per-pixel depth (the distance to the camera center) for a single portrait image, which can be further used for creative applications. (See DepthLab for potential applications).

For example, the following demo transforms a single 2D RGB image into a 3D Portrait: 3D Photo Demo


Table of Contents


How to Run It

There are two steps to run the AR portrait depth API:

First, you create an estimator by choosing one of the models from SupportedModels.

For example:

const model = depthEstimation.SupportedModels.ARPortraitDepth;
const estimator = await depthEstimation.createEstimator(model);

Next, you can use the estimator to estimate depth.

const estimationConfig = {
  minDepth: 0,
  maxDepth: 1,
}
const depthMap = await estimator.estimateDepth(image, estimationConfig);

The returned depth map contains depth values for each pixel in the image.

Example output:

{
  toCanvasImageSource(): ...
  toArray(): ...
  toTensor(): ...
  getUnderlyingType(): ...
}

The output provides access to the underlying depth values using the conversion functions toCanvasImageSource, toArray, and toTensor depending on the desired output type. Note that getUnderlyingType can be queried to determine what is the type being used underneath the hood to avoid expensive conversions (such as from tensor to image data).

Refer to each model's documentation for specific configurations for the model and their performance.

ARPortraitDepth Documentation


Example Code and Demos

You may reference the demos for code examples. Details for how to run the demos are included in the demos/ folder.

FAQs

Last updated on 22 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc