m-ric HF Staff commited on
Commit
65af3cf
ยท
1 Parent(s): 5897436
Files changed (1) hide show
  1. app.py +23 -17
app.py CHANGED
@@ -179,9 +179,10 @@ org_info = {
179
  "AI21 Labs": ("#1E90FF", "๐Ÿ‡ฎ๐Ÿ‡ฑ"), # Dodger Blue,
180
  "Reka AI": ("#FFC300", "๐Ÿ‡บ๐Ÿ‡ธ"),
181
  "Zhipu AI": ("#FFC300", "๐Ÿ‡จ๐Ÿ‡ณ"),
 
182
  }
183
 
184
- def make_figure(original_df, start_time_gradio):
185
  fig = go.Figure()
186
 
187
  start_date = pd.to_datetime(start_time_gradio, unit='s')
@@ -267,7 +268,6 @@ def make_figure(original_df, start_time_gradio):
267
 
268
 
269
  # Update layout
270
- speak_french = False
271
  if speak_french:
272
  fig.update_layout(
273
  title="La course au classement",
@@ -286,9 +286,9 @@ def make_figure(original_df, start_time_gradio):
286
  xaxis_title="Date",
287
  hovermode="closest",
288
  xaxis_range=[start_date, current_date], # Extend x-axis for labels
289
- yaxis_range=[df.loc[df["Release Date"] >= start_date]["rating"].min() - margin, df["rating"].max() + margin],
290
  )
291
- apply_template(fig, annotation_text="Aymeric Roucher", height=500)
292
 
293
  fig.update_xaxes(
294
  tickformat="%m-%Y",
@@ -318,7 +318,8 @@ with gr.Blocks(
318
  with gr.Row():
319
  top_n_orgs = gr.Slider(minimum=1, maximum=30, value=10, step=1, label="View top N companies")
320
  # minimum_rating = gr.Slider(minimum=800, maximum=1300, value=1000, step=1, label="Restrict to ELO scores above N")
321
- start_time = gr.DateTime(value="2024-01-01 00:00:00")
 
322
  with gr.Group():
323
  with gr.Tab("Plot"):
324
  plot = gr.Plot(show_label=False)
@@ -344,24 +345,29 @@ with gr.Blocks(
344
  outputs=filtered_df,
345
  ).then(
346
  fn=make_figure,
347
- inputs=[filtered_df, start_time],
348
  outputs=[plot, display_df],
349
  )
350
 
351
- # minimum_rating.change(
352
- # fn=filter_df,
353
- # inputs=[top_n_orgs, minimum_rating],
354
- # outputs=filtered_df,
355
- # ).then(
356
- # fn=make_figure,
357
- # inputs=[filtered_df],
358
- # outputs=[plot, display_df],
359
- # )
360
 
361
  start_time.change(
362
  fn=make_figure,
363
- inputs=[filtered_df, start_time],
364
  outputs=[plot, display_df],
365
  )
366
-
 
 
 
 
 
367
  demo.launch()
 
179
  "AI21 Labs": ("#1E90FF", "๐Ÿ‡ฎ๐Ÿ‡ฑ"), # Dodger Blue,
180
  "Reka AI": ("#FFC300", "๐Ÿ‡บ๐Ÿ‡ธ"),
181
  "Zhipu AI": ("#FFC300", "๐Ÿ‡จ๐Ÿ‡ณ"),
182
+ "Nvidia": ("#76B900", "๐Ÿ‡บ๐Ÿ‡ธ"),
183
  }
184
 
185
+ def make_figure(original_df, start_time_gradio, speak_french):
186
  fig = go.Figure()
187
 
188
  start_date = pd.to_datetime(start_time_gradio, unit='s')
 
268
 
269
 
270
  # Update layout
 
271
  if speak_french:
272
  fig.update_layout(
273
  title="La course au classement",
 
286
  xaxis_title="Date",
287
  hovermode="closest",
288
  xaxis_range=[start_date, current_date], # Extend x-axis for labels
289
+ yaxis_range=[df.loc[df["Release Date"] >= start_date]["rating"].min(), df["rating"].max() + margin],
290
  )
291
+ apply_template(fig, annotation_text="Aymeric Roucher", height=600)
292
 
293
  fig.update_xaxes(
294
  tickformat="%m-%Y",
 
318
  with gr.Row():
319
  top_n_orgs = gr.Slider(minimum=1, maximum=30, value=10, step=1, label="View top N companies")
320
  # minimum_rating = gr.Slider(minimum=800, maximum=1300, value=1000, step=1, label="Restrict to ELO scores above N")
321
+ start_time = gr.DateTime(value="2024-01-01 00:00:00", label="Start time")
322
+ speak_french = gr.Checkbox(value=False, label="Parler franรงais")
323
  with gr.Group():
324
  with gr.Tab("Plot"):
325
  plot = gr.Plot(show_label=False)
 
345
  outputs=filtered_df,
346
  ).then(
347
  fn=make_figure,
348
+ inputs=[filtered_df, start_time, speak_french],
349
  outputs=[plot, display_df],
350
  )
351
 
352
+ top_n_orgs.change(
353
+ fn=filter_df,
354
+ inputs=[top_n_orgs],
355
+ outputs=filtered_df,
356
+ ).then(
357
+ fn=make_figure,
358
+ inputs=[filtered_df, start_time, speak_french],
359
+ outputs=[plot, display_df],
360
+ )
361
 
362
  start_time.change(
363
  fn=make_figure,
364
+ inputs=[filtered_df, start_time, speak_french],
365
  outputs=[plot, display_df],
366
  )
367
+
368
+ speak_french.change(
369
+ fn=make_figure,
370
+ inputs=[filtered_df, start_time, speak_french],
371
+ outputs=[plot, display_df],
372
+ )
373
  demo.launch()