imagej-tensorflow icon indicating copy to clipboard operation
imagej-tensorflow copied to clipboard

Cached models only compared by name and tag

Open frauzufall opened this issue 7 years ago • 4 comments

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.

frauzufall avatar Jul 12 '18 08:07 frauzufall

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.

ctrueden avatar Jul 12 '18 19:07 ctrueden

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.

frauzufall avatar Jul 13 '18 12:07 frauzufall

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)

frauzufall avatar Jul 02 '19 10:07 frauzufall

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

imagesc-bot avatar Jul 18 '20 23:07 imagesc-bot