joaogante HF staff commited on
Commit
01593e1
1 Parent(s): e589f54

playing around with gradio

Browse files
Files changed (1) hide show
  1. app.py +10 -18
app.py CHANGED
@@ -6,35 +6,26 @@ import numpy as np
6
  import gradio as gr
7
 
8
 
9
- def sales_projections(employee_data):
10
- sales_data = employee_data.iloc[:, 1:4].astype("int").to_numpy()
11
- regression_values = np.apply_along_axis(
12
- lambda row: np.array(np.poly1d(np.polyfit([0, 1, 2], row, 2))), 0, sales_data
13
- )
14
- projected_months = np.repeat(
15
- np.expand_dims(np.arange(3, 12), 0), len(sales_data), axis=0
16
- )
17
- projected_values = np.array(
18
- [
19
- month * month * regression[0] + month * regression[1] + regression[2]
20
- for month, regression in zip(projected_months, regression_values)
21
- ]
22
- )
23
- plt.plot(projected_values.T)
24
- plt.legend(employee_data["Name"])
25
- return employee_data, plt.gcf(), regression_values
26
 
27
  demo = gr.Blocks()
28
 
29
  with demo:
30
  with gr.Tabs():
31
  with gr.TabItem("Greedy Search"):
32
- gr.Dropdown(
33
  choices=["DistilGPT2", "GPT2", "OPT 1.3B", "GPTJ-6B", "T5 Small", "T5 Base", "T5 Large", "T5 3B"],
34
  value="T5 Small",
35
  label="Model",
36
  interactive=True,
37
  )
 
38
  with gr.TabItem("Sample"):
39
  gr.Button("New Tiger")
40
  with gr.TabItem("Beam Search"):
@@ -48,6 +39,7 @@ with demo:
48
  ["Pytorch Version", "1.11.0"],
49
  ["OS", "22.04 LTS (3090) / Debian 10 (other GPUs)"],
50
  ["CUDA", "11.6 (3090) / 11.3 (others GPUs)"],
 
51
  ["Is there code to reproduce?", "Yes -- https://gist.github.com/gante/f0017e3f13ac11b0c02e4e4db351f52f"],
52
  ],
53
  )
 
6
  import gradio as gr
7
 
8
 
9
+ dummy_data = [1, 2, 3, 4]
10
+
11
+
12
+ def get_plot(model_name):
13
+ plt.plot(dummy_data)
14
+ plt.legend(model_name)
15
+ return plt.gcf()
 
 
 
 
 
 
 
 
 
 
16
 
17
  demo = gr.Blocks()
18
 
19
  with demo:
20
  with gr.Tabs():
21
  with gr.TabItem("Greedy Search"):
22
+ model_name = gr.Dropdown(
23
  choices=["DistilGPT2", "GPT2", "OPT 1.3B", "GPTJ-6B", "T5 Small", "T5 Base", "T5 Large", "T5 3B"],
24
  value="T5 Small",
25
  label="Model",
26
  interactive=True,
27
  )
28
+ get_plot(model_name)
29
  with gr.TabItem("Sample"):
30
  gr.Button("New Tiger")
31
  with gr.TabItem("Beam Search"):
 
39
  ["Pytorch Version", "1.11.0"],
40
  ["OS", "22.04 LTS (3090) / Debian 10 (other GPUs)"],
41
  ["CUDA", "11.6 (3090) / 11.3 (others GPUs)"],
42
+ ["Number of runs", "100 (the first run was discarded to ignore compilation time)"],
43
  ["Is there code to reproduce?", "Yes -- https://gist.github.com/gante/f0017e3f13ac11b0c02e4e4db351f52f"],
44
  ],
45
  )