Hello,
I am wondering what’s the difference between these both usages of the API’s,
both usages produce model cards but have different outcomes:
One of them results None and the other one produces an output:
from huggingface_hub import list_models
# Fetch all models
models = list_models()
# Filter for the desired model
desired_model = "typeform/distilbert-base-uncased-mnli"
matching_model = next((model for model in models if model.modelId == desired_model), None)
print(matching_model.last_modified) # prints None
I think this is to reduce the load on the Hub, but anyway, by default, heavy data is not fetched, so you need to add full=True (for last_modified, etc.) or cardData=True (for cardData).
from huggingface_hub import HfApi
hf_api = HfApi()
model_id = 'typeform/distilbert-base-uncased-mnli'
model_info = hf_api.model_info(model_id)
print(model_info.last_modified) # prints: datetime.datetime(2023, 3, 22, 8, 49, tzinfo=datetime.timezone.utc)
from huggingface_hub import list_models
# Fetch all models
# models = list_models()
models = list_models(full=True)
# Filter for the desired model
desired_model = "typeform/distilbert-base-uncased-mnli"
matching_model = next((model for model in models if model.modelId == desired_model), None)
print(matching_model.last_modified) # prints None
"""
2023-03-22 08:49:00+00:00
2023-03-22 08:49:00+00:00
"""