Cached models only compared by name and tag
I have an issue with the current way we load cached models. If one rebuilds the model locally or if we update remote networks but keep the name, the plugin will still use the old cached one because we just compare the file name and tag (right?). What would be the best way to do it? Are hash sums not appropriate for some reason? Could we at least check for a changed file timestamp? I can implement it, just asking for the best strategy or if I am misunderstanding something.
The download service does compare checksums, if they exist. See here.
The DiskCacheService implementation here does implement checking saving and loading, but saving checksums does not happen automatically. Try calling the saveChecksum method manually in your code? Note that I did not test this feature thoroughly, so there may be obstacles, but I believe the pieces you need are there.
Oh I see. I was at the wrong position in the code.. I do not see the DiskCacheService being called anywhere in this repository. The DownloadService is also not being called if the directory for the model in the cached folder already exists (code. So I cannot find a way where checksums are being compared even if they existed.
Quick solution:
- add JavaDoc to reflect that the model name defines the model and cache location
- add method to invalidate cache
Long term solution:
- use DownloadService to check if model source changed
- make sure the model cache gets updated once the source changes (e.g. with datestamp)
This issue has been mentioned on Image.sc Forum. There might be relevant details there:
https://forum.image.sc/t/tensorflow-model-downloading/40514/2