Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -480,14 +480,14 @@ def get_map_from_summary(summary_txt):
|
|
480 |
for idx in tqdm(cameraimg_df.index, desc="Processing Traffic Cameras"):
|
481 |
if cameraimg_df["CameraID"][idx] in list(nearest_cam_df["CameraID"]):
|
482 |
print('added nearby camera', nearest_cam_df["Description"][idx])
|
483 |
-
html = '<
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
iframe = folium.IFrame(html, width=
|
489 |
-
|
490 |
-
popup = folium.Popup(iframe,
|
491 |
|
492 |
folium.Marker(location=[nearest_cam_df["Latitude"][idx], nearest_cam_df["Longitude"][idx]],
|
493 |
icon=folium.Icon(color='blue'),
|
@@ -537,14 +537,14 @@ async def a_get_map_from_summary(summary_txt, get_num_cameras=3):
|
|
537 |
for idx in tqdm(cameraimg_df.index, desc="Processing Traffic Cameras"):
|
538 |
if cameraimg_df["CameraID"][idx] in list(nearest_cam_df["CameraID"]):
|
539 |
print('added nearby camera', nearest_cam_df["Description"][idx])
|
540 |
-
html = '<
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
iframe = folium.IFrame(html, width=
|
546 |
-
|
547 |
-
popup = folium.Popup(iframe,
|
548 |
|
549 |
folium.Marker(location=[nearest_cam_df["Latitude"][idx], nearest_cam_df["Longitude"][idx]],
|
550 |
icon=folium.Icon(color='blue'),
|
@@ -848,7 +848,8 @@ function refresh() {
|
|
848 |
}
|
849 |
'''
|
850 |
|
851 |
-
trans_textbox = gr.Textbox('Transcript',lines=10,max_lines=19, autoscroll = False, label = 'Edit road names as required (e.g. Lawney --> Lornie)', interactive = True)
|
|
|
852 |
summ_textbox = gr.Textbox('Summary',lines=10,max_lines=19, autoscroll = False)
|
853 |
# recc_textbox1 = gr.Textbox(label="SCDF", max_lines=8, show_copy_button=True)
|
854 |
# recc_textbox2 = gr.Textbox(label="LTA", max_lines=8, show_copy_button=True)
|
@@ -859,8 +860,17 @@ with gr.Blocks(js=js) as demo:
|
|
859 |
# summ_textbox = gr.Textbox('Summary')
|
860 |
gr.Markdown("Emergency Responder Copilot Demonstrator")
|
861 |
isOpen = False
|
862 |
-
|
863 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
864 |
input_audio = gr.Audio(
|
865 |
sources=["microphone"],
|
866 |
type = 'filepath',
|
@@ -878,11 +888,11 @@ with gr.Blocks(js=js) as demo:
|
|
878 |
examples=[\
|
879 |
# ],
|
880 |
# "audio/call_711.mp3", \
|
881 |
-
"audio/
|
882 |
cache_examples=True,
|
883 |
allow_flagging = 'never'
|
884 |
)
|
885 |
-
with gr.Tab("Summarisation from
|
886 |
trans2summary = gr.Interface(
|
887 |
fn=get_summary_from_transcript,
|
888 |
inputs=trans_textbox,
|
@@ -890,15 +900,6 @@ with gr.Blocks(js=js) as demo:
|
|
890 |
allow_flagging = 'never'
|
891 |
)
|
892 |
# trans_textbox.change(lambda x: gr.Tab("Summarisation from Audio"), inputs=[trans_textbox], outputs=[tab2], scroll_to_output = True)
|
893 |
-
|
894 |
-
outs_textbox = gr.Textbox("Recommendations outputs will appear here once summary is generated from audio transcript.",lines=1,max_lines=1, autoscroll = False, show_label= False)
|
895 |
-
with gr.Accordion("Recommendations output and Locations on Map", open=True, visible = isOpen) as img:
|
896 |
-
with gr.Row():
|
897 |
-
recc_textbox1 = gr.Textbox(label="SCDF", max_lines=8, show_copy_button=True, autoscroll = False)
|
898 |
-
recc_textbox2 = gr.Textbox(label="LTA", max_lines=8, show_copy_button=True, autoscroll = False)
|
899 |
-
recc_textbox3 = gr.Textbox(label="Traffic Police", max_lines=8, show_copy_button=True, autoscroll = False)
|
900 |
-
# gr.Markdown(loc)
|
901 |
-
map_gr = Folium(value=folium.Map(location=[1.2879, 103.8517], zoom_start=12), height=400)
|
902 |
|
903 |
|
904 |
|
|
|
480 |
for idx in tqdm(cameraimg_df.index, desc="Processing Traffic Cameras"):
|
481 |
if cameraimg_df["CameraID"][idx] in list(nearest_cam_df["CameraID"]):
|
482 |
print('added nearby camera', nearest_cam_df["Description"][idx])
|
483 |
+
html = '<h3 style="display:inline;">{}</h3><div>{}</div><img style="width:320; height:240;" src="data:image/jpeg;base64,{}">'.format(
|
484 |
+
nearest_cam_df["Description"][idx],
|
485 |
+
nearest_cam_df["time_retrieved"][idx],
|
486 |
+
nearest_cam_df["encoded_img"][idx]
|
487 |
+
)
|
488 |
+
iframe = folium.IFrame(html, width=320+40, height=240+60)
|
489 |
+
|
490 |
+
popup = folium.Popup(iframe, max_height=350)
|
491 |
|
492 |
folium.Marker(location=[nearest_cam_df["Latitude"][idx], nearest_cam_df["Longitude"][idx]],
|
493 |
icon=folium.Icon(color='blue'),
|
|
|
537 |
for idx in tqdm(cameraimg_df.index, desc="Processing Traffic Cameras"):
|
538 |
if cameraimg_df["CameraID"][idx] in list(nearest_cam_df["CameraID"]):
|
539 |
print('added nearby camera', nearest_cam_df["Description"][idx])
|
540 |
+
html = '<h3 style="display:inline;">{}</h3><div>{}</div><img style="width:320; height:240;" src="data:image/jpeg;base64,{}">'.format(
|
541 |
+
nearest_cam_df["Description"][idx],
|
542 |
+
nearest_cam_df["time_retrieved"][idx],
|
543 |
+
nearest_cam_df["encoded_img"][idx]
|
544 |
+
)
|
545 |
+
iframe = folium.IFrame(html, width=320+40, height=240+60)
|
546 |
+
|
547 |
+
popup = folium.Popup(iframe, max_height=350)
|
548 |
|
549 |
folium.Marker(location=[nearest_cam_df["Latitude"][idx], nearest_cam_df["Longitude"][idx]],
|
550 |
icon=folium.Icon(color='blue'),
|
|
|
848 |
}
|
849 |
'''
|
850 |
|
851 |
+
#trans_textbox = gr.Textbox('Transcript',lines=10,max_lines=19, autoscroll = False, label = 'Edit road names as required (e.g. Lawney --> Lornie)', interactive = True)
|
852 |
+
trans_textbox = gr.Textbox('Transcript',lines=10,max_lines=19, autoscroll = False, interactive = False)
|
853 |
summ_textbox = gr.Textbox('Summary',lines=10,max_lines=19, autoscroll = False)
|
854 |
# recc_textbox1 = gr.Textbox(label="SCDF", max_lines=8, show_copy_button=True)
|
855 |
# recc_textbox2 = gr.Textbox(label="LTA", max_lines=8, show_copy_button=True)
|
|
|
860 |
# summ_textbox = gr.Textbox('Summary')
|
861 |
gr.Markdown("Emergency Responder Copilot Demonstrator")
|
862 |
isOpen = False
|
863 |
+
|
864 |
+
outs_textbox = gr.Textbox("Recommendations outputs will appear here once summary is generated from audio transcript.",lines=1,max_lines=1, autoscroll = False, show_label= False)
|
865 |
+
with gr.Accordion("Recommendations output and Locations on Map", open=True, visible = isOpen) as img:
|
866 |
+
with gr.Row():
|
867 |
+
recc_textbox1 = gr.Textbox(label="SCDF", max_lines=10, show_copy_button=True, autoscroll = False)
|
868 |
+
recc_textbox2 = gr.Textbox(label="LTA", max_lines=10, show_copy_button=True, autoscroll = False)
|
869 |
+
recc_textbox3 = gr.Textbox(label="Traffic Police", max_lines=10, show_copy_button=True, autoscroll = False)
|
870 |
+
# gr.Markdown(loc)
|
871 |
+
map_gr = Folium(value=folium.Map(location=[1.2879, 103.8517], zoom_start=12), height=400)
|
872 |
+
|
873 |
+
with gr.Tab("Transcript from Audio"):
|
874 |
input_audio = gr.Audio(
|
875 |
sources=["microphone"],
|
876 |
type = 'filepath',
|
|
|
888 |
examples=[\
|
889 |
# ],
|
890 |
# "audio/call_711.mp3", \
|
891 |
+
"audio/example1.m4a", "audio/example2.m4a"],
|
892 |
cache_examples=True,
|
893 |
allow_flagging = 'never'
|
894 |
)
|
895 |
+
with gr.Tab("Summarisation from Transcript") as tab2:
|
896 |
trans2summary = gr.Interface(
|
897 |
fn=get_summary_from_transcript,
|
898 |
inputs=trans_textbox,
|
|
|
900 |
allow_flagging = 'never'
|
901 |
)
|
902 |
# trans_textbox.change(lambda x: gr.Tab("Summarisation from Audio"), inputs=[trans_textbox], outputs=[tab2], scroll_to_output = True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
903 |
|
904 |
|
905 |
|