Conversation
…animl-api into feature/gen-validation-lists
| 'objects.labels.labelId': { | ||
| $in: projectLabelIds | ||
| }, | ||
| 'objects.labels.validation.validated': true, |
| }, | ||
| }, | ||
| { | ||
| $set: { |
There was a problem hiding this comment.
Can you remind me what you're trying to do here with there $seting of the Image.filteredLabels field?
| }, {}); | ||
| const projectLabelIds = Object.keys(projectLabels); | ||
|
|
||
| // Prepare map { labelId: [validatingLabelId] } |
There was a problem hiding this comment.
This map should match the shape of the existing TARGET_CLASS array in the analysisConfig.js`, right? See example entry copied into the comment above.
| const labelIds = obj.filteredLabels.map((lbl) => lbl.labelId); | ||
| const firstValidLabelId = obj.firstValidLabel.shift().labelId; | ||
| const curr = validatingLabels[firstValidLabelId]; | ||
| validatingLabels[firstValidLabelId] = new Set([...curr, ...labelIds]); |
There was a problem hiding this comment.
I'm having a little trouble understanding this. Seems a little odd to use a reducer here. You're both dropping in validatingLabels as an initial value (132) then referencing it and manipulating the out-of-scope variable from within the reducer loop? But then returning the imageAcc after each run of the reducer function (131)? Then I kind of assume is what the reduce() returns and assigns imageAcc to validationLists once it's iterated over all the images? Maybe I'm not tracking or something but I think this could be accomplished with a simple forEach loop:
const validatingLabels = projectLabelIds.reduce((acc, lbl) => {
return { ...acc, [lbl]: [] };
}, {});
images.forEach((img) => {
img.objects.forEach((obj) => {
...
validatingLabels[firstValidLabelId] = new Set([...curr, ...labelIds]);
}
}|
|
||
| const labelIds = obj.filteredLabels.map((lbl) => lbl.labelId); | ||
| const firstValidLabelId = obj.firstValidLabel.shift().labelId; | ||
| const curr = validatingLabels[firstValidLabelId]; |
There was a problem hiding this comment.
I think this might be backwards. The firstValidLabel should be added to the array of validating labels, not used as the predicted label.
nathanielrindlaub
left a comment
There was a problem hiding this comment.
Just one small update and I think this is good to go!
| for await (const img of Image.aggregate(baseImagePipeline)) { | ||
| for (const obj of img.objects) { | ||
| const firstValidated = obj.firstValidLabel.shift(); | ||
| const predicted = obj.labels.find((lbl) => lbl.mlModel === MODEL); |
There was a problem hiding this comment.
We store all predicted labels above whatever the confidence threshold was set for that particular category, so we need to account for situations in which the model has returned two labels above the confidence threshold (i.e., more than one predicted label), rather than just grabbing the first.
Context
Attempts to build a validation list for ml labels. Takes an ML label, finds objects with that label, and builds a set of other labels on the objects. Some things to think about: