Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -950,48 +950,55 @@ def callback(params):
|
|
950 |
def create_gradio_interface():
|
951 |
def greet(name):
|
952 |
return f"Hello {name}, welcome to the Gradio app!"
|
953 |
-
|
954 |
with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
955 |
-
state = gr.State({'authenticated':
|
|
|
956 |
if user_info:
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
985 |
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
login_url = login()
|
993 |
-
gr.Markdown(f"[Login with Google]({login_url})")
|
994 |
-
|
995 |
return demo
|
996 |
|
997 |
def main(params=None):
|
@@ -1003,4 +1010,102 @@ def main(params=None):
|
|
1003 |
if __name__ == "__main__":
|
1004 |
import sys
|
1005 |
params = sys.argv[1] if len(sys.argv) > 1 else None
|
1006 |
-
main(params)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
950 |
def create_gradio_interface():
|
951 |
def greet(name):
|
952 |
return f"Hello {name}, welcome to the Gradio app!"
|
|
|
953 |
with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
954 |
+
state = gr.State({'authenticated': False, 'user_info': {}})
|
955 |
+
|
956 |
if user_info:
|
957 |
+
state.value = {'authenticated': True, 'user_info': user_info}
|
958 |
+
|
959 |
+
def update_interface():
|
960 |
+
if state.value['authenticated']:
|
961 |
+
gr.Markdown(f"### Hello, {state.value['user_info']['name']}! Welcome to the Gradio App")
|
962 |
+
name = gr.Textbox(label="Enter your name")
|
963 |
+
greet_btn = gr.Button("Greet")
|
964 |
+
output = gr.Textbox(label="Greeting")
|
965 |
+
greet_btn.click(greet, inputs=name, outputs=output)
|
966 |
+
|
967 |
+
chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
|
968 |
+
choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
|
969 |
+
|
970 |
+
gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
|
971 |
+
chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!")
|
972 |
+
chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
|
973 |
+
bot_msg = chat_msg.then(bot, [chatbot, choice], [chatbot, gr.Audio(interactive=False, autoplay=True)])
|
974 |
+
bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
|
975 |
+
chatbot.like(print_like_dislike, None, None)
|
976 |
+
clear_button = gr.Button("Clear")
|
977 |
+
clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
|
978 |
+
|
979 |
+
audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
980 |
+
audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
|
981 |
+
|
982 |
+
gr.Markdown("<h1 style='color: red;'>Map</h1>", elem_id="location-markdown")
|
983 |
+
location_output = gr.HTML()
|
984 |
+
bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output])
|
985 |
+
|
986 |
+
weather_output = gr.HTML(value=fetch_local_weather())
|
987 |
+
news_output = gr.HTML(value=fetch_local_news())
|
988 |
+
events_output = gr.HTML(value=fetch_local_events())
|
989 |
+
|
990 |
+
image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
|
991 |
+
image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
|
992 |
+
image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
|
993 |
+
refresh_button = gr.Button("Refresh Images")
|
994 |
+
refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
|
995 |
|
996 |
+
else:
|
997 |
+
login_url = login()
|
998 |
+
gr.Markdown(f"<div style='text-align: right;'><a href='{login_url}' class='gr-button gr-button-primary'>Login with Google</a></div>")
|
999 |
+
|
1000 |
+
update_interface()
|
1001 |
+
|
|
|
|
|
|
|
1002 |
return demo
|
1003 |
|
1004 |
def main(params=None):
|
|
|
1010 |
if __name__ == "__main__":
|
1011 |
import sys
|
1012 |
params = sys.argv[1] if len(sys.argv) > 1 else None
|
1013 |
+
main(params)
|
1014 |
+
|
1015 |
+
|
1016 |
+
|
1017 |
+
|
1018 |
+
|
1019 |
+
|
1020 |
+
|
1021 |
+
|
1022 |
+
|
1023 |
+
|
1024 |
+
|
1025 |
+
|
1026 |
+
|
1027 |
+
|
1028 |
+
|
1029 |
+
|
1030 |
+
|
1031 |
+
|
1032 |
+
|
1033 |
+
|
1034 |
+
|
1035 |
+
|
1036 |
+
|
1037 |
+
|
1038 |
+
|
1039 |
+
|
1040 |
+
|
1041 |
+
|
1042 |
+
|
1043 |
+
|
1044 |
+
|
1045 |
+
|
1046 |
+
|
1047 |
+
|
1048 |
+
|
1049 |
+
|
1050 |
+
|
1051 |
+
|
1052 |
+
|
1053 |
+
|
1054 |
+
|
1055 |
+
|
1056 |
+
|
1057 |
+
|
1058 |
+
|
1059 |
+
# with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
1060 |
+
# state = gr.State({'authenticated': True})
|
1061 |
+
# if user_info:
|
1062 |
+
# gr.Markdown(f"### Hello, {user_info['name']}! Welcome to the Gradio App")
|
1063 |
+
# name = gr.Textbox(label="Enter your name")
|
1064 |
+
# greet_btn = gr.Button("Greet")
|
1065 |
+
# output = gr.Textbox(label="Greeting")
|
1066 |
+
# greet_btn.click(greet, inputs=name, outputs=output)
|
1067 |
+
|
1068 |
+
# chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
|
1069 |
+
# choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
|
1070 |
+
|
1071 |
+
# gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
|
1072 |
+
# chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!")
|
1073 |
+
# chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
|
1074 |
+
# bot_msg = chat_msg.then(bot, [chatbot, choice], [chatbot, gr.Audio(interactive=False, autoplay=True)])
|
1075 |
+
# bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
|
1076 |
+
# chatbot.like(print_like_dislike, None, None)
|
1077 |
+
# clear_button = gr.Button("Clear")
|
1078 |
+
# clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
|
1079 |
+
|
1080 |
+
# audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
|
1081 |
+
# audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
|
1082 |
+
|
1083 |
+
# gr.Markdown("<h1 style='color: red;'>Map</h1>", elem_id="location-markdown")
|
1084 |
+
# location_output = gr.HTML()
|
1085 |
+
# bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output])
|
1086 |
+
|
1087 |
+
# weather_output = gr.HTML(value=fetch_local_weather())
|
1088 |
+
# news_output = gr.HTML(value=fetch_local_news())
|
1089 |
+
# events_output = gr.HTML(value=fetch_local_events())
|
1090 |
+
|
1091 |
+
# image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
|
1092 |
+
# image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
|
1093 |
+
# image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
|
1094 |
+
# refresh_button = gr.Button("Refresh Images")
|
1095 |
+
# refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
|
1096 |
+
# else:
|
1097 |
+
# login_url = login()
|
1098 |
+
# gr.Markdown(f"[Login with Google]({login_url})")
|
1099 |
+
|
1100 |
+
# return demo
|
1101 |
+
|
1102 |
+
# def main(params=None):
|
1103 |
+
# if params:
|
1104 |
+
# callback(params)
|
1105 |
+
# demo = create_gradio_interface()
|
1106 |
+
# demo.launch()
|
1107 |
+
|
1108 |
+
# if __name__ == "__main__":
|
1109 |
+
# import sys
|
1110 |
+
# params = sys.argv[1] if len(sys.argv) > 1 else None
|
1111 |
+
# main(params)
|