playing around with gradio
Browse files
app.py
CHANGED
@@ -1,16 +1,13 @@
|
|
|
|
1 |
import matplotlib
|
2 |
matplotlib.use('Agg')
|
3 |
import matplotlib.pyplot as plt
|
4 |
-
import numpy as np
|
5 |
|
6 |
import gradio as gr
|
7 |
|
8 |
|
9 |
-
dummy_data = [1, 2, 3, 4]
|
10 |
-
|
11 |
-
|
12 |
BENCHMARK_DATA = {
|
13 |
-
"Greedy": {
|
14 |
"DistilGPT2": {
|
15 |
"T4": [],
|
16 |
"3090": [],
|
@@ -32,7 +29,7 @@ BENCHMARK_DATA = {
|
|
32 |
"A100": [],
|
33 |
},
|
34 |
"T5 Small": {
|
35 |
-
"T4": [],
|
36 |
"3090": [],
|
37 |
"A100": [],
|
38 |
},
|
@@ -139,9 +136,10 @@ BENCHMARK_DATA = {
|
|
139 |
}
|
140 |
|
141 |
|
142 |
-
def get_plot(model_name):
|
143 |
-
|
144 |
-
plt.
|
|
|
145 |
return plt.gcf()
|
146 |
|
147 |
demo = gr.Blocks()
|
@@ -156,6 +154,7 @@ with demo:
|
|
156 |
interactive=True,
|
157 |
)
|
158 |
plot = gr.Plot()
|
|
|
159 |
model_selector.change(fn=get_plot, inputs=[model_selector], outputs=plot)
|
160 |
with gr.TabItem("Sample"):
|
161 |
gr.Button("New Tiger")
|
|
|
1 |
+
import functools
|
2 |
import matplotlib
|
3 |
matplotlib.use('Agg')
|
4 |
import matplotlib.pyplot as plt
|
|
|
5 |
|
6 |
import gradio as gr
|
7 |
|
8 |
|
|
|
|
|
|
|
9 |
BENCHMARK_DATA = {
|
10 |
+
"Greedy Search": {
|
11 |
"DistilGPT2": {
|
12 |
"T4": [],
|
13 |
"3090": [],
|
|
|
29 |
"A100": [],
|
30 |
},
|
31 |
"T5 Small": {
|
32 |
+
"T4": [1, 2, 3, 4],
|
33 |
"3090": [],
|
34 |
"A100": [],
|
35 |
},
|
|
|
136 |
}
|
137 |
|
138 |
|
139 |
+
def get_plot(model_name, generate_type):
|
140 |
+
data = BENCHMARK_DATA[generate_type][model_name]["T4"]
|
141 |
+
plt.plot(data)
|
142 |
+
plt.title(model_name)
|
143 |
return plt.gcf()
|
144 |
|
145 |
demo = gr.Blocks()
|
|
|
154 |
interactive=True,
|
155 |
)
|
156 |
plot = gr.Plot()
|
157 |
+
plot_fn = functools.partial(get_plot, generate_type="Greedy Search")
|
158 |
model_selector.change(fn=get_plot, inputs=[model_selector], outputs=plot)
|
159 |
with gr.TabItem("Sample"):
|
160 |
gr.Button("New Tiger")
|