fruitpicker01 commited on
Commit
17c86fb
·
verified ·
1 Parent(s): 27bcd5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -35
app.py CHANGED
@@ -1,45 +1,37 @@
1
  import gradio as gr
2
  import plotly.graph_objects as go
3
 
4
- def create_fancy_gauge(value=76):
 
5
  fig = go.Figure(go.Indicator(
6
- mode="gauge+number+delta", # Добавим дельту для сравнения
7
- value=value,
8
- title={'text': "Success Rate", 'font': {'size': 24}},
9
- delta={'reference': 70, 'increasing': {'color': "green"}},
10
- gauge={
11
- 'axis': {'range': [0, 100], 'tickwidth': 1, 'tickcolor': "darkblue"},
12
- 'bar': {'color': "darkblue"},
13
- 'bgcolor': "white",
14
- 'borderwidth': 2,
15
- 'bordercolor': "gray",
16
- 'steps': [
17
- {'range': [0, 50], 'color': 'lightgray'},
18
- {'range': [50, 75], 'color': 'yellow'},
19
- {'range': [75, 100], 'color': 'green'}
20
- ],
21
- 'threshold': {
22
- 'line': {'color': "red", 'width': 4},
23
- 'thickness': 0.75,
24
- 'value': value
25
- }
26
- }
27
  ))
28
 
29
- fig.update_layout(
30
- font={'color': "darkblue", 'family': "Arial"},
31
- height=400,
32
- margin={'t': 0, 'b': 0}
33
- )
34
  return fig
35
 
36
- # Gradio интерфейс для отображения
37
- def show_fancy_gauge():
38
- return create_fancy_gauge(76)
39
-
40
  with gr.Blocks() as demo:
41
- gr.Markdown("### Улучшенный спидометр с вероятностью успеха")
42
- output = gr.Plot(label="Success Rate Gauge")
43
- demo.load(fn=show_fancy_gauge, inputs=[], outputs=output)
44
-
 
 
 
 
 
 
 
 
 
 
45
  demo.launch()
 
1
  import gradio as gr
2
  import plotly.graph_objects as go
3
 
4
+ # Function to create a speedometer gauge
5
+ def success_rate_gauge(success_value):
6
  fig = go.Figure(go.Indicator(
7
+ mode="gauge+number",
8
+ value=success_value,
9
+ gauge={'axis': {'range': [0, 100]},
10
+ 'bar': {'color': "green"},
11
+ 'steps': [
12
+ {'range': [0, 50], 'color': "red"},
13
+ {'range': [50, 75], 'color': "yellow"},
14
+ {'range': [75, 100], 'color': "green"}],
15
+ 'threshold': {'line': {'color': "black", 'width': 4}, 'thickness': 0.75, 'value': 76}}
 
 
 
 
 
 
 
 
 
 
 
 
16
  ))
17
 
18
+ fig.update_layout(height=400, width=500)
 
 
 
 
19
  return fig
20
 
21
+ # Gradio interface
 
 
 
22
  with gr.Blocks() as demo:
23
+ gr.Markdown("## Улучшенный спидометр с вероятностью успеха")
24
+
25
+ # Add a plot output widget
26
+ plot = gr.Plot(label="Success Rate Gauge")
27
+
28
+ # Function to update the plot
29
+ def update_plot():
30
+ return success_rate_gauge(76)
31
+
32
+ # Button to trigger the update
33
+ with gr.Row():
34
+ plot.render(update_plot())
35
+
36
+ # Launch Gradio interface
37
  demo.launch()