Spaces:
Running
Running
Commit
·
f727ce9
1
Parent(s):
15ce179
update audio and slider
Browse files
app.py
CHANGED
@@ -34,11 +34,7 @@ def get_risk_status(avg_kss, slope):
|
|
34 |
elif avg_kss < 40:
|
35 |
return "주의", "image3.png", "약간 피로해보여요.잠시 쉬었다 가시는걸 추천드려요.mp3"
|
36 |
elif avg_kss < 75:
|
37 |
-
return "위험", "image4.png",
|
38 |
-
"졸음이 온다면 차라리 관속에 누우세요.mp3",
|
39 |
-
"미치셨습니까 휴먼.mp3",
|
40 |
-
"지금자면 병원에서 깨실걸요 ㅋㅋ.mp3"
|
41 |
-
])
|
42 |
else:
|
43 |
return "매우 위험", "image5.png", "사이렌.mp3"
|
44 |
|
@@ -58,7 +54,7 @@ def analyze_frame(image):
|
|
58 |
)
|
59 |
|
60 |
if r.status_code != 200:
|
61 |
-
return "결과 없음", "image1.png", None
|
62 |
|
63 |
top_predictions_3 = sorted(r.json()['predictions'], key=lambda x: x['probability'], reverse=True)[:3]
|
64 |
top_prediction_1 = top_predictions_3[0]
|
@@ -75,16 +71,10 @@ def analyze_frame(image):
|
|
75 |
results_text += f"🔹 가장 유사한 행동: {action_name} | KSS 점수: {kss_score}\n"
|
76 |
results_text += f"📊 현재 위험 수준: {risk_state}\n"
|
77 |
|
78 |
-
|
79 |
-
if audio_file:
|
80 |
-
audio_output = gr.Audio(value=audio_file, autoplay=True)
|
81 |
-
else:
|
82 |
-
audio_output = None
|
83 |
-
|
84 |
-
return results_text, risk_image, audio_output
|
85 |
|
86 |
except Exception as e:
|
87 |
-
return f"오류 발생: {str(e)}", "image1.png", None
|
88 |
|
89 |
with gr.Blocks(
|
90 |
analytics_enabled=False,
|
@@ -97,7 +87,8 @@ with gr.Blocks(
|
|
97 |
with gr.Column():
|
98 |
output_label = gr.Textbox(label="🔍 분석 결과")
|
99 |
output_image = gr.Image(label="📊 위험 수준", height=200, width=200)
|
100 |
-
output_audio = gr.Audio(label="🔊 음성 경고")
|
|
|
101 |
|
102 |
input_img.stream(analyze_frame, [input_img], [output_label, output_image, output_audio])
|
103 |
|
|
|
34 |
elif avg_kss < 40:
|
35 |
return "주의", "image3.png", "약간 피로해보여요.잠시 쉬었다 가시는걸 추천드려요.mp3"
|
36 |
elif avg_kss < 75:
|
37 |
+
return "위험", "image4.png", "미치셨습니까 휴먼.mp3"
|
|
|
|
|
|
|
|
|
38 |
else:
|
39 |
return "매우 위험", "image5.png", "사이렌.mp3"
|
40 |
|
|
|
54 |
)
|
55 |
|
56 |
if r.status_code != 200:
|
57 |
+
return "결과 없음", "image1.png", None, None
|
58 |
|
59 |
top_predictions_3 = sorted(r.json()['predictions'], key=lambda x: x['probability'], reverse=True)[:3]
|
60 |
top_prediction_1 = top_predictions_3[0]
|
|
|
71 |
results_text += f"🔹 가장 유사한 행동: {action_name} | KSS 점수: {kss_score}\n"
|
72 |
results_text += f"📊 현재 위험 수준: {risk_state}\n"
|
73 |
|
74 |
+
return results_text, risk_image, audio_file, avg_kss
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
except Exception as e:
|
77 |
+
return f"오류 발생: {str(e)}", "image1.png", None, None
|
78 |
|
79 |
with gr.Blocks(
|
80 |
analytics_enabled=False,
|
|
|
87 |
with gr.Column():
|
88 |
output_label = gr.Textbox(label="🔍 분석 결과")
|
89 |
output_image = gr.Image(label="📊 위험 수준", height=200, width=200)
|
90 |
+
output_audio = gr.Audio(type='filepath', label="🔊 음성 경고", autoplay=True, loop=True)
|
91 |
+
output_slider = gr.Slider(minimum=0, maximum=100, step=1, label="⚠️ 위험 수준")
|
92 |
|
93 |
input_img.stream(analyze_frame, [input_img], [output_label, output_image, output_audio])
|
94 |
|