Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Check for if discussion is disabled
Browse files- src/app.py +5 -1
src/app.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
import pandas as pd
|
3 |
from hub_utils import check_for_discussion, report_results
|
4 |
from model_utils import calculate_memory, get_model
|
|
|
5 |
|
6 |
|
7 |
# We need to store them as globals because gradio doesn't have a way for us to pass them in to the button
|
@@ -11,7 +12,10 @@ MODEL = None
|
|
11 |
def get_results(model_name: str, library: str, options: list, access_token: str):
|
12 |
global MODEL
|
13 |
MODEL = get_model(model_name, library, access_token)
|
14 |
-
|
|
|
|
|
|
|
15 |
title = f"## Memory usage for '{model_name}'"
|
16 |
data = calculate_memory(MODEL, options)
|
17 |
return [title, gr.update(visible=True, value=pd.DataFrame(data)), gr.update(visible=not has_discussion)]
|
|
|
2 |
import pandas as pd
|
3 |
from hub_utils import check_for_discussion, report_results
|
4 |
from model_utils import calculate_memory, get_model
|
5 |
+
from huggingface_hub.utils import HfHubHTTPError
|
6 |
|
7 |
|
8 |
# We need to store them as globals because gradio doesn't have a way for us to pass them in to the button
|
|
|
12 |
def get_results(model_name: str, library: str, options: list, access_token: str):
|
13 |
global MODEL
|
14 |
MODEL = get_model(model_name, library, access_token)
|
15 |
+
try:
|
16 |
+
has_discussion = check_for_discussion(model_name)
|
17 |
+
except HfHubHTTPError:
|
18 |
+
has_discussion = True
|
19 |
title = f"## Memory usage for '{model_name}'"
|
20 |
data = calculate_memory(MODEL, options)
|
21 |
return [title, gr.update(visible=True, value=pd.DataFrame(data)), gr.update(visible=not has_discussion)]
|