muellerzr HF staff commited on
Commit
f98c827
1 Parent(s): 562c3cb

Try removing global var

Browse files
Files changed (1) hide show
  1. src/app.py +2 -7
src/app.py CHANGED
@@ -5,19 +5,14 @@ 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
9
- MODEL = None
10
-
11
-
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)]
22
 
23
 
 
5
  from huggingface_hub.utils import HfHubHTTPError
6
 
7
 
 
 
 
 
8
  def get_results(model_name: str, library: str, options: list, access_token: str):
9
+ model = get_model(model_name, library, access_token)
 
10
  try:
11
  has_discussion = check_for_discussion(model_name)
12
  except HfHubHTTPError:
13
  has_discussion = True
14
  title = f"## Memory usage for '{model_name}'"
15
+ data = calculate_memory(model, options)
16
  return [title, gr.update(visible=True, value=pd.DataFrame(data)), gr.update(visible=not has_discussion)]
17
 
18