Spaces:
Sleeping
Sleeping
fruitpicker01
commited on
Commit
•
10f64b7
1
Parent(s):
1eaf6bf
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import plotly.graph_objects as go
|
|
|
3 |
|
4 |
# Функция для создания спидометра
|
5 |
def create_gauge(value):
|
@@ -30,15 +31,9 @@ def create_gauge(value):
|
|
30 |
margin=dict(l=20, r=180, t=20, b=20)) # Отступы для центровки
|
31 |
return fig
|
32 |
|
33 |
-
#
|
34 |
-
def
|
35 |
-
return create_gauge(
|
36 |
-
|
37 |
-
def get_success_forecast_2():
|
38 |
-
return create_gauge(85)
|
39 |
-
|
40 |
-
def get_success_forecast_3():
|
41 |
-
return create_gauge(62)
|
42 |
|
43 |
# Функция для смены вкладки
|
44 |
def change_tab(id):
|
@@ -100,6 +95,10 @@ with gr.Blocks() as demo:
|
|
100 |
with gr.Row():
|
101 |
btn_check = gr.Button("Проверить", elem_id="check3")
|
102 |
btn_check.click(fn=change_tab, inputs=[gr.Number(value=3, visible=False)], outputs=tabs)
|
|
|
|
|
|
|
|
|
103 |
|
104 |
# Вкладка 4: Проверка
|
105 |
with gr.TabItem("Проверка", id=3):
|
@@ -137,5 +136,4 @@ with gr.Blocks() as demo:
|
|
137 |
success_forecast_3 = gr.Plot(value=get_success_forecast_3(), label="Прогноз успешности сообщения 3")
|
138 |
gr.HTML("</div>")
|
139 |
|
140 |
-
|
141 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import plotly.graph_objects as go
|
3 |
+
import random
|
4 |
|
5 |
# Функция для создания спидометра
|
6 |
def create_gauge(value):
|
|
|
31 |
margin=dict(l=20, r=180, t=20, b=20)) # Отступы для центровки
|
32 |
return fig
|
33 |
|
34 |
+
# Функция для генерации случайных значений спидометров
|
35 |
+
def generate_random_gauges():
|
36 |
+
return create_gauge(random.randint(60, 90)), create_gauge(random.randint(60, 90)), create_gauge(random.randint(60, 90))
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
# Функция для смены вкладки
|
39 |
def change_tab(id):
|
|
|
95 |
with gr.Row():
|
96 |
btn_check = gr.Button("Проверить", elem_id="check3")
|
97 |
btn_check.click(fn=change_tab, inputs=[gr.Number(value=3, visible=False)], outputs=tabs)
|
98 |
+
success_forecast_1 = gr.Plot()
|
99 |
+
success_forecast_2 = gr.Plot()
|
100 |
+
success_forecast_3 = gr.Plot()
|
101 |
+
btn_check.click(fn=generate_random_gauges, inputs=[], outputs=[success_forecast_1, success_forecast_2, success_forecast_3])
|
102 |
|
103 |
# Вкладка 4: Проверка
|
104 |
with gr.TabItem("Проверка", id=3):
|
|
|
136 |
success_forecast_3 = gr.Plot(value=get_success_forecast_3(), label="Прогноз успешности сообщения 3")
|
137 |
gr.HTML("</div>")
|
138 |
|
|
|
139 |
demo.launch()
|