Curios why snapshot_download is needed
#2
by
nielsr
- opened
Hi there!
Niels from the open-source team at Hugging Face. Glad to see you adopted the PyTorchModelHubMixin class. Just wondering why snapshot_download is used?
The point of the Mixin class is to allow to do just this:
from GFM import ElasticViTMAE
model = ElasticViTMAE.ElasticViTMAE.from_pretrained("thinkonward/geophysical-foundation-model")
instead of:
import torch
from huggingface_hub import snapshot_download
MODEL_REPO_ID = "thinkonward/geophysical-foundation-model"
snapshot_download(repo_id=MODEL_REPO_ID, repo_type="model", local_dir="./gfm-weights")
# import the architecture from the GitHub repository
from GFM import ElasticViTMAE
model = ElasticViTMAE.ElasticViTMAE()
The from_pretrained method will automatically equip the model with the weights.
Hi @nielsr
Thanks for checking out the GFM! When the team initially put together the example the weights were getting randomly re-initialized and the snapshot download was the easiest workaround at the time. I just checked the Mixin class use and it worked perfect. I am updating the README and tutorials today to use the class.