这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 5, 2025

The README rust example was syntactically incorrect and used outdated API patterns.

Changes:

  • Added missing imports (burn::prelude::*, InferenceBackend)
  • Added device initialization with backend comment (NdArray with Cuda/Cpu alternatives)
  • Fixed load() call to include required device parameter
  • Replaced forward() with infer() method (correct inference API)
  • Added tensor shape comment [1, 3, H, W] for input
  • Documented output structure (result.depth, result.focallength_px) with types and shapes

Before:

use burn_depth::model::depth_pro::DepthPro;

let model = DepthPro::<InferenceBackend>::load("assets/model/depth_pro.mpk")?;
let depth = model.forward(input);

After:

use burn::prelude::*;
use burn_depth::{InferenceBackend, model::depth_pro::DepthPro};

// NdArray backend (alternatively: burn::backend::Cuda, burn::backend::Cpu)
let device = <InferenceBackend as Backend>::Device::default();

let model = DepthPro::<InferenceBackend>::load(&device, "assets/model/depth_pro.mpk")?;

// Image tensor with shape [1, 3, H, W] (batch, channels, height, width)
let input: Tensor<InferenceBackend, 4> = Tensor::zeros([1, 3, 512, 512], &device);

let result = model.infer(input, None);
// result.depth: Tensor<InferenceBackend, 3> with shape [1, H, W]
// result.focallength_px: Tensor<InferenceBackend, 1> with shape [1]
Original prompt

fix the readme rust example. keep it roughly the same simplicity (e.g. image tensor with correct shape comment), NdArray backend (with cuda/cpu backend comment), show the proper output type in the .forward return value


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Nov 5, 2025
Copilot AI and others added 2 commits November 5, 2025 02:08
Co-authored-by: mosure <35904762+mosure@users.noreply.github.com>
Co-authored-by: mosure <35904762+mosure@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix README example for Rust NdArray Fix README example: add missing imports, device parameter, and correct API usage Nov 5, 2025
Copilot AI requested a review from mosure November 5, 2025 02:11
Copilot finished work on behalf of mosure November 5, 2025 02:11
@mosure mosure marked this pull request as ready for review November 5, 2025 03:01
@mosure mosure changed the title Fix README example: add missing imports, device parameter, and correct API usage docs(example): add missing imports, device parameter, and correct API usage Nov 5, 2025
@mosure mosure merged commit 395f5d9 into main Nov 5, 2025
7 checks passed
@mosure mosure deleted the copilot/fix-readme-rust-example branch November 5, 2025 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants