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

[WIP] Fix feature extractor examples #1086

Merged
merged 1 commit into from
Oct 28, 2020

Conversation

bomanimc
Copy link
Member

@bomanimc bomanimc commented Oct 22, 2020

Our FeatureExtractor examples were breaking with the following error when I'd try to add samples for the model to use for training:

Error: Error when checking : expected input_1 to have shape [null,224,224,3] but got array with shape [1,480,480,3].

#191 introduced some logic that would make videos avoid resizing. Marking this as WIP because I'm not sure why the videos were ignored for resizing in that PR.

I also noticed that it seems that we get some odd behavior when we pass in numerical values as strings into the model. Our JS example passed in strings that broke the mapping the example was expecting .

After the changes, both the p5.js and JS versions of FeatureExtractor_Image_Classification of FeatureExtractor_Image_Regression seem to be working well!

Copy link
Member

@shiffman shiffman left a comment

Choose a reason for hiding this comment

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

Looks great, one small comment but it's minor and fine to keep as is!

@@ -71,7 +71,7 @@ function setupButtons() {
// When the Dog button is pressed, add the current frame
// from the video with a label of "dog" to the classifier
document.querySelector("#addSample").addEventListener("click", function() {
regressor.addImage(slider.value);
regressor.addImage(parseFloat(slider.value));
Copy link
Member

Choose a reason for hiding this comment

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

Should we handle this internally in ml5? I don't feel strongly but we could do this conversion there since passing in a string label is not compatible with regression!

Copy link
Member Author

Choose a reason for hiding this comment

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

I was wondering about this too. The best logic I could consider is changing any values that seem numeric into a numeric value instead of a string label.

Are string labels really not compatible? It seems like there might be some code in the model for associating string levels to some of the regression outputs. I'll open an issue to come back to this!

Copy link
Member Author

@bomanimc bomanimc Oct 26, 2020

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Great question! The concept of regression is quite broad, but in the case of ml5 and the way ml5.neuralNetwork() was designed, the only valid outputs are numeric. If it's a string then by definition (at least in the case of ml5) it's a classification. I'm open to rethinking this of course!

@bomanimc
Copy link
Member Author

Looks like there may be some possibly valid test failures here. I'll take a closer look to see what may be happening.

@bomanimc
Copy link
Member Author

Test failures here we were related to #1093. Now that that has been temporarily addressed, I feel comfortable merging this in!

@bomanimc bomanimc merged commit 4ac6321 into main Oct 28, 2020
@bomanimc bomanimc deleted the bomani.fix-mobilenet-feature-extractor-on-main branch October 28, 2020 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants