I apologized in advance if this was already asked but I couldn’t find any solution.
I have trained a classification model and I got a pretty good accuracy on the validation dataset (>97%).
Now I found out that during inference, I am getting really bad results.
I think this is due to the fact that for training I am performing normalization of the data (2d images) and before doing inference I am not doing it which cause a discrepancy.
Could you tell me the best way to normalize data for inference please ?
I am using the last version of Fastai (2.7.10)
The current source code I am using for inference is the following:
Hey do you have a colab notebook or some more sample code to look at? Its a little tricky to only see your .predict() call and see how that compares to your training inputs to your model. From how you describe the problem, it sounds like you’re correct that your normalising/transforming your data in some way that is different to your inference time data.
If you post something I can run/replicate your problem, I’d be happy to have a look and try to help
Please let me know if you have any ideas about what could be wrong.
I went inside the source code of FastAi library but couldn’t find any difference in values of the data.
Sorry it took me a couple days to get back to you, is there a reason you’re not calling .predict() directly with your filepath? Similar to the following?
Or is this because you’re not writing the image to disk and instead have it in memory as “image_item” for your application?
I’m wondering if you could write your normalisation process/function as a method and reference it at both training and inference time so that you know the same process is running for both instances.
If you could make a colab notebook or some usable example I could debug I reckon I could knuckle down your problem, its definitely harder with just snippets but I understand thats not always possible.
@nglillywhite .
Thank you very much for your help and your reply.
The reason I didn’t use directly the path was because for inference I have an image with a high resolution. I crop it, make patches then inference.
I was used to previous FastAi versions and I didn’t know that they changed the way to use transformations. I found out that I was doing too many pre-processing that are now being handled automatically. Now, after correction of my source code, the validation results and the inference results are matching in terms of ratio (the confusion matrix is pretty beautiful and consistent).
Thank you for helping me.
I wish you a good weekend.
Analyze the direct unit cost of an item To view the value entries that are related to the item charge that you posted, use the following procedure.
Select the search for page icon in the top-right corner of the page, enter Posted Purchase Receipts, and then choose the related link. Open the purchase receipt with item charges.
In the command bar, select Receipt, then Find Entries. Select Item Ledger Entry, then Show Related Entries.
Notice that the Quantity hasn’t changed in comparison with the quantity on the posted purchase receipt. Select the item ledger entry and, on the Entry tab, select Value Entries or select the Cost Amount (Actual) field. A new value entry of the type Direct Cost represents the additional cost of the freight invoice.
Close the Value Entries page. On the Item Ledger Entries page, copy the Item No. field for your example and then close the Item Ledger Entries page.
Select the search for page icon in the top-right corner of the page, enter Items, and then choose the related link. In a search pane, paste the item number that you copied on the Item Ledger Entries page.
From the Item List page, open the item card, select Related, then Availability, then Statistics, then Statistics.
On the General FastTab, in the Show as Lines field, select Purch. Item Charge Spec. and then select the Show Matrix action.
You can also check item charge details by using the Item Charges - Specification report. To do so, select the search for page icon in the top-right corner of the page, enter Item Charges - Specification, and then choose the related link. On the Options FastTab, select Print Details, and then select Purchase in the Source Details field. Select Preview.