Niki Zhang commited on
Commit
433556e
·
verified ·
1 Parent(s): 757e48f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +125 -111
app.py CHANGED
@@ -621,7 +621,7 @@ css = """
621
 
622
 
623
  .info_btn {
624
- background: white !important;
625
  border: none !important;
626
  box-shadow: none !important;
627
  font-size: 15px !important;
@@ -630,7 +630,7 @@ css = """
630
  }
631
 
632
  .info_btn_interact {
633
- background: rgb(242, 240, 233) !important;
634
  box-shadow: none !important;
635
  font-size: 15px !important;
636
  min-width: 6rem !important;
@@ -638,16 +638,24 @@ css = """
638
  }
639
 
640
  .function_button {
 
641
  border: none !important;
642
  box-shadow: none !important;
643
  }
644
 
645
  .function_button_rec {
646
- background: rgb(245, 193, 154) !important;
647
  border: none !important;
648
  box-shadow: none !important;
649
  }
650
 
 
 
 
 
 
 
 
651
  #tool_box {max-width: 50px}
652
 
653
  """
@@ -684,7 +692,7 @@ prompt_list = [
684
  "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.",
685
  ],
686
  [
687
- '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 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.',
688
  '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.',
689
  '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.',
690
  '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.',
@@ -700,7 +708,7 @@ recommendation_prompt=[
700
  Each bullet point should be in {language} language, with a response length of about {length} words.
701
  ''',
702
  '''
703
- 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.
704
 
705
  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:
706
 
@@ -932,9 +940,14 @@ def update_click_state(click_state, caption, click_mode):
932
  raise NotImplementedError
933
 
934
  async def chat_input_callback(*args):
935
- visual_chatgpt, chat_input, click_state, state, aux_state ,language , autoplay,gender,api_key,image_input,log_state,history = args
936
  message = chat_input["text"]
937
- prompt="Please help me answer the question with this painting {question} in {language}."
 
 
 
 
 
938
  prompt=prompt.format(question=message, language=language)
939
 
940
  if visual_chatgpt is not None:
@@ -1254,7 +1267,7 @@ async def submit_caption(naritive, state,length, sentiment, factuality, language
1254
  return state, state, click_index_state, input_mask_state, input_points_state, input_labels_state, out_state, None,None,log_state,history
1255
 
1256
 
1257
- naritive_mapping = {"Narrator Character": 0, "Artist Character": 1, "In-Situ Character": 2}
1258
 
1259
  def generate_prompt(focus_type, paragraph,length, sentiment, factuality, language,naritive):
1260
 
@@ -1710,9 +1723,9 @@ async def texttospeech(text, language,gender='female'):
1710
 
1711
  # give the reason of recommendation
1712
  async def item_associate(new_crop,openai_api_key,language,autoplay,length,log_state,sort_score,narritive,state,recommend_type,evt: gr.SelectData):
 
1713
  if recommend_type=="Reasons":
1714
  persona=naritive_mapping[narritive]
1715
- rec_path=evt._data['value']['image']['path']
1716
  index="Item Recommendation Picture "+ str(evt.index)
1717
  print("rec_path",rec_path)
1718
 
@@ -1733,14 +1746,15 @@ async def item_associate(new_crop,openai_api_key,language,autoplay,length,log_st
1733
  audio_output=None
1734
  if autoplay:
1735
  audio_output = await texttospeech(read_info, language)
1736
- return state,state,audio_output,log_state,index,gr.update(value=[])
1737
- return state,state,None,log_state,None,gr.update(value=[])
1738
 
1739
 
1740
  async def style_associate(image_path,openai_api_key,language,autoplay,length,log_state,sort_score,narritive,state,artist,recommend_type,evt: gr.SelectData):
 
1741
  if recommend_type=="Reasons":
1742
  persona=naritive_mapping[narritive]
1743
- rec_path=evt._data['value']['image']['path']
1744
  index="Style Recommendation Picture "+str(evt.index)
1745
  print("rec_path",rec_path)
1746
  if persona==1:
@@ -1761,30 +1775,30 @@ async def style_associate(image_path,openai_api_key,language,autoplay,length,log
1761
  audio_output=None
1762
  if autoplay:
1763
  audio_output = await texttospeech(read_info, language)
1764
- return state,state,audio_output,log_state,index,gr.update(value=[])
1765
- return state,state,None,log_state,None,gr.update(value=[])
1766
 
1767
 
1768
  def change_naritive(session_type,image_input, state, click_state, paragraph, origin_image,narritive,task_instruct,gallery_output,style_gallery_result,reco_reasons,language="English"):
1769
  if session_type=="Session 1":
1770
- return None, [], [], [[], [], []], "", None, None, [], [],[],[],gr.update(value="Preview"),[]
1771
  else:
1772
  if language=="English":
1773
- if narritive=="Narrator Character" :
1774
  state += [
1775
  (
1776
  None,
1777
  f"🤖 Hi, I am EyeSee. Let's explore this painting together."
1778
  )
1779
  ]
1780
- elif narritive=="Artist Character":
1781
  state += [
1782
  (
1783
  None,
1784
  f"🧑‍🎨 Let's delve into it from the perspective of the artist."
1785
  )
1786
  ]
1787
- elif narritive=="In-Situ Character":
1788
  state += [
1789
  (
1790
  None,
@@ -1792,21 +1806,21 @@ def change_naritive(session_type,image_input, state, click_state, paragraph, ori
1792
  )
1793
  ]
1794
  elif language=="Chinese":
1795
- if narritive=="Narrator Character" :
1796
  state += [
1797
  (
1798
  None,
1799
  "🤖 让我们从第三方视角一起探索这幅画吧。"
1800
  )
1801
  ]
1802
- elif narritive == "Artist Character":
1803
  state += [
1804
  (
1805
  None,
1806
  "🧑‍🎨 让我们从艺术家的视角深入探索这幅画。"
1807
  )
1808
  ]
1809
- elif narritive == "In-Situ Character":
1810
  state += [
1811
  (
1812
  None,
@@ -1908,19 +1922,26 @@ def create_ui():
1908
  recomended_state=gr.State([])
1909
 
1910
 
1911
- with gr.Row():
1912
- auto_play = gr.Checkbox(
1913
- label="Check to autoplay audio", value=False, elem_classes="custom-autoplay"
1914
- )
1915
- output_audio = gr.HTML(
1916
- label="Synthesised Audio", elem_classes="custom-output"
1917
- )
1918
  with gr.Row():
1919
- with gr.Column(scale=1,min_width=50,visible=False) as instruct:
1920
- task_instuction=gr.Image(type="pil", interactive=False, elem_classes="task_instruct",height=650,label="Instruction")
1921
  with gr.Column(scale=6):
1922
  with gr.Column(visible=False) as modules_not_need_gpt:
1923
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1924
  with gr.Tab("Base(GPT Power)",visible=False) as base_tab:
1925
  image_input_base = gr.Image(type="pil", interactive=True, elem_classes="image_upload",height=650)
1926
  with gr.Row():
@@ -1937,49 +1958,50 @@ def create_ui():
1937
  year_label_base2 = gr.Button(value="Year: ",elem_classes="info_btn_interact")
1938
  material_label_base2 = gr.Button(value="Style: ",elem_classes="info_btn")
1939
 
1940
- with gr.Tab("Click") as click_tab:
1941
- with gr.Row():
1942
- with gr.Column(scale=10,min_width=600):
1943
- image_input = gr.Image(type="pil", interactive=True, elem_classes="image_upload",height=650)
1944
- example_image = gr.Image(type="pil", interactive=False, visible=False)
1945
  with gr.Row():
1946
- name_label = gr.Button(value="Name: ",elem_classes="info_btn")
1947
- artist_label = gr.Button(value="Artist: ",elem_classes="info_btn_interact")
1948
- year_label = gr.Button(value="Year: ",elem_classes="info_btn_interact")
1949
- material_label = gr.Button(value="Style: ",elem_classes="info_btn")
1950
-
1951
-
1952
-
1953
-
1954
- # example_image_click = gr.Image(type="pil", interactive=False, visible=False)
1955
- # the tool column
1956
- with gr.Column(scale=1,elem_id="tool_box",min_width=80):
1957
- add_button = gr.Button(value="Extend Area", interactive=True,elem_classes="tools_button_add",icon=add_icon_path)
1958
- minus_button = gr.Button(value="Remove Area", interactive=True,elem_classes="tools_button",icon=minus_icon_path)
1959
- clear_button_click = gr.Button(value="Reset", interactive=True,elem_classes="tools_button")
1960
- focus_d = gr.Button(value="Describe",interactive=True,elem_classes="function_button",variant="primary")
1961
- focus_da = gr.Button(value="D+Analysis",interactive=True,elem_classes="function_button",variant="primary")
1962
- focus_dai = gr.Button(value="DA+Interprete",interactive=True,elem_classes="function_button",variant="primary")
1963
- focus_dda = gr.Button(value="Judge",interactive=True,elem_classes="function_button",variant="primary")
1964
-
1965
- recommend_btn = gr.Button(value="Recommend",interactive=True,elem_classes="function_button_rec")
1966
  # focus_asso = gr.Button(value="Associate",interactive=True,elem_classes="function_button",variant="primary")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1967
 
1968
- with gr.Row(visible=False):
1969
- with gr.Column():
1970
- with gr.Row():
1971
- # point_prompt = gr.Radio(
1972
- # choices=["Positive", "Negative"],
1973
- # value="Positive",
1974
- # label="Point Prompt",
1975
- # scale=5,
1976
- # interactive=True)
1977
- click_mode = gr.Radio(
1978
- choices=["Continuous", "Single"],
1979
- value="Continuous",
1980
- label="Clicking Mode",
1981
- scale=5,
1982
- interactive=True)
1983
 
1984
 
1985
  with gr.Tab("Trajectory (beta)", visible=False) as traj_tab:
@@ -2026,11 +2048,11 @@ def create_ui():
2026
  value="No",
2027
  label="Expert",
2028
  interactive=True)
2029
- with gr.Column(visible=True) as modules_not_need_gpt3:
2030
- gr.Examples(
2031
- examples=examples,
2032
- inputs=[example_image],
2033
- )
2034
 
2035
 
2036
  with gr.Column(scale=4):
@@ -2056,24 +2078,8 @@ def create_ui():
2056
 
2057
 
2058
 
2059
- with gr.Column(visible=False) as modules_not_need_gpt2:
2060
- with gr.Row():
2061
- naritive = gr.Radio(
2062
- choices=["Narrator Character", "Artist Character","In-Situ Character"],
2063
- value="Narrator Character",
2064
- label="Character",
2065
- scale=5,
2066
- interactive=True)
2067
- with gr.Blocks():
2068
- chatbot = gr.Chatbot(label="Chatbox", elem_classes="chatbot",likeable=True,height=600,bubble_full_width=False)
2069
- with gr.Column() as modules_need_gpt3:
2070
- chat_input = gr.MultimodalTextbox(interactive=True, file_types=[".txt"], placeholder="Message EyeSee...", show_label=False)
2071
- with gr.Row():
2072
- clear_button_text = gr.Button(value="Clear Chat", interactive=True)
2073
- export_button = gr.Button(value="Export Chat Log", interactive=True, variant="primary")
2074
- # submit_button_text = gr.Button(value="Send", interactive=True, variant="primary")
2075
- # upvote_btn = gr.Button(value="👍 Upvote", interactive=True)
2076
- # downvote_btn = gr.Button(value="👎 Downvote", interactive=True)
2077
 
2078
 
2079
 
@@ -2096,16 +2102,17 @@ def create_ui():
2096
 
2097
  with gr.Row():
2098
  with gr.Column(scale=6):
2099
- with gr.Column(visible=False) as recommend:
2100
- sort_rec=gr.Dropdown(["1", "2", "3", "4"],
2101
- value=[],
2102
- multiselect=True,
2103
- label="Score", info="Please sort the pictures according to your preference"
2104
- )
2105
- with gr.Row():
2106
-
 
2107
  gallery_result = gr.Gallery(
2108
- label="Recommendations Based on Object",
2109
  height="auto",
2110
  columns=2,
2111
  interactive=False
@@ -2121,7 +2128,7 @@ def create_ui():
2121
  )
2122
 
2123
  style_gallery_result = gr.Gallery(
2124
- label="Recommendations Based on Style",
2125
  height="auto",
2126
  columns=2,
2127
  interactive=False
@@ -2135,6 +2142,13 @@ def create_ui():
2135
  # show_share_button=True,
2136
  # show_download_button=True
2137
  )
 
 
 
 
 
 
 
2138
 
2139
  recommend_type = gr.Radio(
2140
  choices=["Preview","Reasons"],
@@ -2148,7 +2162,7 @@ def create_ui():
2148
  recommend_score = gr.Radio(
2149
  choices=[1,2,3,4,5,6,7],
2150
  label="Score",
2151
- interactive=True)
2152
 
2153
  with gr.Row():
2154
  task_type = gr.Textbox(visible=False)
@@ -2269,7 +2283,7 @@ def create_ui():
2269
  )
2270
  language = gr.Dropdown(
2271
  ['English', 'Chinese', 'French', "Spanish", "Arabic", "Portuguese", "Cantonese"],
2272
- value="Chinese", label="Language", interactive=True, elem_classes="custom-language"
2273
  )
2274
  length = gr.Slider(
2275
  minimum=60,
@@ -2333,7 +2347,7 @@ def create_ui():
2333
  gallery_result.select(
2334
  item_associate,
2335
  inputs=[new_crop_save_path,openai_api_key,language,auto_play,length,log_state,sort_rec,naritive,recomended_state,recommend_type],
2336
- outputs=[recommend_bot,recomended_state,output_audio,log_state,pic_index,recommend_score],
2337
 
2338
 
2339
  )
@@ -2341,7 +2355,7 @@ def create_ui():
2341
  style_gallery_result.select(
2342
  style_associate,
2343
  inputs=[image_path,openai_api_key,language,auto_play,length,log_state,sort_rec,naritive,recomended_state,artist_label,recommend_type],
2344
- outputs=[recommend_bot,recomended_state,output_audio,log_state,pic_index,recommend_score],
2345
 
2346
 
2347
  )
@@ -2646,7 +2660,7 @@ def create_ui():
2646
  # sketcher_input.upload(upload_callback, [sketcher_input, state, visual_chatgpt, openai_api_key],
2647
  # [chatbot, state, origin_image, click_state, image_input, image_input_base, sketcher_input,
2648
  # 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])
2649
- 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],
2650
  [chatbot, state, aux_state,output_audio,log_state,history_log])
2651
  # chat_input.submit(lambda: "", None, chat_input)
2652
  chat_input.submit(lambda: {"text": ""}, None, chat_input)
@@ -2661,9 +2675,9 @@ def create_ui():
2661
 
2662
  example_image.change(clear_chat_memory, inputs=[visual_chatgpt])
2663
  example_image.change(
2664
- lambda:([],[],[],None,[],gr.update(value="Preview"),gr.update(value=[])),
2665
  [],
2666
- [gallery_result,style_gallery_result,recommend_bot,new_crop_save_path,chatbot,recommend_type,sort_rec])
2667
 
2668
  # def on_click_tab_selected():
2669
  # if gpt_state ==1:
 
621
 
622
 
623
  .info_btn {
624
+ background: rgb(245, 245, 245) !important;
625
  border: none !important;
626
  box-shadow: none !important;
627
  font-size: 15px !important;
 
630
  }
631
 
632
  .info_btn_interact {
633
+ background: rgb(217, 217, 217) !important;
634
  box-shadow: none !important;
635
  font-size: 15px !important;
636
  min-width: 6rem !important;
 
638
  }
639
 
640
  .function_button {
641
+ background: rgb(227, 226, 226) !important;
642
  border: none !important;
643
  box-shadow: none !important;
644
  }
645
 
646
  .function_button_rec {
647
+ background: rgb(189, 189, 189) !important;
648
  border: none !important;
649
  box-shadow: none !important;
650
  }
651
 
652
+ .small_button {
653
+ font-size: 12px !important;
654
+ padding: 2px 8px !important;
655
+ min-width: 60px !important;
656
+ height: 30px !important;
657
+ }
658
+
659
  #tool_box {max-width: 50px}
660
 
661
  """
 
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.',
 
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 you are 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
 
 
940
  raise NotImplementedError
941
 
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=="Narrative":
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:
 
1267
  return state, state, click_index_state, input_mask_state, input_points_state, input_labels_state, out_state, None,None,log_state,history
1268
 
1269
 
1270
+ naritive_mapping = {"Narrator": 0, "Artist": 1, "In-Situ": 2}
1271
 
1272
  def generate_prompt(focus_type, paragraph,length, sentiment, factuality, language,naritive):
1273
 
 
1723
 
1724
  # give the reason of recommendation
1725
  async def item_associate(new_crop,openai_api_key,language,autoplay,length,log_state,sort_score,narritive,state,recommend_type,evt: gr.SelectData):
1726
+ rec_path=evt._data['value']['image']['path']
1727
  if recommend_type=="Reasons":
1728
  persona=naritive_mapping[narritive]
 
1729
  index="Item Recommendation Picture "+ str(evt.index)
1730
  print("rec_path",rec_path)
1731
 
 
1746
  audio_output=None
1747
  if autoplay:
1748
  audio_output = await texttospeech(read_info, language)
1749
+ return state,state,audio_output,log_state,index,gr.update(value=[]),rec_path
1750
+ return state,state,None,log_state,None,gr.update(value=[]),rec_path
1751
 
1752
 
1753
  async def style_associate(image_path,openai_api_key,language,autoplay,length,log_state,sort_score,narritive,state,artist,recommend_type,evt: gr.SelectData):
1754
+ rec_path=evt._data['value']['image']['path']
1755
  if recommend_type=="Reasons":
1756
  persona=naritive_mapping[narritive]
1757
+
1758
  index="Style Recommendation Picture "+str(evt.index)
1759
  print("rec_path",rec_path)
1760
  if persona==1:
 
1775
  audio_output=None
1776
  if autoplay:
1777
  audio_output = await texttospeech(read_info, language)
1778
+ return state,state,audio_output,log_state,index,gr.update(value=[]),rec_path
1779
+ return state,state,None,log_state,None,gr.update(value=[]),rec_path
1780
 
1781
 
1782
  def change_naritive(session_type,image_input, state, click_state, paragraph, origin_image,narritive,task_instruct,gallery_output,style_gallery_result,reco_reasons,language="English"):
1783
  if session_type=="Session 1":
1784
+ return None, [], [], [[], [], []], "", None, None, [], [],[],[],gr.update(value="Preview")
1785
  else:
1786
  if language=="English":
1787
+ if narritive=="Narrator" :
1788
  state += [
1789
  (
1790
  None,
1791
  f"🤖 Hi, I am EyeSee. Let's explore this painting together."
1792
  )
1793
  ]
1794
+ elif narritive=="Artist":
1795
  state += [
1796
  (
1797
  None,
1798
  f"🧑‍🎨 Let's delve into it from the perspective of the artist."
1799
  )
1800
  ]
1801
+ elif narritive=="In-Situ":
1802
  state += [
1803
  (
1804
  None,
 
1806
  )
1807
  ]
1808
  elif language=="Chinese":
1809
+ if narritive=="Narrator" :
1810
  state += [
1811
  (
1812
  None,
1813
  "🤖 让我们从第三方视角一起探索这幅画吧。"
1814
  )
1815
  ]
1816
+ elif narritive == "Artist":
1817
  state += [
1818
  (
1819
  None,
1820
  "🧑‍🎨 让我们从艺术家的视角深入探索这幅画。"
1821
  )
1822
  ]
1823
+ elif narritive == "In-Situ":
1824
  state += [
1825
  (
1826
  None,
 
1922
  recomended_state=gr.State([])
1923
 
1924
 
1925
+
 
 
 
 
 
 
1926
  with gr.Row():
 
 
1927
  with gr.Column(scale=6):
1928
  with gr.Column(visible=False) as modules_not_need_gpt:
1929
+ with gr.Row():
1930
+ naritive = gr.Radio(
1931
+ choices=["Narrator", "Artist","In-Situ"],
1932
+ value="Narrator",
1933
+ label="Select Mode",
1934
+ scale=5,
1935
+ interactive=True)
1936
+
1937
+ add_button = gr.Button(value="Extend Area", interactive=True,elem_classes="tools_button_add",icon=add_icon_path)
1938
+ minus_button = gr.Button(value="Remove Area", interactive=True,elem_classes="tools_button",icon=minus_icon_path)
1939
+ clear_button_click = gr.Button(value="Reset", interactive=True,elem_classes="tools_button",icon="assets/icons/recycle.png")
1940
+
1941
+ auto_play = gr.Checkbox(
1942
+ label="Check to autoplay audio", value=False, elem_classes="custom-autoplay",visible=False)
1943
+ output_audio = gr.HTML(
1944
+ label="Synthesised Audio", elem_classes="custom-output", visible=False)
1945
  with gr.Tab("Base(GPT Power)",visible=False) as base_tab:
1946
  image_input_base = gr.Image(type="pil", interactive=True, elem_classes="image_upload",height=650)
1947
  with gr.Row():
 
1958
  year_label_base2 = gr.Button(value="Year: ",elem_classes="info_btn_interact")
1959
  material_label_base2 = gr.Button(value="Style: ",elem_classes="info_btn")
1960
 
1961
+ with gr.Row():
1962
+ with gr.Column(scale=1,min_width=50,visible=False) as instruct:
1963
+ task_instuction=gr.Image(type="pil", interactive=False, elem_classes="task_instruct",height=650,label="Instruction")
1964
+ with gr.Column(scale=6):
1965
+ with gr.Tab("Click") as click_tab:
1966
  with gr.Row():
1967
+ with gr.Column(scale=10,min_width=600):
1968
+ image_input = gr.Image(type="pil", interactive=True, elem_classes="image_upload",height=650)
1969
+ example_image = gr.Image(type="pil", interactive=False, visible=False)
1970
+ # example_image_click = gr.Image(type="pil", interactive=False, visible=False)
1971
+ # the tool column
1972
+ with gr.Column(scale=1,elem_id="tool_box",min_width=80):
1973
+ name_label = gr.Button(value="Name: ",elem_classes="info_btn")
1974
+ artist_label = gr.Button(value="Artist: ",elem_classes="info_btn_interact")
1975
+ year_label = gr.Button(value="Year: ",elem_classes="info_btn_interact")
1976
+ material_label = gr.Button(value="Style: ",elem_classes="info_btn")
1977
+
1978
+ focus_d = gr.Button(value="Describe",interactive=True,elem_classes="function_button")
1979
+ focus_da = gr.Button(value="D+Analysis",interactive=True,elem_classes="function_button")
1980
+ focus_dai = gr.Button(value="DA+Interprete",interactive=True,elem_classes="function_button")
1981
+ focus_dda = gr.Button(value="Judge",interactive=True,elem_classes="function_button")
1982
+
1983
+ recommend_btn = gr.Button(value="Recommend",interactive=True,elem_classes="function_button_rec")
 
 
 
1984
  # focus_asso = gr.Button(value="Associate",interactive=True,elem_classes="function_button",variant="primary")
1985
+ with gr.Column(visible=False) as modules_not_need_gpt2:
1986
+ with gr.Blocks():
1987
+ chatbot = gr.Chatbot(label="Chatbox", elem_classes="chatbot",likeable=True,height=600,bubble_full_width=False)
1988
+ with gr.Column() as modules_need_gpt3:
1989
+ chat_input = gr.MultimodalTextbox(interactive=True, file_types=[".txt"], placeholder="Message EyeSee...", show_label=False)
1990
+ with gr.Row():
1991
+ clear_button_text = gr.Button(value="Clear Chat", interactive=True)
1992
+ export_button = gr.Button(value="Export Chat Log", interactive=True, variant="primary")
1993
+ with gr.Row(visible=False):
1994
+ with gr.Column():
1995
+ with gr.Row():
1996
+ click_mode = gr.Radio(
1997
+ choices=["Continuous", "Single"],
1998
+ value="Continuous",
1999
+ label="Clicking Mode",
2000
+ scale=5,
2001
+ interactive=True)
2002
+
2003
+
2004
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2005
 
2006
 
2007
  with gr.Tab("Trajectory (beta)", visible=False) as traj_tab:
 
2048
  value="No",
2049
  label="Expert",
2050
  interactive=True)
2051
+ with gr.Column(visible=True) as modules_not_need_gpt3:
2052
+ gr.Examples(
2053
+ examples=examples,
2054
+ inputs=[example_image],
2055
+ )
2056
 
2057
 
2058
  with gr.Column(scale=4):
 
2078
 
2079
 
2080
 
2081
+
2082
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2083
 
2084
 
2085
 
 
2102
 
2103
  with gr.Row():
2104
  with gr.Column(scale=6):
2105
+ with gr.Row():
2106
+ with gr.Column(visible=False) as recommend:
2107
+
2108
+ # sort_rec=gr.Dropdown(["1", "2", "3", "4"], visible=False,
2109
+ # value=[],
2110
+ # multiselect=True,
2111
+ # label="Score", info="Please sort the pictures according to your preference"
2112
+ # )
2113
+
2114
  gallery_result = gr.Gallery(
2115
+ label="Object-based Recommendation",
2116
  height="auto",
2117
  columns=2,
2118
  interactive=False
 
2128
  )
2129
 
2130
  style_gallery_result = gr.Gallery(
2131
+ label="Style-based Recommendation",
2132
  height="auto",
2133
  columns=2,
2134
  interactive=False
 
2142
  # show_share_button=True,
2143
  # show_download_button=True
2144
  )
2145
+ with gr.Column(scale=3):
2146
+ selected_image = gr.Image(label="Selected Image", interactive=False)
2147
+
2148
+ sort_rec = gr.Radio(
2149
+ choices=[1,2,3,4,5,6,7],
2150
+ label="Score",
2151
+ interactive=True,info="Please sort the recommendation artwork")
2152
 
2153
  recommend_type = gr.Radio(
2154
  choices=["Preview","Reasons"],
 
2162
  recommend_score = gr.Radio(
2163
  choices=[1,2,3,4,5,6,7],
2164
  label="Score",
2165
+ interactive=True,info='Please score the recommendation reasons')
2166
 
2167
  with gr.Row():
2168
  task_type = gr.Textbox(visible=False)
 
2283
  )
2284
  language = gr.Dropdown(
2285
  ['English', 'Chinese', 'French', "Spanish", "Arabic", "Portuguese", "Cantonese"],
2286
+ value="English", label="Language", interactive=True, elem_classes="custom-language"
2287
  )
2288
  length = gr.Slider(
2289
  minimum=60,
 
2347
  gallery_result.select(
2348
  item_associate,
2349
  inputs=[new_crop_save_path,openai_api_key,language,auto_play,length,log_state,sort_rec,naritive,recomended_state,recommend_type],
2350
+ outputs=[recommend_bot,recomended_state,output_audio,log_state,pic_index,recommend_score,selected_image],
2351
 
2352
 
2353
  )
 
2355
  style_gallery_result.select(
2356
  style_associate,
2357
  inputs=[image_path,openai_api_key,language,auto_play,length,log_state,sort_rec,naritive,recomended_state,artist_label,recommend_type],
2358
+ outputs=[recommend_bot,recomended_state,output_audio,log_state,pic_index,recommend_score,selected_image],
2359
 
2360
 
2361
  )
 
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)
 
2675
 
2676
  example_image.change(clear_chat_memory, inputs=[visual_chatgpt])
2677
  example_image.change(
2678
+ lambda:([],[],[],None,[],gr.update(value="Preview")),
2679
  [],
2680
+ [gallery_result,style_gallery_result,recommend_bot,new_crop_save_path,chatbot,recommend_type])
2681
 
2682
  # def on_click_tab_selected():
2683
  # if gpt_state ==1: