Rajarshi Roy commited on
Commit
56c7253
·
verified ·
1 Parent(s): c72bb1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -17
app.py CHANGED
@@ -1,6 +1,5 @@
1
- import json
2
  import plotly.io as pio
3
- from google.colab import files
4
 
5
  # List of plot names
6
  plot_list = [
@@ -10,19 +9,39 @@ plot_list = [
10
  "Gemma2_9b"
11
  ]
12
 
13
- # Function to save Plotly figure to JSON file
14
- def save_plotly_figures():
15
- for plot_name in plot_list:
16
- # Load the figure (assuming you have these figures in the current environment)
17
- fig = pio.read_json(f'{plot_name}.json')
18
-
19
- # Save the figure to a JSON file
20
- json_filename = f'{plot_name}.json'
21
- with open(json_filename, 'w') as f:
22
- json.dump(fig.to_dict(), f)
23
-
24
- # Download the file
25
- files.download(json_filename)
26
 
27
- # Call the function to save and download figures
28
- save_plotly_figures()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import plotly.io as pio
2
+ import gradio as gr
3
 
4
  # List of plot names
5
  plot_list = [
 
9
  "Gemma2_9b"
10
  ]
11
 
12
+ # Create a function for each plot
13
+ def load_plotly_figure(index):
14
+ return pio.read_json(f'{plot_list[index]}.json')
 
 
 
 
 
 
 
 
 
 
15
 
16
+ # Define custom CSS for rectangular blocks
17
+ custom_css = """
18
+ <style>
19
+ .gradio-container {
20
+ display: flex;
21
+ flex-direction: column;
22
+ align-items: center;
23
+ height: 100vh; /* Full viewport height */
24
+ }
25
+ .gradio-row {
26
+ display: flex;
27
+ justify-content: center;
28
+ margin-bottom: 20px;
29
+ width: 100%;
30
+ }
31
+ .gradio-output {
32
+ width: 600px; /* Set the width of the block */
33
+ height: 400px; /* Set the height of the block */
34
+ border: 2px solid #ccc; /* Border to visualize the block */
35
+ border-radius: 10px; /* Rounded corners for a more rectangular appearance */
36
+ }
37
+ </style>
38
+ """
39
+
40
+ # Create a Gradio interface with custom layout and CSS
41
+ with gr.Blocks(css=custom_css) as demo:
42
+ for i in range(len(plot_list)):
43
+ with gr.Row():
44
+ gr.Plot(lambda index=i: load_plotly_figure(index), label=plot_list[i])
45
+
46
+ # Launch the Gradio interface
47
+ demo.launch()