Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-2380 Check if labels file is split by spaces or commas #2178

Conversation

kim-mishra
Copy link
Contributor

No description provided.

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Apr 6, 2023
classifications, err := unpackClassificationTensor(ctx, outTensor, model, labels)
if err != nil {
logger.Error(err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the best way to surface this error to the user? Logging it here logs it over and over and over again, but just returning the error doesn't seem to surface it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this function that gets returned will run every time an image gets classified. My first thought is that if we hate that, maybe try a logger.Fatal() which will kill everything after printing it out once. If that seems like overkill, maybe only fatal depending on the type of error. Either way it seems like don't want to keep on trying to classify this over and over again if we're definitely not unpacking the tensors correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm the linter complains about logger.Fatal, do you know of a workaround?

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Apr 6, 2023
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Apr 6, 2023
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Apr 6, 2023
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Apr 6, 2023
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Apr 6, 2023
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Apr 6, 2023
Copy link
Member

@bhaney bhaney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Just one rearranging of lines, and one test to add

Comment on lines 420 to 427
// if the labels come out as one line, try splitting that line by spaces or commas to extract labels
if len(labels) == 1 {
labels = strings.Split(labels[0], " ")
}

if len(labels) == 1 {
labels = strings.Split(labels[0], ",")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's try a comma-split first, before the space-split. I'm thinking about the case where someone has the label "stop sign", and it gets split on line 422, before 426 is attempted. Also, I think people often put spaces after their commas, so the space-split may grab commas and put them in the label string that would show up in the overlay.

@@ -254,3 +255,23 @@ func TestMoreClassifierModels(t *testing.T) {
test.That(t, bestClass[0].Label(), test.ShouldResemble, "292")
test.That(t, bestClass[0].Score(), test.ShouldBeGreaterThan, 0.93)
}

func TestInvalidLabels(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a test of it successfully unpacking a label file where all the labels are on one string, comma separated?

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Apr 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2023

Code Coverage

Package Line Rate Delta Health
go.viam.com/rdk/components/arm 64% 0.00%
go.viam.com/rdk/components/arm/fake 30% 0.00%
go.viam.com/rdk/components/arm/universalrobots 42% 0.00%
go.viam.com/rdk/components/arm/wrapper 20% 0.00%
go.viam.com/rdk/components/arm/xarm 6% 0.00%
go.viam.com/rdk/components/arm/yahboom 6% 0.00%
go.viam.com/rdk/components/audioinput 53% 0.00%
go.viam.com/rdk/components/base 61% 0.00%
go.viam.com/rdk/components/base/agilex 62% 0.00%
go.viam.com/rdk/components/base/boat 41% 0.00%
go.viam.com/rdk/components/base/wheeled 76% 0.00%
go.viam.com/rdk/components/board 65% 0.00%
go.viam.com/rdk/components/board/arduino 10% 0.00%
go.viam.com/rdk/components/board/fake 38% 0.00%
go.viam.com/rdk/components/board/genericlinux 23% 0.00%
go.viam.com/rdk/components/board/numato 19% 0.00%
go.viam.com/rdk/components/board/pi 50% 0.00%
go.viam.com/rdk/components/camera 64% -0.25%
go.viam.com/rdk/components/camera/align 64% 0.00%
go.viam.com/rdk/components/camera/fake 71% 0.00%
go.viam.com/rdk/components/camera/ffmpeg 77% +1.43%
go.viam.com/rdk/components/camera/rtsp 44% 0.00%
go.viam.com/rdk/components/camera/transformpipeline 78% 0.00%
go.viam.com/rdk/components/camera/videosource 34% 0.00%
go.viam.com/rdk/components/encoder 15% 0.00%
go.viam.com/rdk/components/encoder/fake 76% 0.00%
go.viam.com/rdk/components/gantry 58% 0.00%
go.viam.com/rdk/components/gantry/multiaxis 85% 0.00%
go.viam.com/rdk/components/gantry/oneaxis 86% 0.00%
go.viam.com/rdk/components/generic 82% 0.00%
go.viam.com/rdk/components/gripper 67% 0.00%
go.viam.com/rdk/components/input 86% 0.00%
go.viam.com/rdk/components/input/fake 86% 0.00%
go.viam.com/rdk/components/input/gpio 84% 0.00%
go.viam.com/rdk/components/motor 76% 0.00%
go.viam.com/rdk/components/motor/dimensionengineering 63% 0.00%
go.viam.com/rdk/components/motor/dmc4000 69% 0.00%
go.viam.com/rdk/components/motor/fake 56% 0.00%
go.viam.com/rdk/components/motor/gpio 66% +0.41%
go.viam.com/rdk/components/motor/gpiostepper 54% 0.00%
go.viam.com/rdk/components/motor/tmcstepper 62% 0.00%
go.viam.com/rdk/components/motor/ulnstepper 52% 0.00%
go.viam.com/rdk/components/movementsensor 74% 0.00%
go.viam.com/rdk/components/movementsensor/adxl345 66% 0.00%
go.viam.com/rdk/components/movementsensor/cameramono 45% 0.00%
go.viam.com/rdk/components/movementsensor/gpsnmea 36% 0.00%
go.viam.com/rdk/components/movementsensor/gpsrtk 29% 0.00%
go.viam.com/rdk/components/movementsensor/mpu6050 83% 0.00%
go.viam.com/rdk/components/posetracker 84% 0.00%
go.viam.com/rdk/components/sensor 66% 0.00%
go.viam.com/rdk/components/sensor/ultrasonic 31% 0.00%
go.viam.com/rdk/components/servo 66% 0.00%
go.viam.com/rdk/components/servo/gpio 71% 0.00%
go.viam.com/rdk/config 78% 0.00%
go.viam.com/rdk/control 57% 0.00%
go.viam.com/rdk/data 77% 0.00%
go.viam.com/rdk/examples/customresources/demos/remoteserver 0% 0.00%
go.viam.com/rdk/grpc 25% 0.00%
go.viam.com/rdk/ml 67% 0.00%
go.viam.com/rdk/ml/inference 70% 0.00%
go.viam.com/rdk/module 67% 0.00%
go.viam.com/rdk/module/modmanager 80% 0.00%
go.viam.com/rdk/motionplan 71% -0.05%
go.viam.com/rdk/operation 82% 0.00%
go.viam.com/rdk/pointcloud 69% 0.00%
go.viam.com/rdk/protoutils 49% 0.00%
go.viam.com/rdk/referenceframe 72% 0.00%
go.viam.com/rdk/registry 83% 0.00%
go.viam.com/rdk/resource 84% 0.00%
go.viam.com/rdk/rimage 78% 0.00%
go.viam.com/rdk/rimage/depthadapter 94% 0.00%
go.viam.com/rdk/rimage/transform 75% 0.00%
go.viam.com/rdk/rimage/transform/cmd/extrinsic_calibration 67% 0.00%
go.viam.com/rdk/robot 86% 0.00%
go.viam.com/rdk/robot/client 82% 0.00%
go.viam.com/rdk/robot/framesystem 65% 0.00%
go.viam.com/rdk/robot/impl 82% +0.19%
go.viam.com/rdk/robot/packages 80% 0.00%
go.viam.com/rdk/robot/server 53% 0.00%
go.viam.com/rdk/robot/web 64% 0.00%
go.viam.com/rdk/robot/web/stream 87% 0.00%
go.viam.com/rdk/services/baseremotecontrol 71% 0.00%
go.viam.com/rdk/services/baseremotecontrol/builtin 78% 0.00%
go.viam.com/rdk/services/datamanager 75% 0.00%
go.viam.com/rdk/services/datamanager/builtin 84% -0.44%
go.viam.com/rdk/services/datamanager/datacapture 73% 0.00%
go.viam.com/rdk/services/datamanager/datasync 0% 0.00%
go.viam.com/rdk/services/motion 62% 0.00%
go.viam.com/rdk/services/motion/builtin 88% 0.00%
go.viam.com/rdk/services/navigation 54% 0.00%
go.viam.com/rdk/services/sensors 74% 0.00%
go.viam.com/rdk/services/sensors/builtin 97% 0.00%
go.viam.com/rdk/services/shell 25% 0.00%
go.viam.com/rdk/services/slam 84% 0.00%
go.viam.com/rdk/services/slam/builtin 74% 0.00%
go.viam.com/rdk/services/slam/fake 90% 0.00%
go.viam.com/rdk/services/slam/slam_copy/config 97% 0.00%
go.viam.com/rdk/services/slam/slam_copy/dataprocess 71% 0.00%
go.viam.com/rdk/services/slam/slam_copy/utils 100% 0.00%
go.viam.com/rdk/services/vision 79% 0.00%
go.viam.com/rdk/services/vision/builtin 74% +0.10%
go.viam.com/rdk/session 97% 0.00%
go.viam.com/rdk/spatialmath 84% 0.00%
go.viam.com/rdk/subtype 92% 0.00%
go.viam.com/rdk/utils 72% -0.18%
go.viam.com/rdk/vision 26% 0.00%
go.viam.com/rdk/vision/chess 80% 0.00%
go.viam.com/rdk/vision/delaunay 87% 0.00%
go.viam.com/rdk/vision/keypoints 92% 0.00%
go.viam.com/rdk/vision/objectdetection 82% 0.00%
go.viam.com/rdk/vision/odometry 60% 0.00%
go.viam.com/rdk/vision/odometry/cmd 0% 0.00%
go.viam.com/rdk/vision/segmentation 49% 0.00%
go.viam.com/rdk/web/server 26% 0.00%
Summary 66% (22858 / 34897) 0.00%

@kim-mishra kim-mishra requested a review from bhaney April 7, 2023 15:04
Copy link
Member

@bhaney bhaney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@kharijarrett kharijarrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice LGTM!

@kim-mishra kim-mishra merged commit c9ff68f into viamrobotics:main Apr 10, 2023
@kim-mishra kim-mishra deleted the RSDK-2380-invalid-label-file-causes-panic branch April 10, 2023 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants