os1187 commited on
Commit
e4a74d9
·
1 Parent(s): 7a946a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -35
app.py CHANGED
@@ -3,18 +3,7 @@ import numpy as np
3
  import matplotlib.pyplot as plt
4
  import gradio as gr
5
 
6
- def plot_usage_volume(inputs):
7
- # Unpack the inputs
8
- system1 = inputs["system1"]
9
- users1 = inputs["users1"]
10
- timeline1 = inputs["timeline1"]
11
- system2 = inputs["system2"]
12
- users2 = inputs["users2"]
13
- timeline2 = inputs["timeline2"]
14
- system3 = inputs["system3"]
15
- users3 = inputs["users3"]
16
- timeline3 = inputs["timeline3"]
17
-
18
  # Create empty dataframe to hold usage data
19
  data = pd.DataFrame(columns=["System", "Month", "Usage"])
20
 
@@ -49,7 +38,7 @@ def plot_usage_volume(inputs):
49
  axs[1].set_ylabel("Usage Volume")
50
  axs[1].set_title("Aggregated Usage Volume for All Systems")
51
 
52
- #Set xticks to only show every 3 months
53
  axs[0].set_xticks(aggregated_data.index[::3])
54
  axs[1].set_xticks(aggregated_data.index[::3])
55
 
@@ -57,31 +46,10 @@ def plot_usage_volume(inputs):
57
  axs[0].set_xticklabels(aggregated_data["Month"][::3], rotation=45, fontsize=10)
58
  axs[1].set_xticklabels(aggregated_data["Month"][::3], rotation=45, fontsize=10)
59
 
60
- # Add a legend to the plot
61
  axs[0].legend()
62
  axs[1].legend()
63
 
64
  # Return the plot as a Gradio output
65
  return gr.outputs.Image(fig)
66
 
67
- # Create input components for the Gradio app
68
- system1 = gr.inputs.Textbox(label="System 1 Name", default="System1")
69
- users1 = gr.inputs.Slider(minimum=100, maximum=10000, step=100, default=1000, label="System 1 Estimated Users")
70
- timeline1 = gr.inputs.Slider(minimum=6, maximum=48, step=6, default=12, label="System 1 Timeline (Months)")
71
-
72
- # Add input components for the remaining two systems
73
- system2 = gr.inputs.Textbox(label="System 2 Name", default="System2")
74
- users2 = gr.inputs.Slider(minimum=100, maximum=10000, step=100, default=500, label="System 2 Estimated Users")
75
- timeline2 = gr.inputs.Slider(minimum=6, maximum=48, step=6, default=18, label="System 2 Timeline (Months)")
76
-
77
- system3 = gr.inputs.Textbox(label="System 3 Name", default="System3")
78
- users3 = gr.inputs.Slider(minimum=100, maximum=10000, step=100, default=2000, label="System 3 Estimated Users")
79
- timeline3 = gr.inputs.Slider(minimum=6, maximum=48, step=6, default=24, label="System 3 Timeline (Months)")
80
-
81
- # Create the Gradio interface
82
- inputs = [system1, users1, timeline1, system2, users2, timeline2, system3, users3, timeline3]
83
- output = gr.outputs.Image(type='numpy')
84
- title = "System Rollout Usage Volume Plot"
85
- description = "Enter the rollout parameters for three different systems and see the resulting usage volume plot."
86
-
87
- gr.Interface(plot_usage_volume, inputs, gr.outputs.Image(type="numpy"), title=title, description=description).launch(share=False)
 
3
  import matplotlib.pyplot as plt
4
  import gradio as gr
5
 
6
+ def plot_usage_volume(system1, users1, timeline1, system2, users2, timeline2, system3, users3, timeline3):
 
 
 
 
 
 
 
 
 
 
 
7
  # Create empty dataframe to hold usage data
8
  data = pd.DataFrame(columns=["System", "Month", "Usage"])
9
 
 
38
  axs[1].set_ylabel("Usage Volume")
39
  axs[1].set_title("Aggregated Usage Volume for All Systems")
40
 
41
+ # Set xticks to only show every 3 months
42
  axs[0].set_xticks(aggregated_data.index[::3])
43
  axs[1].set_xticks(aggregated_data.index[::3])
44
 
 
46
  axs[0].set_xticklabels(aggregated_data["Month"][::3], rotation=45, fontsize=10)
47
  axs[1].set_xticklabels(aggregated_data["Month"][::3], rotation=45, fontsize=10)
48
 
49
+ # Add a legend to the plot
50
  axs[0].legend()
51
  axs[1].legend()
52
 
53
  # Return the plot as a Gradio output
54
  return gr.outputs.Image(fig)
55