Spaces:
Running
Running
Commit
·
2a23d6e
1
Parent(s):
3349df6
add sound
Browse files
alert.wav
ADDED
Binary file (36.3 kB). View file
|
|
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import requests
|
3 |
from io import BytesIO
|
4 |
|
@@ -18,7 +19,7 @@ def abnormal_stream(image):
|
|
18 |
)
|
19 |
|
20 |
if r.status_code != 200:
|
21 |
-
return {'확인불가': 1.0, r.status_code: 0.0, r.text: 0.0}
|
22 |
|
23 |
output_dict = {}
|
24 |
|
@@ -27,7 +28,9 @@ def abnormal_stream(image):
|
|
27 |
probability = item['probability']
|
28 |
output_dict[tag_name] = probability
|
29 |
|
30 |
-
|
|
|
|
|
31 |
|
32 |
except Exception as e:
|
33 |
return {str(e): 1.0}
|
@@ -42,7 +45,8 @@ with gr.Blocks(
|
|
42 |
input_img = gr.Image(sources=["webcam"], type="pil")
|
43 |
with gr.Column():
|
44 |
output_label = gr.Label()
|
45 |
-
|
|
|
46 |
|
47 |
if __name__ == "__main__":
|
48 |
demo.launch(favicon_path='./favicon.png', show_api=False)
|
|
|
1 |
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
import requests
|
4 |
from io import BytesIO
|
5 |
|
|
|
19 |
)
|
20 |
|
21 |
if r.status_code != 200:
|
22 |
+
return {'확인불가': 1.0, r.status_code: 0.0, r.text: 0.0}, None
|
23 |
|
24 |
output_dict = {}
|
25 |
|
|
|
28 |
probability = item['probability']
|
29 |
output_dict[tag_name] = probability
|
30 |
|
31 |
+
with open('alert.wav', 'rb') as f:
|
32 |
+
output_audio = f.read()
|
33 |
+
return output_dict, output_audio
|
34 |
|
35 |
except Exception as e:
|
36 |
return {str(e): 1.0}
|
|
|
45 |
input_img = gr.Image(sources=["webcam"], type="pil")
|
46 |
with gr.Column():
|
47 |
output_label = gr.Label()
|
48 |
+
output_audio = gr.Audio(autoplay=True)
|
49 |
+
dep = input_img.stream(abnormal_stream, [input_img], [output_label, output_audio])
|
50 |
|
51 |
if __name__ == "__main__":
|
52 |
demo.launch(favicon_path='./favicon.png', show_api=False)
|