-
Notifications
You must be signed in to change notification settings - Fork 113
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
RSDK-2380 Check if labels file is split by spaces or commas #2178
Conversation
classifications, err := unpackClassificationTensor(ctx, outTensor, model, labels) | ||
if err != nil { | ||
logger.Error(err) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
…ls do not match outputs
There was a problem hiding this 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
// 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], ",") | ||
} |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
…d texgt & necessary files
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice LGTM!
No description provided.