MCPcopy
hub / github.com/mudler/LocalAI / Depth

Function Depth

core/backend/depth.go:19–66  ·  view source on GitHub ↗

Depth runs depth estimation (Depth Anything 3) on the supplied image and returns the full DepthResponse: per-pixel metric depth + confidence + sky, camera pose (extrinsics/intrinsics), an optional 3D point cloud and any requested exports (glb/colmap). The include_* flags and exports mirror the Depth

(
	ctx context.Context,
	in *proto.DepthRequest,
	loader *model.ModelLoader,
	appConfig *config.ApplicationConfig,
	modelConfig config.ModelConfig,
)

Source from the content-addressed store, hash-verified

17// requested exports (glb/colmap). The include_* flags and exports mirror the
18// DepthRequest proto so callers can ask for less work.
19func Depth(
20 ctx context.Context,
21 in *proto.DepthRequest,
22 loader *model.ModelLoader,
23 appConfig *config.ApplicationConfig,
24 modelConfig config.ModelConfig,
25) (*proto.DepthResponse, error) {
26 opts := ModelOptions(modelConfig, appConfig)
27 depthModel, err := loader.Load(opts...)
28 if err != nil {
29 recordModelLoadFailure(appConfig, modelConfig.Name, modelConfig.Backend, err, nil)
30 return nil, err
31 }
32
33 if depthModel == nil {
34 return nil, fmt.Errorf("could not load depth model")
35 }
36
37 var startTime time.Time
38 if appConfig.EnableTracing {
39 trace.InitBackendTracingIfEnabled(appConfig.TracingMaxItems, appConfig.TracingMaxBodyBytes)
40 startTime = time.Now()
41 }
42
43 res, err := depthModel.Depth(ctx, in)
44
45 if appConfig.EnableTracing {
46 errStr := ""
47 if err != nil {
48 errStr = err.Error()
49 }
50
51 trace.RecordBackendTrace(trace.BackendTrace{
52 Timestamp: startTime,
53 Duration: time.Since(startTime),
54 Type: trace.BackendTraceDepth,
55 ModelName: modelConfig.Name,
56 Backend: modelConfig.Backend,
57 Summary: trace.TruncateString(in.GetSrc(), 200),
58 Error: errStr,
59 Data: map[string]any{
60 "exports": in.GetExports(),
61 },
62 })
63 }
64
65 return res, err
66}

Callers 1

DepthEndpointFunction · 0.92

Calls 8

RecordBackendTraceFunction · 0.92
TruncateStringFunction · 0.92
ModelOptionsFunction · 0.85
recordModelLoadFailureFunction · 0.85
LoadMethod · 0.65
DepthMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected