File size: 642 Bytes
197fb1d
 
 
f3ddcb4
 
197fb1d
 
580dfff
197fb1d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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}")