mirror of
https://github.com/mudler/LocalAI.git
synced 2026-06-14 11:49:33 -04:00
* feat(backend): add locate-anything-cpp backend (open-vocab detection via la_capi) A Go/purego backend wrapping locate-anything.cpp's la_capi C ABI, implementing the gRPC Detect RPC: image + open-vocabulary text prompt -> labeled boxes. Mirrors backend/go/rfdetr-cpp; static-links ggml into a per-CPU-variant .so. Assisted-by: Claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * ci(backend): register locate-anything-cpp in build matrix Assisted-by: Claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(gallery): locate-anything gallery entry + model importer Assisted-by: Claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * test(backend): locate-anything-cpp Load+Detect wire test Assisted-by: Claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat(gallery): add locate-anything-3b model to the gallery index Assisted-by: Claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * ci(backend): register locate-anything.cpp in bump_deps auto-bump Assisted-by: Claude:claude-opus-4-8 [Claude Code] Signed-off-by: mudler <mudler@localai.io> * ci(test): e2e smoke for locate-anything-cpp in test-extra (loads the 3B + image, runs Detect) Assisted-by: Claude:claude-opus-4-8 [Claude Code] Signed-off-by: mudler <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Signed-off-by: mudler <mudler@localai.io> Co-authored-by: mudler <mudler@localai.io>
60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
package main
|
|
|
|
// main.go - entry point for the locate-anything-cpp gRPC backend.
|
|
//
|
|
// Dlopens liblocateanythingcpp-<variant>.so via purego at the path in
|
|
// LOCATEANYTHING_LIBRARY (set by run.sh based on /proc/cpuinfo), registers
|
|
// the la_capi_* C ABI symbols, then starts the gRPC server.
|
|
|
|
import (
|
|
"flag"
|
|
"os"
|
|
|
|
"github.com/ebitengine/purego"
|
|
grpc "github.com/mudler/LocalAI/pkg/grpc"
|
|
)
|
|
|
|
var (
|
|
addr = flag.String("addr", "localhost:50051", "the address to connect to")
|
|
)
|
|
|
|
type LibFuncs struct {
|
|
FuncPtr any
|
|
Name string
|
|
}
|
|
|
|
func main() {
|
|
// Get library name from environment variable, default to fallback
|
|
libName := os.Getenv("LOCATEANYTHING_LIBRARY")
|
|
if libName == "" {
|
|
libName = "./liblocateanythingcpp-fallback.so"
|
|
}
|
|
|
|
lib, err := purego.Dlopen(libName, purego.RTLD_NOW|purego.RTLD_GLOBAL)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
libFuncs := []LibFuncs{
|
|
{&CapiLoad, "la_capi_load"},
|
|
{&CapiFree, "la_capi_free"},
|
|
{&CapiLocatePath, "la_capi_locate_path"},
|
|
{&CapiLocateBuffer, "la_capi_locate_buffer"},
|
|
{&CapiGetNDetections, "la_capi_get_n_detections"},
|
|
{&CapiGetDetectionBox, "la_capi_get_detection_box"},
|
|
{&CapiGetDetectionLabel, "la_capi_get_detection_label"},
|
|
{&CapiFreeString, "la_capi_free_string"},
|
|
{&CapiLastError, "la_capi_last_error"},
|
|
}
|
|
|
|
for _, lf := range libFuncs {
|
|
purego.RegisterLibFunc(lf.FuncPtr, lib, lf.Name)
|
|
}
|
|
|
|
flag.Parse()
|
|
|
|
if err := grpc.StartServer(*addr, &LocateAnythingCpp{}); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|