Spaces:
Running
Running
Niki Zhang
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -686,15 +686,15 @@ prompt_list = [
|
|
686 |
'Wiki_caption: {Wiki_caption}, You have to help me understand what is about the selected object and list one object judgement and one whole art judgement(how successful do you think the artist was?) as markdown outline with appropriate emojis that describes what you see according to the image and wiki caption. Each point listed is to be in {language} language, with a response length of about {length} words.'
|
687 |
],
|
688 |
[
|
689 |
-
"When generating the answer, you should tell others that you are
|
690 |
-
"When generating the answer, you should tell others that you are
|
691 |
-
"When generating the answer, you should tell others that you are
|
692 |
"When generating the answer, you should tell others that you are one of the creators of these paintings and generate the text in the tone and manner as if you are the creator of the painting. According to image and wiki_caption {Wiki_caption}, You have to help me understand what is about the selected object and list one object judgement and one whole art judgement(how successful do you think the artist was?) as markdown outline with appropriate emojis that describes what you see according to the image and wiki caption. Please generate the above points in the tone and manner as if you are the creator of this painting and start every sentence with I. Each point listed is to be in {language} language, with a response length of about {length} words.",
|
693 |
],
|
694 |
[
|
695 |
'When generating answers, you should tell people that you are the object itself that was selected, and generate text in the tone and manner in which you are the object or the person. You have to help me understand what is about the selected object and list one fact and one analysis and one interpret as markdown outline with appropriate emojis that describes what you see according to the image and {Wiki_caption}. Please generate the above points in the tone and manner as if you are the object and start every sentence with I. Please generate the above points in the tone and manner as if you are the object of this painting and start every sentence with I. Each point listed is to be in {language} language, with a response length of about {length} words.',
|
696 |
-
'When generating answers, you should tell people that you are the object itself that was selected, and generate text in the tone and manner in which you are the object or the person. You have to help me understand what is about the selected object and list one fact and one analysis as markdown outline with appropriate emojis that describes what you see according to the image and {Wiki_caption}. Please generate the above points in the tone and manner as if you are the object and start every sentence with I. Please generate the above points in the tone and manner as if you are the object of this painting and start every sentence with I. Each point listed is to be in {language} language, with a response length of about {length} words.',
|
697 |
-
'When generating answers, you should tell people that you are the object itself that was selected, and generate text in the tone and manner in which you are the object or the person. You have to help me understand what is about the selected object and list one fact and one analysis and one interpret as markdown outline with appropriate emojis that describes what you see according to the image and {Wiki_caption}. Please generate the above points in the tone and manner as if you are the object and start every sentence with I. Please generate the above points in the tone and manner as if you are the object of this painting and start every sentence with I. Each point listed is to be in {language} language, with a response length of about {length} words.',
|
698 |
'When generating answers, you should tell people that you are the object itself that was selected, and generate text in the tone and manner in which you are the object or the person. According to image and wiki_caption {Wiki_caption}, You have to help me understand what is about the selected object and list one object judgement and one whole art judgement(how successful do you think the artist was?) as markdown outline with appropriate emojis that describes what you see according to the image and wiki caption. Please generate the above points in the tone and manner as if you are the object of this painting and start every sentence with I. Each point listed is to be in {language} language, with a response length of about {length} words.',
|
699 |
]
|
700 |
]
|
@@ -708,7 +708,7 @@ recommendation_prompt=[
|
|
708 |
Each bullet point should be in {language} language, with a response length of about {length} words.
|
709 |
''',
|
710 |
'''
|
711 |
-
When generating answers, you should tell people that
|
712 |
|
713 |
First identify what the object of the first painting is, you save yourself as the parameter: {{object}}, do not need to tell me, the following will use the. I want you to write the recommendation reason according to the following content, as a markdown outline with appropriate emojis that describe what you see according to the painting:
|
714 |
|
@@ -942,12 +942,12 @@ def update_click_state(click_state, caption, click_mode):
|
|
942 |
async def chat_input_callback(*args):
|
943 |
visual_chatgpt, chat_input, click_state, state, aux_state ,language , autoplay,gender,api_key,image_input,log_state,history,persona = args
|
944 |
message = chat_input["text"]
|
945 |
-
if persona=="
|
946 |
prompt="Please help me answer the question with this painting {question} in {language}."
|
947 |
-
elif persona=="Artist":
|
948 |
prompt="When generating the answer, you should tell others that you are one of the creators of these paintings and generate the text in the tone and manner as if you are the creator of the painting. Please help me answer the question with this painting {question} in {language}."
|
949 |
else:
|
950 |
-
prompt="
|
951 |
prompt=prompt.format(question=message, language=language)
|
952 |
|
953 |
if visual_chatgpt is not None:
|
@@ -1940,7 +1940,7 @@ def create_ui():
|
|
1940 |
clear_button_click = gr.Button(value="Reset", interactive=True,elem_classes="tools_button",icon="assets/icons/recycle.png")
|
1941 |
|
1942 |
auto_play = gr.Checkbox(
|
1943 |
-
label="Check to autoplay audio", value=
|
1944 |
output_audio = gr.HTML(
|
1945 |
label="Synthesised Audio", elem_classes="custom-output", visible=False)
|
1946 |
with gr.Tab("Base(GPT Power)",visible=False) as base_tab:
|
@@ -2654,19 +2654,12 @@ def create_ui():
|
|
2654 |
# name_label_base2, artist_label_base2, year_label_base2, material_label_base2,name_label_traj, artist_label_traj, year_label_traj, material_label_traj, \
|
2655 |
# paragraph,artist])
|
2656 |
|
2657 |
-
|
2658 |
-
# [chatbot, state, origin_image, click_state, image_input, image_input_base, sketcher_input,
|
2659 |
-
# image_embedding, original_size, input_size,name_label,artist_label,year_label,material_label,name_label_base, artist_label_base, year_label_base, material_label_base,paragraph,artist])
|
2660 |
-
# sketcher_input.upload(upload_callback, [sketcher_input, state, visual_chatgpt, openai_api_key],
|
2661 |
-
# [chatbot, state, origin_image, click_state, image_input, image_input_base, sketcher_input,
|
2662 |
-
# image_embedding, original_size, input_size,name_label,artist_label,year_label,material_label,name_label_base, artist_label_base, year_label_base, material_label_base,paragraph,artist])
|
2663 |
chat_input.submit(chat_input_callback, [visual_chatgpt, chat_input, click_state, state, aux_state,language,auto_play,gender,openai_api_key,image_path,log_state,history_log,naritive],
|
2664 |
[chatbot, state, aux_state,output_audio,log_state,history_log])
|
2665 |
# chat_input.submit(lambda: "", None, chat_input)
|
2666 |
chat_input.submit(lambda: {"text": ""}, None, chat_input)
|
2667 |
-
|
2668 |
-
# [chatbot, state, aux_state,output_audio])
|
2669 |
-
# submit_button_text.click(lambda: "", None, chat_input)
|
2670 |
example_image.change(upload_callback, [example_image, state, log_state, task_type, visual_chatgpt, openai_api_key,language,naritive,history_log,auto_play,session_type],
|
2671 |
[chatbot, state, origin_image, click_state, image_input, image_input_base, sketcher_input,image_input_base_2,
|
2672 |
image_embedding, original_size, input_size,name_label,artist_label,year_label,material_label,name_label_base, artist_label_base, year_label_base, material_label_base, \
|
@@ -2703,6 +2696,15 @@ def create_ui():
|
|
2703 |
# click_tab.select(on_click_tab_selected, outputs=[modules_need_gpt1,modules_not_need_gpt2,modules_need_gpt0,modules_need_gpt2])
|
2704 |
# base_tab.select(on_base_selected, outputs=[modules_need_gpt0,modules_need_gpt2,modules_not_need_gpt2,modules_need_gpt1])
|
2705 |
# base_tab2.select(on_base_selected, outputs=[modules_not_need_gpt2,modules_not_need_gpt2,modules_need_gpt0,modules_need_gpt1])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2706 |
|
2707 |
|
2708 |
|
|
|
686 |
'Wiki_caption: {Wiki_caption}, You have to help me understand what is about the selected object and list one object judgement and one whole art judgement(how successful do you think the artist was?) as markdown outline with appropriate emojis that describes what you see according to the image and wiki caption. Each point listed is to be in {language} language, with a response length of about {length} words.'
|
687 |
],
|
688 |
[
|
689 |
+
"When generating the answer, you should tell others that you are the creator of this painting and generate the text in the tone and manner as if you are the creator of this painting. You have to help me understand what is about the selected object and list one fact (describes the selected object but does not include analysis) as markdown outline with appropriate emojis that describes what you see according to the image and {Wiki_caption}. Please generate the above points in the tone and manner as if you are the creator of this painting and start every sentence with I. Please generate the above points in the tone and manner as if you are the creator of this painting and start every sentence with I. Each point listed is to be in {language} language, with a response length of about {length} words.",
|
690 |
+
"When generating the answer, you should tell others that you are the creator of this painting and generate the text in the tone and manner as if you are the creator of this painting. You have to help me understand what is about the selected object and list one fact and one analysis from art appreciation perspective as markdown outline with appropriate emojis that describes what you see according to the image and {Wiki_caption}. Please generate the above points in the tone and manner as if you are the creator of this painting and start every sentence with I. Please generate the above points in the tone and manner as if you are the creator of this painting and start every sentence with I. Each point listed is to be in {language} language, with a response length of about {length} words.",
|
691 |
+
"When generating the answer, you should tell others that you are the creator of this painting and generate the text in the tone and manner as if you are the creator of this painting. You have to help me understand what is about the selected object and list one fact, one analysis, and one interpret from art appreciation perspective as markdown outline with appropriate emojis that describes what you see according to the image and {Wiki_caption}. Please generate the above points in the tone and manner as if you are the creator of this painting and start every sentence with I. Please generate the above points in the tone and manner as if you are the creator of this painting and start every sentence with I. Each point listed is to be in {language} language, with a response length of about {length} words.",
|
692 |
"When generating the answer, you should tell others that you are one of the creators of these paintings and generate the text in the tone and manner as if you are the creator of the painting. According to image and wiki_caption {Wiki_caption}, You have to help me understand what is about the selected object and list one object judgement and one whole art judgement(how successful do you think the artist was?) as markdown outline with appropriate emojis that describes what you see according to the image and wiki caption. Please generate the above points in the tone and manner as if you are the creator of this painting and start every sentence with I. Each point listed is to be in {language} language, with a response length of about {length} words.",
|
693 |
],
|
694 |
[
|
695 |
'When generating answers, you should tell people that you are the object itself that was selected, and generate text in the tone and manner in which you are the object or the person. You have to help me understand what is about the selected object and list one fact and one analysis and one interpret as markdown outline with appropriate emojis that describes what you see according to the image and {Wiki_caption}. Please generate the above points in the tone and manner as if you are the object and start every sentence with I. Please generate the above points in the tone and manner as if you are the object of this painting and start every sentence with I. Each point listed is to be in {language} language, with a response length of about {length} words.',
|
696 |
+
'When generating answers, you should tell people that you are the object itself that was selected, and generate text in the tone and manner in which you are the object or the person. You have to help me understand what is about the selected object and list one fact and one analysis from art appreciation perspective as markdown outline with appropriate emojis that describes what you see according to the image and {Wiki_caption}. Please generate the above points in the tone and manner as if you are the object and start every sentence with I. Please generate the above points in the tone and manner as if you are the object of this painting and start every sentence with I. Each point listed is to be in {language} language, with a response length of about {length} words.',
|
697 |
+
'When generating answers, you should tell people that you are the object itself that was selected, and generate text in the tone and manner in which you are the object or the person. You have to help me understand what is about the selected object and list one fact and one analysis from art appreciation perspective and one interpret as markdown outline with appropriate emojis that describes what you see according to the image and {Wiki_caption}. Please generate the above points in the tone and manner as if you are the object and start every sentence with I. Please generate the above points in the tone and manner as if you are the object of this painting and start every sentence with I. Each point listed is to be in {language} language, with a response length of about {length} words.',
|
698 |
'When generating answers, you should tell people that you are the object itself that was selected, and generate text in the tone and manner in which you are the object or the person. According to image and wiki_caption {Wiki_caption}, You have to help me understand what is about the selected object and list one object judgement and one whole art judgement(how successful do you think the artist was?) as markdown outline with appropriate emojis that describes what you see according to the image and wiki caption. Please generate the above points in the tone and manner as if you are the object of this painting and start every sentence with I. Each point listed is to be in {language} language, with a response length of about {length} words.',
|
699 |
]
|
700 |
]
|
|
|
708 |
Each bullet point should be in {language} language, with a response length of about {length} words.
|
709 |
''',
|
710 |
'''
|
711 |
+
When generating answers, you should tell people that I am the creator of painting you were looking at earlier itself, and generate text in the tone and manner in which you are the creator of painting were looking at earlier.
|
712 |
|
713 |
First identify what the object of the first painting is, you save yourself as the parameter: {{object}}, do not need to tell me, the following will use the. I want you to write the recommendation reason according to the following content, as a markdown outline with appropriate emojis that describe what you see according to the painting:
|
714 |
|
|
|
942 |
async def chat_input_callback(*args):
|
943 |
visual_chatgpt, chat_input, click_state, state, aux_state ,language , autoplay,gender,api_key,image_input,log_state,history,persona = args
|
944 |
message = chat_input["text"]
|
945 |
+
if persona == "Narrator":
|
946 |
prompt="Please help me answer the question with this painting {question} in {language}."
|
947 |
+
elif persona =="Artist":
|
948 |
prompt="When generating the answer, you should tell others that you are one of the creators of these paintings and generate the text in the tone and manner as if you are the creator of the painting. Please help me answer the question with this painting {question} in {language}."
|
949 |
else:
|
950 |
+
prompt="When generating answers, you should tell people that you are the object itself that was selected, and generate text in the tone and manner in which you are the object or the person. Please help me answer the question with this painting {question} in {language}."
|
951 |
prompt=prompt.format(question=message, language=language)
|
952 |
|
953 |
if visual_chatgpt is not None:
|
|
|
1940 |
clear_button_click = gr.Button(value="Reset", interactive=True,elem_classes="tools_button",icon="assets/icons/recycle.png")
|
1941 |
|
1942 |
auto_play = gr.Checkbox(
|
1943 |
+
label="Check to autoplay audio", value=True, elem_classes="custom-autoplay",visible=False)
|
1944 |
output_audio = gr.HTML(
|
1945 |
label="Synthesised Audio", elem_classes="custom-output", visible=False)
|
1946 |
with gr.Tab("Base(GPT Power)",visible=False) as base_tab:
|
|
|
2654 |
# name_label_base2, artist_label_base2, year_label_base2, material_label_base2,name_label_traj, artist_label_traj, year_label_traj, material_label_traj, \
|
2655 |
# paragraph,artist])
|
2656 |
|
2657 |
+
|
|
|
|
|
|
|
|
|
|
|
2658 |
chat_input.submit(chat_input_callback, [visual_chatgpt, chat_input, click_state, state, aux_state,language,auto_play,gender,openai_api_key,image_path,log_state,history_log,naritive],
|
2659 |
[chatbot, state, aux_state,output_audio,log_state,history_log])
|
2660 |
# chat_input.submit(lambda: "", None, chat_input)
|
2661 |
chat_input.submit(lambda: {"text": ""}, None, chat_input)
|
2662 |
+
|
|
|
|
|
2663 |
example_image.change(upload_callback, [example_image, state, log_state, task_type, visual_chatgpt, openai_api_key,language,naritive,history_log,auto_play,session_type],
|
2664 |
[chatbot, state, origin_image, click_state, image_input, image_input_base, sketcher_input,image_input_base_2,
|
2665 |
image_embedding, original_size, input_size,name_label,artist_label,year_label,material_label,name_label_base, artist_label_base, year_label_base, material_label_base, \
|
|
|
2696 |
# click_tab.select(on_click_tab_selected, outputs=[modules_need_gpt1,modules_not_need_gpt2,modules_need_gpt0,modules_need_gpt2])
|
2697 |
# base_tab.select(on_base_selected, outputs=[modules_need_gpt0,modules_need_gpt2,modules_not_need_gpt2,modules_need_gpt1])
|
2698 |
# base_tab2.select(on_base_selected, outputs=[modules_not_need_gpt2,modules_not_need_gpt2,modules_need_gpt0,modules_need_gpt1])
|
2699 |
+
|
2700 |
+
def print_reason():
|
2701 |
+
print("reason")
|
2702 |
+
|
2703 |
+
|
2704 |
+
image_select.select(
|
2705 |
+
print_reason,
|
2706 |
+
inputs=[],
|
2707 |
+
outputs=[])
|
2708 |
|
2709 |
|
2710 |
|