debayan commited on
Commit
11bad2f
Β·
1 Parent(s): 80a53ee

Upload folder using huggingface_hub

Browse files
__pycache__/request_api.cpython-38.pyc CHANGED
Binary files a/__pycache__/request_api.cpython-38.pyc and b/__pycache__/request_api.cpython-38.pyc differ
 
gradio_app.py CHANGED
@@ -7,8 +7,6 @@ from datetime import datetime, timezone
7
  from pathlib import Path
8
  from request_api import make_get_request, make_post_request
9
  from io import BytesIO, StringIO
10
- import asyncio
11
-
12
  LEADERBOARD_PATH = "/home/Bhattacharya/ism_leaderboard/files/leaderboard"
13
  # Directory where request by models are stored
14
  DIR_OUTPUT_REQUESTS = Path("requested_models")
@@ -18,7 +16,7 @@ EVAL_REQUESTS_PATH = Path("eval_requests")
18
  # Text definitions #
19
  ##########################
20
 
21
- banner_url = "https://huggingface.co/spaces/debayan/ISM2023w/resolve/main/logo_leaderboard.png"
22
  BANNER = f'<div style="display: flex; justify-content: space-around;"><img src="{banner_url}" alt="Banner" style="width: 40vw; min-width: 300px; max-width: 600px;"> </div>'
23
 
24
  TITLE = "<html> <head> <style> h1 {text-align: center;} </style> </head> <body> <h1> πŸ€— Open Automatic Speech Recognition Leaderboard </b> </body> </html>"
@@ -28,9 +26,9 @@ INTRODUCTION_TEXT = "πŸ† The ISM2023w Leaderboard ranks and evaluates models \
28
  \nWe report the Precision, Recall, Accuracy, Weighted [F1 Score](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html)\n"
29
 
30
  #CSV_TEXT = "<p>Please make sure that you upload the CSV in the correct format. Click the link to download a sample CSV!</p> <a href=\"https://huggingface.co/spaces/debayan/ism_2023w/raw/main/example.csv\" download=\"example.csv\">Download CSV</a>"
 
31
 
32
 
33
- CSV_TEXT = "<p>Please go to the new url to upload CSV and check leaderboard!</p> [https://726b6c34825b86770e.gradio.live](https://726b6c34825b86770e.gradio.live)"
34
 
35
  METRICS_TAB_TEXT = """
36
  Here you will find details about the multi-class classification metrics and datasets reported in our leaderboard.
@@ -41,8 +39,6 @@ below.
41
  """
42
 
43
 
44
-
45
-
46
  LAST_UPDATED = "Sep 28th 2023"
47
 
48
 
@@ -62,18 +58,17 @@ def create_html_page(title, content):
62
 
63
  return html_page
64
 
65
- async def fetch_leaderboard(phase=1):
66
 
67
  """
68
  Fetch the leaderboard from the local disk
69
  """
70
  params = {"phase": phase}
71
 
72
- leaderboard_df = await make_get_request("fetch-leaderboard", params)
73
-
74
  csv_data = leaderboard_df.content.decode('utf-8')
75
-
76
- #print(csv_data)
77
 
78
  # create dataframe from csv data
79
  leaderboard_df = pd.read_csv(StringIO(csv_data))
@@ -150,10 +145,6 @@ def formatter(x):
150
  def format_leaderboard(df,sort_by="F1 Score"):
151
  # Formats the columns
152
 
153
- if df is None:
154
- return None
155
- print(df)
156
-
157
  for col in df.columns:
158
  if col == "Team Name":
159
  # do nothing
@@ -169,15 +160,12 @@ def format_leaderboard(df,sort_by="F1 Score"):
169
  df.sort_values(by=sort_by, inplace=True, ascending=False)
170
  return df
171
 
172
- # Run the async function in an event loop
173
 
174
 
175
- #lb_1 = asyncio.run(fetch_leaderboard(phase=1))
176
- #lb_2 = asyncio.run(fetch_leaderboard(phase=2))
177
- #leaderboard_df_1 = format_leaderboard(lb_1)
178
- #leaderboard_df_2 = format_leaderboard(lb_2)
179
- #leaderboard_df_1 = None
180
- #leaderboard_df_2 = None
181
 
182
  COLS = [c.name for c in fields(AutoEvalColumn)]
183
  TYPES = [c.type for c in fields(AutoEvalColumn)]
@@ -187,8 +175,8 @@ with gr.Blocks() as demo:
187
  leaderboard_table_2 = None
188
 
189
  def button_clicked_phase_1(inputs):
190
- lb_1 = asyncio.run(fetch_leaderboard(phase=1))
191
- leaderboard_df_1 = format_leaderboard(lb_1)
192
 
193
 
194
  leaderboard_table_1 = gr.components.Dataframe(
@@ -205,8 +193,8 @@ with gr.Blocks() as demo:
205
 
206
 
207
  def button_clicked_phase_2():
208
- lb_2 = asyncio.run(fetch_leaderboard(phase=2))
209
- leaderboard_df_2 = format_leaderboard(lb_2)
210
 
211
 
212
  leaderboard_table_2 = gr.components.Dataframe(
@@ -230,8 +218,8 @@ with gr.Blocks() as demo:
230
  gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
231
  gr.HTML(CSV_TEXT, elem_classes="markdown-text")
232
 
233
- """
234
 
 
235
  with gr.Tabs(elem_classes="tab-buttons") as tabs:
236
  with gr.TabItem("πŸ… Leaderboard Phase 1", elem_id="od-benchmark-tab-table-1", id=0):
237
 
@@ -278,9 +266,9 @@ with gr.Blocks() as demo:
278
  ],
279
  outputs=gr.outputs.HTML()
280
  )
 
281
 
282
 
283
- """
284
 
285
 
286
 
@@ -288,9 +276,7 @@ with gr.Blocks() as demo:
288
 
289
 
290
  gr.Markdown(f"Last updated on **{LAST_UPDATED}**", elem_classes="markdown-text")
291
-
292
-
293
-
294
- demo.launch( debug=True,share=True)
295
 
296
 
 
7
  from pathlib import Path
8
  from request_api import make_get_request, make_post_request
9
  from io import BytesIO, StringIO
 
 
10
  LEADERBOARD_PATH = "/home/Bhattacharya/ism_leaderboard/files/leaderboard"
11
  # Directory where request by models are stored
12
  DIR_OUTPUT_REQUESTS = Path("requested_models")
 
16
  # Text definitions #
17
  ##########################
18
 
19
+ banner_url = "https://huggingface.co/spaces/debayan/ism_2023w/resolve/main/logo_leaderboard.png"
20
  BANNER = f'<div style="display: flex; justify-content: space-around;"><img src="{banner_url}" alt="Banner" style="width: 40vw; min-width: 300px; max-width: 600px;"> </div>'
21
 
22
  TITLE = "<html> <head> <style> h1 {text-align: center;} </style> </head> <body> <h1> πŸ€— Open Automatic Speech Recognition Leaderboard </b> </body> </html>"
 
26
  \nWe report the Precision, Recall, Accuracy, Weighted [F1 Score](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html)\n"
27
 
28
  #CSV_TEXT = "<p>Please make sure that you upload the CSV in the correct format. Click the link to download a sample CSV!</p> <a href=\"https://huggingface.co/spaces/debayan/ism_2023w/raw/main/example.csv\" download=\"example.csv\">Download CSV</a>"
29
+ CSV_TEXT = "<p>Please use this link to upload your csvs and check leaderboards!</p> <a href=\"https://96a0375bee72bd00d0.gradio.live\" >https://96a0375bee72bd00d0.gradio.live</a>"
30
 
31
 
 
32
 
33
  METRICS_TAB_TEXT = """
34
  Here you will find details about the multi-class classification metrics and datasets reported in our leaderboard.
 
39
  """
40
 
41
 
 
 
42
  LAST_UPDATED = "Sep 28th 2023"
43
 
44
 
 
58
 
59
  return html_page
60
 
61
+ def fetch_leaderboard(phase=1):
62
 
63
  """
64
  Fetch the leaderboard from the local disk
65
  """
66
  params = {"phase": phase}
67
 
68
+ leaderboard_df = make_get_request("fetch-leaderboard", params)
 
69
  csv_data = leaderboard_df.content.decode('utf-8')
70
+
71
+ print(csv_data)
72
 
73
  # create dataframe from csv data
74
  leaderboard_df = pd.read_csv(StringIO(csv_data))
 
145
  def format_leaderboard(df,sort_by="F1 Score"):
146
  # Formats the columns
147
 
 
 
 
 
148
  for col in df.columns:
149
  if col == "Team Name":
150
  # do nothing
 
160
  df.sort_values(by=sort_by, inplace=True, ascending=False)
161
  return df
162
 
 
163
 
164
 
165
+
166
+ #leaderboard_df_1 = format_leaderboard(fetch_leaderboard(phase=1))
167
+ #leaderboard_df_2 = format_leaderboard(fetch_leaderboard(phase=2))
168
+
 
 
169
 
170
  COLS = [c.name for c in fields(AutoEvalColumn)]
171
  TYPES = [c.type for c in fields(AutoEvalColumn)]
 
175
  leaderboard_table_2 = None
176
 
177
  def button_clicked_phase_1(inputs):
178
+
179
+ leaderboard_df_1 = format_leaderboard(fetch_leaderboard(phase=1))
180
 
181
 
182
  leaderboard_table_1 = gr.components.Dataframe(
 
193
 
194
 
195
  def button_clicked_phase_2():
196
+
197
+ leaderboard_df_2 = format_leaderboard(fetch_leaderboard(phase=2))
198
 
199
 
200
  leaderboard_table_2 = gr.components.Dataframe(
 
218
  gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
219
  gr.HTML(CSV_TEXT, elem_classes="markdown-text")
220
 
 
221
 
222
+ """
223
  with gr.Tabs(elem_classes="tab-buttons") as tabs:
224
  with gr.TabItem("πŸ… Leaderboard Phase 1", elem_id="od-benchmark-tab-table-1", id=0):
225
 
 
266
  ],
267
  outputs=gr.outputs.HTML()
268
  )
269
+ """
270
 
271
 
 
272
 
273
 
274
 
 
276
 
277
 
278
  gr.Markdown(f"Last updated on **{LAST_UPDATED}**", elem_classes="markdown-text")
279
+
280
+ demo.launch(debug=True,share=True)
 
 
281
 
282
 
request_api.py CHANGED
@@ -4,43 +4,15 @@
4
 
5
  import requests
6
 
7
- from urllib.parse import urljoin, urlencode
8
 
9
- # Define the base URL
10
- #BASE_URL = 'http://127.0.0.1:5000/'
11
- import httpx
12
 
 
13
  BASE_URL = 'https://d9c5-134-28-45-21.ngrok-free.app/'
 
14
 
15
- async def make_get_request(endpoint, params):
16
-
17
- async with httpx.AsyncClient() as client:
18
- try:
19
- response = await client.get(urljoin(BASE_URL, endpoint), params=params)
20
- print(response.url)
21
- response.raise_for_status() # Check if the response is successful
22
- except httpx.HTTPError as e:
23
- print(f"Request failed: {e}")
24
- return None
25
-
26
- print(response)
27
- return response
28
-
29
- async def make_post_request(endpoint, params, data=None):
30
- if data is None:
31
- return None
32
-
33
- async with httpx.AsyncClient() as client:
34
- try:
35
- response = await client.post(urljoin(BASE_URL, endpoint), params=params, data=data)
36
- response.raise_for_status() # Check if the response is successful
37
- except httpx.HTTPError as e:
38
- print(f"Request failed: {e}")
39
- return None
40
- return response
41
 
42
 
43
- """
44
  def make_get_request(endpoint,params):
45
 
46
  try:
@@ -78,5 +50,5 @@ def make_post_request(endpoint,params,data=None):
78
  # Return the error
79
  return response
80
 
81
- """
82
 
 
4
 
5
  import requests
6
 
7
+ from urllib.parse import urljoin, urlencode, urlparse, urlunparse
8
 
 
 
 
9
 
10
+ # Define the base URL
11
  BASE_URL = 'https://d9c5-134-28-45-21.ngrok-free.app/'
12
+ #BASE_URL = 'http://127.0.0.1:5000/'
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
 
 
16
  def make_get_request(endpoint,params):
17
 
18
  try:
 
50
  # Return the error
51
  return response
52
 
53
+
54