lambdaofgod commited on
Commit
de9e814
·
1 Parent(s): 1352e18

feat: Add Gradio interface in "Explore PapersWithCode Tasks" tab that displays the plotly plots returned by `task_visualizations`

Browse files
Files changed (1) hide show
  1. app.py +23 -3
app.py CHANGED
@@ -3,6 +3,7 @@ import pandas as pd
3
  import logging
4
  import re
5
  from task_visualizations import TaskVisualizations
 
6
 
7
  logging.basicConfig(level=logging.INFO)
8
 
@@ -109,8 +110,27 @@ with gr.Blocks() as demo:
109
  with gr.Tab("Explore Repository Representations"):
110
  setup_repository_representations_tab(repos, representation_types)
111
  with gr.Tab("Explore PapersWithCode Tasks"):
112
- with open("plots/pwc_area_tasks_sunburst.html") as f:
113
- sunburst_tasks = f.read()
114
- gr.HTML(sunburst_tasks)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
 
116
  demo.launch()
 
3
  import logging
4
  import re
5
  from task_visualizations import TaskVisualizations
6
+ import plotly.graph_objects as go
7
 
8
  logging.basicConfig(level=logging.INFO)
9
 
 
110
  with gr.Tab("Explore Repository Representations"):
111
  setup_repository_representations_tab(repos, representation_types)
112
  with gr.Tab("Explore PapersWithCode Tasks"):
113
+ gr.Markdown("## PapersWithCode Tasks Visualization")
114
+ with gr.Row():
115
+ min_task_count = gr.Slider(minimum=1, maximum=100, value=10, step=1, label="Minimum Task Count")
116
+ update_button = gr.Button("Update Plots")
117
+
118
+ with gr.Row():
119
+ with gr.Column():
120
+ gr.Markdown("### All Repositories")
121
+ all_repos_plot = gr.Plot()
122
+ with gr.Column():
123
+ gr.Markdown("### Selected Repositories")
124
+ selected_repos_plot = gr.Plot()
125
+
126
+ def update_plots(min_count):
127
+ all_plot, selected_plot = task_visualizations.display_tasks_sunburst_charts(min_count)
128
+ return all_plot, selected_plot
129
+
130
+ update_button.click(
131
+ fn=update_plots,
132
+ inputs=[min_task_count],
133
+ outputs=[all_repos_plot, selected_repos_plot]
134
+ )
135
 
136
  demo.launch()