sasha HF Staff commited on
Commit
b4fd74a
·
verified ·
1 Parent(s): 44f1ea5

Update app.py

Browse files

checking if model has already been tested

Files changed (1) hide show
  1. app.py +36 -35
app.py CHANGED
@@ -18,6 +18,8 @@ TOKEN = os.environ.get("DEBUG")
18
  API = HfApi(token=TOKEN)
19
 
20
  requests= load_dataset("EnergyStarAI/requests_debug", split="test", token=TOKEN)
 
 
21
 
22
  tasks = ['ASR', 'Object Detection', 'Text Classification', 'Image Captioning', 'Question Answering', 'Text Generation', 'Image Classification',
23
  'Sentence Similarity', 'Image Generation', 'Summarization']
@@ -50,47 +52,46 @@ def add_new_eval(
50
  model_name = repo_id.split("/")[1]
51
 
52
  current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
53
-
54
- # Is the model info correctly filled?
55
- try:
56
- model_info = API.model_info(repo_id=repo_id)
57
- except Exception:
58
- print("Could not find information for model %s" % (model))
59
  return
60
- # return styled_error("Could not get your model information. Please fill it up properly.")
61
-
62
- model_size = get_model_size(model_info=model_info)
 
 
 
 
63
 
64
- print("Adding request")
65
-
66
- requests_dset = requests.to_pandas()
67
 
68
- request_dict = {
69
- "model": repo_id,
70
- "precision": "N/A",
71
- "status": "PENDING",
72
- "submitted_time": pd.to_datetime(current_time),
73
- "task": task,
74
- "likes": model_info.likes,
75
- "params": model_size}
76
- #"license": license,
77
- #"private": False,
78
- #}
79
-
80
- print("Writing out request file to dataset")
81
- df_request_dict = pd.DataFrame([request_dict])
82
- print(df_request_dict)
83
- df_final = pd.concat([requests_dset, df_request_dict], ignore_index=True)
84
- updated_dset =Dataset.from_pandas(df_final)
85
- updated_dset.push_to_hub("EnergyStarAI/requests_debug", split="test", token=TOKEN)
86
 
87
- print("Starting compute space at %s " % COMPUTE_SPACE)
88
- return start_compute_space()
 
 
 
 
 
 
 
89
 
90
  def print_existing_models():
91
- requests = load_dataset("EnergyStarAI/requests_debug", split="test")
92
- requests_dset = requests.to_pandas()
93
- model_list= requests_dset[requests_dset['status'] == 'COMPLETED']
94
  return model_list
95
 
96
  with gr.Blocks() as demo:
 
18
  API = HfApi(token=TOKEN)
19
 
20
  requests= load_dataset("EnergyStarAI/requests_debug", split="test", token=TOKEN)
21
+ requests_dset = requests.to_pandas()
22
+ model_list= requests_dset[requests_dset['status'] == 'COMPLETED']
23
 
24
  tasks = ['ASR', 'Object Detection', 'Text Classification', 'Image Captioning', 'Question Answering', 'Text Generation', 'Image Classification',
25
  'Sentence Similarity', 'Image Generation', 'Summarization']
 
52
  model_name = repo_id.split("/")[1]
53
 
54
  current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
55
+ if repo_id in model_list:
56
+ print('This model has already been run!')
 
 
 
 
57
  return
58
+ else:
59
+ # Is the model info correctly filled?
60
+ try:
61
+ model_info = API.model_info(repo_id=repo_id)
62
+ except Exception:
63
+ print("Could not find information for model %s" % (model))
64
+ return
65
 
66
+ model_size = get_model_size(model_info=model_info)
67
+
68
+ print("Adding request")
69
 
70
+
71
+
72
+ request_dict = {
73
+ "model": repo_id,
74
+ "precision": "N/A",
75
+ "status": "PENDING",
76
+ "submitted_time": pd.to_datetime(current_time),
77
+ "task": task,
78
+ "likes": model_info.likes,
79
+ "params": model_size}
80
+ #"license": license,
81
+ #"private": False,
82
+ #}
 
 
 
 
 
83
 
84
+ print("Writing out request file to dataset")
85
+ df_request_dict = pd.DataFrame([request_dict])
86
+ print(df_request_dict)
87
+ df_final = pd.concat([requests_dset, df_request_dict], ignore_index=True)
88
+ updated_dset =Dataset.from_pandas(df_final)
89
+ updated_dset.push_to_hub("EnergyStarAI/requests_debug", split="test", token=TOKEN)
90
+
91
+ print("Starting compute space at %s " % COMPUTE_SPACE)
92
+ return start_compute_space()
93
 
94
  def print_existing_models():
 
 
 
95
  return model_list
96
 
97
  with gr.Blocks() as demo: