File size: 1,129 Bytes
47c50bf
12884f6
783515c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a86f009
47c50bf
 
783515c
 
 
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
import gradio as gr

import gradio as gr
import plotly.graph_objects as go

# Функция для создания спидометра
def create_gauge(value=76):
    fig = go.Figure(go.Indicator(
        mode="gauge+number",
        value=value,
        title={'text': "Success Rate"},
        gauge={'axis': {'range': [0, 100]},
               'bar': {'color': "darkblue"},
               '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': 76}}
    ))

    fig.update_layout(height=300)
    return fig

# Функция для отображения графика в Gradio
def show_gauge():
    return create_gauge(76)

# Создание интерфейса Gradio
with gr.Blocks() as demo:
    gr.Markdown("### Спидометр с вероятностью успеха")
    output = gr.Plot(label="Success Rate Gauge")
    demo.load(fn=show_gauge, inputs=[], outputs=output)

demo.launch()