apple / turicreate

Turi Create simplifies the development of custom machine learning models.
BSD 3-Clause "New" or "Revised" License
11.19k stars 1.14k forks source link

Allow User Defined Feature Extractors #3067

Open kuri54 opened 4 years ago

kuri54 commented 4 years ago

Is it possible to convert my own keras model (Fine-tuning a VGG16) to '.model'?

If use CoreMLTools, can convert it to '.mlmodel', but can't load_model with turicreate.

Let me know if you have any hands.

TobyRoseman commented 4 years ago

Sorry, we don't have any support for using Keras models in TuriCreate.

Can you give us a bit more details about what you are trying to do? Do you want to do image classification or image similarity using your own feature extractor (i.e. VGG16)?

kuri54 commented 4 years ago

Thanks for the reply.

The ability to easily create a learning model with simple coding without the need to try the hyperparameters needed to create an existing learning model is very attractive and amazing. With TuriCreate I can draw graphs without long coding, and I am very grateful.

Unfortunately, there are few types of trained models available.In the image classification of the field that I am studying, ResNet50 is too deep and does not provide much accuracy (about 85%). The VGG16 is more than 95% accurate, so I want to deploy that model to iOS.

TuriCreate does not have the Data Augment function of Keras. (It is implemented in CreateML) It is necessary to generate a large number of learning images with a self-made program, which takes a long time to read and consumes a large amount of memory.

Some may say that you can use Raspberry Pi or JetsonNano, but the big breakthrough in my research area is that it can be implemented on a smartphone.

However, TuriCreate requires “.model”, and CoreMLTools only supports conversion to “.mlmodel”.

Since it has been pointed out that the accuracy has been reduced when converting to ".mlmodel", there is also an idea that TuriCreate should confirm it before implementing it.

Sorry for the long sentence.

TobyRoseman commented 4 years ago

@kuri54 - There should not be a change in accuracy going from a TuriCreate model (i.e. a ".model") to a CoreML model (i.e. a ".mlmodel"). The predicted probabilities should be almost identical.

I agree it would be to allow the image classifier and image similarity toolkits to take user defined feature extractor. I'll leave this issue open as a feature request.

kuri54 commented 4 years ago

I am very grateful for your agreement.

It may not have been good to tell me, but I also think that there is almost no loss of precision in ".model"-> ". Mlmodel".

However, I am concerned about the change in accuracy when converting from the keras model to “.mlmodel”.

Therefore, after verifying the converted learning model with TuriCreate, we thought that we could deploy it to a smartphone.

For that purpose, ".model" is required instead of ".mlmodel", and is that conversion possible? I came to the idea.

Of course, if you can read ".mlmodel" with TuriCreate and handle ".model" in the same way, my question this time will be solved at a stretch, but I could not find a way because of my lack of study.

TobyRoseman commented 4 years ago

To deploy to an iOS device using Core ML, you will a ".mlmodel" not a turicreate model. If you have a turicreate model, you can get a ".mlmodel" by calling: model.export_coreml('MyCoreMLModel.mlmodel')

Our User Guide contains details about how deploy an image classifier to an iOS device.

If you are using coremltools to convert a keras model and you're seeing significant differences in accuracy difference, then you should create an issue in the coremltools repository.

kuri54 commented 4 years ago

Thank you for all the details.

Perhaps my intention is not well communicated because of my poor English.Because it converts Japanese, it has become strange English. I'll sort it out once.

What i want to do ・ I want to deploy my own highly accurate keras model to iOS device with the same accuracy. ・ I want to do the accuracy verification with TuriCreate.

Problem(As far as I investigated) ・ TuriCreate can load only “.model”. ・ CoreMLTools can only convert to “.mlmodel”. ・ I can't find a way to convert my own keras model to “.model”.   ->Did the title change with that intention?     If so, further discussion may not be necessary.

I found an article on a Japanese website about the loss of accuracy of the ".mlmodel" converted from the Keras model, but have not verified it.

A brief summary is as above. If so, please point out.

TobyRoseman commented 4 years ago

If possible, please share more details about the following: "I want to do the accuracy verification with TuriCreate."

kuri54 commented 4 years ago

After create a learning model, must carefully verify it. So I asked TuriCreate if it could be visualized like grad-CAM. (Grad-CAM of image classification # 2116)

There is only one reason to use TuriCreate. Because it's easy. Also, deploying to iOS is relatively easy.

For example, TuriCreate can draw graphs without writing long code. (Detailed customization is not possible ...)Just reducing the coding burden can be very helpful.

Hopefully everything can be done with TuriCreate, but in this study using ResNet50 did not improve accuracy. So I thought I would do that by converting the VGG16 Fine-tuning model.

If TuriCreate has options such as VGG and Inception, there may have been no such discussion.

I hope this answers your question.