Spaces:
Sleeping
Sleeping
Rajarshi Roy
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
-
import json
|
2 |
import plotly.io as pio
|
3 |
-
|
4 |
|
5 |
# List of plot names
|
6 |
plot_list = [
|
@@ -10,19 +9,39 @@ plot_list = [
|
|
10 |
"Gemma2_9b"
|
11 |
]
|
12 |
|
13 |
-
#
|
14 |
-
def
|
15 |
-
|
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 |
-
#
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|