ThomasSimonini HF staff commited on
Commit
2edb029
1 Parent(s): c3c7548

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -18
app.py CHANGED
@@ -3,22 +3,30 @@ import requests.exceptions
3
  from huggingface_hub import HfApi, hf_hub_download
4
  from huggingface_hub.repocard import metadata_load
5
 
6
- def load_agent(model_id):
7
  """
8
  This function load the agent's video and results
9
  :return: video_path
10
  """
11
  # Load the metrics
12
- metadata = get_metadata(model_id)
13
 
14
  # Get the accuracy
15
- results = parse_metrics_accuracy(metadata)
16
 
17
  # Load the video
18
- video_path = hf_hub_download(model_id, filename="replay.mp4")
19
-
20
- return video_path, results
21
-
 
 
 
 
 
 
 
 
22
 
23
  def parse_metrics_accuracy(meta):
24
  if "model-index" not in meta:
@@ -43,14 +51,18 @@ def get_metadata(model_id):
43
  return None
44
 
45
 
46
- agent1 = gr.Interface(load_agent, gr.Textbox(
47
- label="model_1",
48
- ), ["video", "text"])
49
- agent2 = gr.Interface(load_agent, gr.Textbox(
50
- label="model_2",
51
- ), ["video", "text"])
52
-
53
-
54
-
55
- gr.Series(agent1, agent2).launch()
56
-
 
 
 
 
3
  from huggingface_hub import HfApi, hf_hub_download
4
  from huggingface_hub.repocard import metadata_load
5
 
6
+ def load_agent(model_id_1, model_id_2):
7
  """
8
  This function load the agent's video and results
9
  :return: video_path
10
  """
11
  # Load the metrics
12
+ metadata_1 = get_metadata(model_id_1)
13
 
14
  # Get the accuracy
15
+ results_1 = parse_metrics_accuracy(metadata_1)
16
 
17
  # Load the video
18
+ video_path_1 = hf_hub_download(model_id_1, filename="replay.mp4")
19
+
20
+ # Load the metrics
21
+ metadata_2 = get_metadata(model_id_2)
22
+
23
+ # Get the accuracy
24
+ results_2 = parse_metrics_accuracy(metadata_2)
25
+
26
+ # Load the video
27
+ video_path_2 = hf_hub_download(model_id_2, filename="replay.mp4")
28
+
29
+ return video_path_1, results_1, video_path_2, results_2
30
 
31
  def parse_metrics_accuracy(meta):
32
  if "model-index" not in meta:
51
  return None
52
 
53
 
54
+ gr.Interface(load_agent,
55
+ [
56
+ gr.Textbox(
57
+ label="Model 1",
58
+ ),
59
+ gr.Textbox(
60
+ label="Model 2",
61
+ ),
62
+ ],
63
+ ["video", gr.Textbox(
64
+ label="Mean Reward +/- Std Reward",
65
+ ), "video", gr.Textbox(
66
+ label="Mean Reward +/- Std Reward",
67
+ )]
68
+ ).launch()