kerrj / lerf

Code for LERF: Language Embedded Radiance Fields
https://www.lerf.io/
MIT License
649 stars 63 forks source link

load func in the class PyramidEmbeddingDataloader #38

Closed Chuan-10 closed 1 year ago

Chuan-10 commented 1 year ago

Hi,

I noticed that the load function does not assign the cache value to the self.data_dict in the class PyramidEmbeddingDataloader. Is it a bug? if not, why?

    def load(self):
        # don't create anything, PatchEmbeddingDataloader will create itself
        cache_info_path = self.cache_path.with_suffix(".info")

        # check if cache exists
        if not cache_info_path.exists():
            raise FileNotFoundError

        # if config is different, remove all cached content
        with open(cache_info_path, "r") as f:
            cfg = json.loads(f.read())
        if cfg != self.cfg:
            for f in os.listdir(self.cache_path):
                os.remove(os.path.join(self.cache_path, f))
            raise ValueError("Config mismatch")

        raise FileNotFoundError  # trigger create

Thank you for your time! Best, Chris

kerrj commented 1 year ago

Hi! The code is written a bit confusingly here, the final line of raise FileNotFoundError will always trigger a create(), which assigns data_dict values to the PatchEmbeddingDataloaders. The actual caching of CLIP/DINO embeddings is done inside PatchEmbeddingDataloader.