googlecreativelab / teachablemachine-community

Example code snippets and machine learning code for Teachable Machine
https://g.co/teachablemachine
Apache License 2.0
1.51k stars 678 forks source link

Knowing the details of the model trained #189

Open Ankit-Vohra opened 3 years ago

Ankit-Vohra commented 3 years ago

I'm using teachable to train a binary classifier, it is giving me some very good results so I exported the model and have deployed it. When I load the model and print model.summary() I'm only able to go through 2 sequential layers. image

Is there any way to identify the entire architecture of the model which is built on teachable that will be really helpful to those who want to dive deep into the model. Thanks

HalfdanJ commented 3 years ago

Which type of model are you training? (image/audio/pose)

Ankit-Vohra commented 3 years ago

I'm training a Binary image classification It's giving me very good accuracy so I want to know the entire architecture of the model I can share the teachable model file if required

On Mon, Apr 5, 2021, 7:51 PM Jonas Jongejan @.***> wrote:

Which type of model are you training? (image/audio/pose)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/googlecreativelab/teachablemachine-community/issues/189#issuecomment-813417863, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKRUWNW4BLGFUGUVNLNS3ZTTHHBM3ANCNFSM42MOSSLQ .

HalfdanJ commented 3 years ago

The model is standard Mobilenet v2 without tops, and then an added a new top layer for the custom transfer learning. https://github.com/googlecreativelab/teachablemachine-community/blob/master/libraries/image/src/custom-mobilenet.ts#L303

yo80106 commented 3 years ago

Hi, I am also interested in knowing more about the base model in Teachable Machine. I am wondering that how did you shrink down the size of mobilenet v2? I used "tf.keras.applications.mobilenet_v2.MobileNetV2" to import the MobileNet 2; however the total parameters is over 2 millions. Also, I think MobileNet is expected to accept the image in 3 channels (RGB), how did you make it to adapt grayscale images? Thank you in advance.

HalfdanJ commented 3 years ago

The model we load is an unmodified version of mobilenet v2 with alpha 0.35, image size 224. The model takes rgb. Then after truncaing the top layer, all we do is adding globalAveragePooling2d to the model in the code linked above.

To convert to keras, we are using the tensorflowjs commandline utility, I dont know what that does in its internals, but I think it should just do a 1:1 conversion.

ansariahmad commented 1 year ago

@Ankit-Vohra Use this code model.summary(expand_nested=True)