Spaces:
Sleeping
Sleeping
File size: 1,512 Bytes
783515c 27bcd5b 783515c 27bcd5b 783515c 27bcd5b 783515c 27bcd5b 783515c 27bcd5b a86f009 47c50bf 27bcd5b 783515c 27bcd5b b8f348d 783515c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
import gradio as gr
import plotly.graph_objects as go
def create_fancy_gauge(value=76):
fig = go.Figure(go.Indicator(
mode="gauge+number+delta", # Добавим дельту для сравнения
value=value,
title={'text': "Success Rate", 'font': {'size': 24}},
delta={'reference': 70, 'increasing': {'color': "green"}},
gauge={
'axis': {'range': [0, 100], 'tickwidth': 1, 'tickcolor': "darkblue"},
'bar': {'color': "darkblue"},
'bgcolor': "white",
'borderwidth': 2,
'bordercolor': "gray",
'steps': [
{'range': [0, 50], 'color': 'lightgray'},
{'range': [50, 75], 'color': 'yellow'},
{'range': [75, 100], 'color': 'green'}
],
'threshold': {
'line': {'color': "red", 'width': 4},
'thickness': 0.75,
'value': value
}
}
))
fig.update_layout(
font={'color': "darkblue", 'family': "Arial"},
height=400,
margin={'t': 0, 'b': 0}
)
return fig
# Gradio интерфейс для отображения
def show_fancy_gauge():
return create_fancy_gauge(76)
with gr.Blocks() as demo:
gr.Markdown("### Улучшенный спидометр с вероятностью успеха")
output = gr.Plot(label="Success Rate Gauge")
demo.load(fn=show_fancy_gauge, inputs=[], outputs=output)
demo.launch() |