from huggingface_hub import HfApi def get_model_size(model_name_or_path, token=None): api = HfApi(token=token) try: model_info = api.model_info(model_name_or_path, timeout=10) safetensors_info = model_info.safetensors size = safetensors_info.total return size except Exception as e: print(e) return -1 if __name__ == "__main__": model = "zhaorui-nb/Phi-3-mini-4k-instruct._.lora_ft._.Setting3" print(get_model_size(model)) import time # calc this function time start = time.time() print(get_model_size(model)) print(f"Time: {time.time() - start}")