Fetch files metadata directly from model_info call
Browse filesYou can directly use `model_info(..., files_metadata=True)` to fetch all file sizes. This way, you don't have to do extra `get_hf_file_metadata` calls.
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from huggingface_hub import
|
2 |
import gradio as gr
|
3 |
|
4 |
|
@@ -22,7 +22,7 @@ def get_component_wise_memory(pipeline_id, token=None, variant=None, revision=No
|
|
22 |
print(pipeline_id, variant, revision, extension)
|
23 |
component_wise_memory = {}
|
24 |
|
25 |
-
files_in_repo = model_info(pipeline_id, revision=revision, token=token).siblings
|
26 |
|
27 |
for current_file in files_in_repo:
|
28 |
if all(
|
@@ -44,10 +44,7 @@ def get_component_wise_memory(pipeline_id, token=None, variant=None, revision=No
|
|
44 |
filename = current_file.rfilename
|
45 |
|
46 |
if filename is not None:
|
47 |
-
|
48 |
-
file_metadata = get_hf_file_metadata(hub_url)
|
49 |
-
|
50 |
-
component_wise_memory[component] = bytes_to_giga_bytes(file_metadata.size)
|
51 |
|
52 |
return component_wise_memory
|
53 |
|
|
|
1 |
+
from huggingface_hub import model_info
|
2 |
import gradio as gr
|
3 |
|
4 |
|
|
|
22 |
print(pipeline_id, variant, revision, extension)
|
23 |
component_wise_memory = {}
|
24 |
|
25 |
+
files_in_repo = model_info(pipeline_id, revision=revision, token=token, files_metadata=True).siblings
|
26 |
|
27 |
for current_file in files_in_repo:
|
28 |
if all(
|
|
|
44 |
filename = current_file.rfilename
|
45 |
|
46 |
if filename is not None:
|
47 |
+
component_wise_memory[component] = bytes_to_giga_bytes(current_file.size)
|
|
|
|
|
|
|
48 |
|
49 |
return component_wise_memory
|
50 |
|