Skip to content

Commit

Permalink
Merge branch 'main' into cuda-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
abe-winter committed Oct 29, 2024
2 parents b89cc04 + 7a3be1d commit 53b7ca3
Show file tree
Hide file tree
Showing 217 changed files with 407 additions and 15,601 deletions.
1 change: 0 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
brew install x264
brew install jpeg-turbo
brew install ffmpeg
brew install tensorflowlite # Needs to be last
- name: build
run: go build ./web/cmd/server
- uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ jobs:
--platform linux/arm/v7 \
-v `pwd`:/rdk \
ghcr.io/viamrobotics/rdk-devenv:armhf-cache \
sudo -Hu testbot bash -lc 'sudo apt-get install -y python3-venv && cd /rdk && go test -v -tags=no_tflite ./...'
sudo -Hu testbot bash -lc 'sudo apt-get install -y python3-venv && cd /rdk && go test -v ./...'
motion_tests:
name: Test Longer-running Motion Plans if affected
Expand Down
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ TAG_VERSION?=$(shell git tag --points-at | sort -Vr | head -n1)
DATE_COMPILED?=$(shell date +'%Y-%m-%d')
COMMON_LDFLAGS = -s -w -X 'go.viam.com/rdk/config.Version=${TAG_VERSION}' -X 'go.viam.com/rdk/config.GitRevision=${GIT_REVISION}' -X 'go.viam.com/rdk/config.DateCompiled=${DATE_COMPILED}'
LDFLAGS = -ldflags "-extld=$(shell pwd)/etc/ld_wrapper.sh $(COMMON_LDFLAGS)"
ifeq ($(shell command -v dpkg >/dev/null && dpkg --print-architecture),armhf)
GOFLAGS += -tags=no_tflite
endif

default: build lint server

Expand Down
1 change: 0 additions & 1 deletion android.make
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ droid-rdk.%.aar: etc/android/prefix/aarch64 etc/android/prefix/x86_64
mkdir -p droidtmp/jni/$(JNI_ARCH)
cp -d etc/android/prefix/$(CPU_ARCH)/lib/*.so* droidtmp/jni/$(JNI_ARCH)
cd droidtmp && zip --symlinks -r ../$@ jni/$(JNI_ARCH)
cd ./services/mlmodel/tflitecpu/android/ && zip --symlinks -r ../../../../$@ jni/$(JNI_ARCH)

droid-rdk.aar: droid-rdk.amd64.aar droid-rdk.arm64.aar
# multi-platform AAR -- twice the size, but portable
Expand Down
29 changes: 6 additions & 23 deletions components/camera/transformpipeline/classifier_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build !no_tflite

package transformpipeline

import (
Expand All @@ -17,7 +15,6 @@ import (
"go.viam.com/rdk/rimage"
"go.viam.com/rdk/robot"
robotimpl "go.viam.com/rdk/robot/impl"
"go.viam.com/rdk/services/mlmodel"
_ "go.viam.com/rdk/services/mlmodel/register"
"go.viam.com/rdk/services/vision"
_ "go.viam.com/rdk/services/vision/register"
Expand All @@ -28,25 +25,11 @@ func buildRobotWithClassifier(logger logging.Logger) (robot.Robot, error) {
cfg := &config.Config{}

// create fake source camera
tfliteSrv1 := resource.Config{
Name: "object_classifier",
API: mlmodel.API,
Model: resource.DefaultModelFamily.WithModel("tflite_cpu"),
Attributes: rutils.AttributeMap{
"model_path": artifact.MustPath("vision/classification/object_classifier.tflite"),
"label_path": artifact.MustPath("vision/classification/object_labels.txt"),
"num_threads": 1,
},
}
cfg.Services = append(cfg.Services, tfliteSrv1)
visionSrv1 := resource.Config{
Name: "vision_classifier",
API: vision.API,
Model: resource.DefaultModelFamily.WithModel("mlmodel"),
Attributes: rutils.AttributeMap{
"mlmodel_name": "object_classifier",
},
DependsOn: []string{"object_classifier"},
Name: "vision_classifier",
API: vision.API,
Model: resource.DefaultModelFamily.WithModel("fake"),
Attributes: rutils.AttributeMap{},
}
cfg.Services = append(cfg.Services, visionSrv1)
cameraComp := resource.Config{
Expand Down Expand Up @@ -122,7 +105,7 @@ func TestClassifierSource(t *testing.T) {

// Max classifications was 5, but this image gets classified with just 2 labels, so we
// test that each label is present.
test.That(t, ovImg.GetXY(149, 48), test.ShouldResemble, rimage.Red)
test.That(t, ovImg.GetXY(100, 75), test.ShouldResemble, rimage.Red)
test.That(t, ovImg.GetXY(42, 50), test.ShouldResemble, rimage.Red)
test.That(t, ovImg.GetXY(268, 48), test.ShouldResemble, rimage.Red)
test.That(t, classifier.Close(context.Background()), test.ShouldBeNil)
}
89 changes: 0 additions & 89 deletions components/camera/transformpipeline/detector_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build !no_tflite

package transformpipeline

import (
Expand All @@ -18,7 +16,6 @@ import (
"go.viam.com/rdk/rimage"
"go.viam.com/rdk/robot"
robotimpl "go.viam.com/rdk/robot/impl"
"go.viam.com/rdk/services/mlmodel"
_ "go.viam.com/rdk/services/mlmodel/register"
"go.viam.com/rdk/services/vision"
_ "go.viam.com/rdk/services/vision/register"
Expand Down Expand Up @@ -64,27 +61,6 @@ func buildRobotWithFakeCamera(logger logging.Logger) (robot.Robot, error) {
},
}
cfg.Services = append(cfg.Services, colorSrv1)
tfliteSrv2 := resource.Config{
Name: "detector_tflite",
API: mlmodel.API,
Model: resource.DefaultModelFamily.WithModel("tflite_cpu"),
Attributes: rutils.AttributeMap{
"model_path": artifact.MustPath("vision/tflite/effdet0.tflite"),
"label_path": artifact.MustPath("vision/tflite/effdetlabels.txt"),
"num_threads": 1,
},
}
cfg.Services = append(cfg.Services, tfliteSrv2)
visionSrv2 := resource.Config{
Name: "vision_detector",
API: vision.API,
Model: resource.DefaultModelFamily.WithModel("mlmodel"),
Attributes: rutils.AttributeMap{
"mlmodel_name": "detector_tflite",
},
DependsOn: []string{"detector_tflite"},
}
cfg.Services = append(cfg.Services, visionSrv2)
cameraComp := resource.Config{
Name: "fake_cam",
API: camera.API,
Expand Down Expand Up @@ -115,26 +91,6 @@ func buildRobotWithFakeCamera(logger logging.Logger) (robot.Robot, error) {
DependsOn: []string{"fake_cam"},
}
cfg.Components = append(cfg.Components, detectorComp)
// create 2nd fake detector camera
tfliteComp := resource.Config{
Name: "tflite_detect",
API: camera.API,
Model: resource.DefaultModelFamily.WithModel("transform"),
Attributes: rutils.AttributeMap{
"source": "fake_cam",
"pipeline": []rutils.AttributeMap{
{
"type": "detections",
"attributes": rutils.AttributeMap{
"detector_name": "vision_detector",
"confidence_threshold": 0.35,
},
},
},
},
DependsOn: []string{"fake_cam"},
}
cfg.Components = append(cfg.Components, tfliteComp)
if err := cfg.Ensure(false, logger); err != nil {
return nil, err
}
Expand Down Expand Up @@ -173,29 +129,6 @@ func TestColorDetectionSource(t *testing.T) {
test.That(t, detector.Close(context.Background()), test.ShouldBeNil)
}

func TestTFLiteDetectionSource(t *testing.T) {
logger := logging.NewTestLogger(t)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

r, err := buildRobotWithFakeCamera(logger)
defer func() {
test.That(t, r.Close(context.Background()), test.ShouldBeNil)
}()
test.That(t, err, test.ShouldBeNil)

detector, err := camera.FromRobot(r, "tflite_detect")
test.That(t, err, test.ShouldBeNil)
defer detector.Close(ctx)

resImg, _, err := camera.ReadImage(ctx, detector)
test.That(t, err, test.ShouldBeNil)
ovImg := rimage.ConvertImage(resImg)
test.That(t, ovImg.GetXY(624, 402), test.ShouldResemble, rimage.Red)
test.That(t, ovImg.GetXY(815, 647), test.ShouldResemble, rimage.Red)
test.That(t, detector.Close(context.Background()), test.ShouldBeNil)
}

func BenchmarkColorDetectionSource(b *testing.B) {
logger := logging.NewTestLogger(b)
ctx, cancel := context.WithCancel(context.Background())
Expand All @@ -217,25 +150,3 @@ func BenchmarkColorDetectionSource(b *testing.B) {
}
test.That(b, detector.Close(context.Background()), test.ShouldBeNil)
}

func BenchmarkTFLiteDetectionSource(b *testing.B) {
logger := logging.NewTestLogger(b)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

r, err := buildRobotWithFakeCamera(logger)
defer func() {
test.That(b, r.Close(context.Background()), test.ShouldBeNil)
}()
test.That(b, err, test.ShouldBeNil)
detector, err := camera.FromRobot(r, "tflite_detect")
test.That(b, err, test.ShouldBeNil)
defer detector.Close(ctx)

b.ResetTimer()
// begin benchmarking
for i := 0; i < b.N; i++ {
_, _, _ = camera.ReadImage(ctx, detector)
}
test.That(b, detector.Close(context.Background()), test.ShouldBeNil)
}
1 change: 0 additions & 1 deletion components/motor/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
_ "go.viam.com/rdk/components/motor/gpio"
_ "go.viam.com/rdk/components/motor/gpiostepper"
_ "go.viam.com/rdk/components/motor/i2cmotors"
_ "go.viam.com/rdk/components/motor/roboclaw"
_ "go.viam.com/rdk/components/motor/tmcstepper"
_ "go.viam.com/rdk/components/motor/ulnstepper"
)
Loading

0 comments on commit 53b7ca3

Please sign in to comment.