-
Notifications
You must be signed in to change notification settings - Fork 1.9k
how to retrain the image classify model incrementally? #5355
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
Comments
@thicktao thanks for using ML.NET, could you please upload the model file tensorflow_inception_graph.pb to some cloud storage and share the link so we can investigate what is going on here? |
@frank-dong-ms Ok,I created a repository,you can download it from https://github.com/thicktao/issuefiles/blob/master/tensorflow_inception_graph.zip |
@thicktao seems we still need definition of class "ImageSettings", could you please share a repro solution and repro steps which will be much easier? |
@frank-dong-ms https://github.com/thicktao/issuefiles.git you can Reproduce this error by this repository |
@thicktao Thanks for providing that. I can see several issue in your sample code:
I have made a working version based on your sample code like below (I put code in a single method but you can get the idea), please take a look and let me know if you have any further questions: ` public static void SaveRetrainModel2()
|
@frank-dong-ms Thank you so much! As I tested the code you replied to,It wokrs well! But I have another question, I find that it's not incremental training. private static void PredictScore(string dataModelPath = "")
{
if (string.IsNullOrEmpty(dataModelPath))
{
dataModelPath = DataModelPath;
}
var loadedModel = MlContext.Model.Load(dataModelPath, out var modelInputSchema);
var predictor = MlContext.Model.CreatePredictionEngine<ImageData, ImagePrediction>(loadedModel);
var imageData = new ImageData() { Image = (Bitmap)Image.FromFile(PredictImgs) };
var result = predictor.Predict(imageData);
if (result.PredictedLabelValue == "2")
{
Console.WriteLine($"It is my expectation and PredictedLabelValue:{result.PredictedLabelValue} and score is {result.Score.Max()}");
}
else
{
Console.WriteLine($"It is not my expectation,PredictedLabelValue:{result.PredictedLabelValue} and score is {result.Score.Max()}");
}
} |
@thicktao I checked the training data, the image used to predict(PredictImgs/111.png) is the same one as the only image marked as label 3 at train2 folder(\train\TrainImage2\3\111.png) so I would not surprise that this image is marked as label 3. |
@frank-dong-ms sorry,i forget to tell you that the repository was updated, and i changed the trainImage1、trainImage2 files, as below : |
@thicktao I see what you are trying to do now. Looks like you are not retraining the image classification model (only loads through MlContext.Model.LoadTensorFlowModel(InceptionPb).ScoreTensorFlowModel). There used to be a method called RetrainDnnModel serves this purpose but this method has been marked as internal due to not fully tested, see related issues and PRs below: If you need this functionality, please describe your scenarios in detail and other necessary infos and I can tag this issue as feature request and we can prioritize this. |
@frank-dong-ms Thank you very much for your answer. I need a picture classification model, i want to constantly train to optimize this model. My training material is constantly produced by users, but my physical machine is only 16G, in the future the size of images collection will be much larger than 16G, I can not load all the pictures into memory, and then train it. So I need a solution of ml.net. ML.net is a good machine learning framework, I like .net very much, and I'm not willing to try other languages to achieve the above requirements, so can ml.net add this functionality? |
@thicktao thanks for your support for ML.NET, I will mark this issue as feature request and will prioritize this later. |
Is there any update? I need this feature too. |
Any update? I would need this feature as well |
System information
Issue
I want to retrain the image classify model incrementally
when i predict it after my second training, it report an error,as below
after my retraining model ,it can works well
Source code / logs
train.zip
and file "tensorflow_inception_graph.pb" is too big to upload
The text was updated successfully, but these errors were encountered: