Spaces:
Sleeping
Sleeping
fruitpicker01
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,45 +1,37 @@
|
|
1 |
import gradio as gr
|
2 |
import plotly.graph_objects as go
|
3 |
|
4 |
-
|
|
|
5 |
fig = go.Figure(go.Indicator(
|
6 |
-
mode="gauge+number
|
7 |
-
value=
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
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 |
-
|
43 |
-
|
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()
|