Update app.py
Browse files
app.py
CHANGED
@@ -15,8 +15,8 @@ def format_size(num: int) -> str:
|
|
15 |
num_f /= 1000.0
|
16 |
return f"{num_f:.1f}Y"
|
17 |
|
18 |
-
def format_output(memory_mapping):
|
19 |
-
markdown_str = ""
|
20 |
if memory_mapping:
|
21 |
for component, memory in memory_mapping.items():
|
22 |
markdown_str += f"* {component}: {format_size(memory)}\n"
|
@@ -28,7 +28,6 @@ def load_model_index(pipeline_id, token=None, revision=None):
|
|
28 |
index_dict = json.load(f)
|
29 |
return index_dict
|
30 |
|
31 |
-
|
32 |
def get_component_wise_memory(pipeline_id, token=None, variant=None, revision=None, extension=".safetensors"):
|
33 |
if token == "":
|
34 |
token = None
|
@@ -88,7 +87,7 @@ def get_component_wise_memory(pipeline_id, token=None, variant=None, revision=No
|
|
88 |
print(selected_file.rfilename)
|
89 |
component_wise_memory[component] = selected_file.size
|
90 |
|
91 |
-
return format_output(component_wise_memory)
|
92 |
|
93 |
|
94 |
gr.Interface(
|
@@ -113,7 +112,7 @@ gr.Interface(
|
|
113 |
info="Extension to use.",
|
114 |
),
|
115 |
],
|
116 |
-
outputs="
|
117 |
examples=[
|
118 |
["runwayml/stable-diffusion-v1-5", None, "fp32", None, ".safetensors"],
|
119 |
["stabilityai/stable-diffusion-xl-base-1.0", None, "fp16", None, ".safetensors"],
|
|
|
15 |
num_f /= 1000.0
|
16 |
return f"{num_f:.1f}Y"
|
17 |
|
18 |
+
def format_output(pipeline_id, memory_mapping):
|
19 |
+
markdown_str = f"## {pipeline_id}\n"
|
20 |
if memory_mapping:
|
21 |
for component, memory in memory_mapping.items():
|
22 |
markdown_str += f"* {component}: {format_size(memory)}\n"
|
|
|
28 |
index_dict = json.load(f)
|
29 |
return index_dict
|
30 |
|
|
|
31 |
def get_component_wise_memory(pipeline_id, token=None, variant=None, revision=None, extension=".safetensors"):
|
32 |
if token == "":
|
33 |
token = None
|
|
|
87 |
print(selected_file.rfilename)
|
88 |
component_wise_memory[component] = selected_file.size
|
89 |
|
90 |
+
return format_output(pipeline_id, component_wise_memory)
|
91 |
|
92 |
|
93 |
gr.Interface(
|
|
|
112 |
info="Extension to use.",
|
113 |
),
|
114 |
],
|
115 |
+
outputs=gr.Markdown(label="Output"),
|
116 |
examples=[
|
117 |
["runwayml/stable-diffusion-v1-5", None, "fp32", None, ".safetensors"],
|
118 |
["stabilityai/stable-diffusion-xl-base-1.0", None, "fp16", None, ".safetensors"],
|