hyzhang00 commited on
Commit
46d8462
·
1 Parent(s): 54ec520

update on code

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +69 -118
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: EyeSee_v2
3
  emoji: 👀
4
  colorFrom: green
5
  colorTo: yellow
 
1
  ---
2
+ title: EyeSee_chi
3
  emoji: 👀
4
  colorFrom: green
5
  colorTo: yellow
app.py CHANGED
@@ -8,7 +8,6 @@ import json
8
  import gradio as gr
9
  import numpy as np
10
  from PIL import Image
11
- import functools
12
  import emoji
13
  from langchain_community.chat_models import ChatOpenAI
14
  from langchain.schema import HumanMessage
@@ -17,13 +16,12 @@ from caption_anything.utils.utils import mask_painter, seg_model_map, prepare_se
17
  from caption_anything.utils.parser import parse_augment
18
  from caption_anything.captioner import build_captioner
19
  from caption_anything.segmenter import build_segmenter
20
- from backend.chatbox import ConversationBot, build_chatbot_tools, get_new_image_name
21
  from segment_anything import sam_model_registry
22
  import easyocr
23
  import re
24
  from langchain import __version__
25
  import pandas as pd
26
- import requests
27
  import os
28
  import json
29
  import numpy as np
@@ -32,6 +30,7 @@ from backend.prompts import generate_prompt
32
  from backend.recommendation import RecommendationConfig, ImageRecommender
33
  from backend.gpt_service import get_gpt_response, get_artistinfo, get_yearinfo
34
  from backend.texttospeech.tts import texttospeech
 
35
 
36
  recommendation_config = RecommendationConfig()
37
  recommender = ImageRecommender(recommendation_config)
@@ -108,30 +107,16 @@ def validate_api_key(api_key):
108
  return False
109
 
110
 
111
- def init_openai_api_key(api_key=""):
112
- text_refiner = None
113
- visual_chatgpt = None
114
  if api_key and len(api_key) > 30:
115
  print(api_key)
116
  if validate_api_key(api_key):
117
- try:
118
- text_refiner = None
119
- print("text refiner")
120
- visual_chatgpt = ConversationBot(shared_chatbot_tools, api_key=api_key)
121
- except Exception as e:
122
- print(f"Error initializing TextRefiner or ConversationBot: {e}")
123
- text_refiner = None
124
- visual_chatgpt = None
125
  else:
126
  print("Invalid API key.")
127
  else:
128
  print("API key is too short.")
129
- print(text_refiner)
130
-
131
- if visual_chatgpt:
132
- return [gr.update(visible=True)]+[gr.update(visible=False)]+[gr.update(visible=True)]* 3 + [gr.update(visible=False)]*2 + [text_refiner, visual_chatgpt, None]+[gr.update(visible=True)]*4+[gr.update(visible=False)]+[gr.update(visible=True)]*2
133
- else:
134
- return [gr.update(visible=False)]*5 + [gr.update(visible=True)]*2 + [text_refiner, visual_chatgpt, 'Your OpenAI API Key is not available']+[gr.update(visible=False)]*7
135
 
136
 
137
  def get_click_prompt(chat_input, click_state, click_mode):
@@ -171,7 +156,7 @@ def update_click_state(click_state, caption, click_mode):
171
  raise NotImplementedError
172
 
173
  async def chat_input_callback(*args):
174
- visual_chatgpt, chat_input, click_state, state, aux_state ,language , autoplay,gender,api_key,image_input,log_state,history,persona = args
175
  message = chat_input["text"]
176
  if persona == "Narrator":
177
  prompt="Please help me answer the question with this painting {question} in {language}, with a response length of about 70 words.."
@@ -181,32 +166,26 @@ async def chat_input_callback(*args):
181
  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}, with a response length of about 70 words."
182
  prompt=prompt.format(question=message, language=language)
183
 
184
- if visual_chatgpt is not None:
185
- result=get_gpt_response(api_key, image_input,prompt+message,history)
186
- read_info = re.sub(r'[#[\]!*]','',result)
187
- read_info = emoji.replace_emoji(read_info,replace="")
188
- state = state + [(message,result)]
189
- log_state += [(message,"/////")]
190
- log_state += [("/////",result)]
191
- # log_state += [("%% chat messahe %%",None)]
192
-
193
- history.append({"role": "user", "content": message})
194
- history.append({"role": "assistant", "content": result})
 
195
 
196
- if autoplay==False:
197
- return state, state, aux_state, None,log_state,history
198
-
199
- else:
200
- audio = await texttospeech(read_info,language,gender)
201
- return state, state, aux_state, audio,log_state,history
202
- else:
203
- response = "Text refiner is not initilzed, please input openai api key."
204
- state = state + [(chat_input, response)]
205
- audio = await texttospeech(response,language,gender)
206
- return state, state, None, audio,log_state,history
207
 
208
 
209
- async def upload_callback(image_input,state, log_state, task_type, visual_chatgpt=None, openai_api_key=None,language="English",narritive=None,history=None,autoplay=True,session="Session 1"):
210
  print("narritive", narritive)
211
  if isinstance(image_input, dict): # if upload from sketcher_input, input contains image and mask
212
  image_input = image_input['background']
@@ -216,10 +195,7 @@ async def upload_callback(image_input,state, log_state, task_type, visual_chatgp
216
  elif isinstance(image_input, bytes):
217
  image_input = Image.open(io.BytesIO(image_input))
218
 
219
-
220
  click_state = [[], [], []]
221
-
222
-
223
  image_input = image_resize(image_input, res=1024)
224
 
225
  model = build_caption_anything_with_models(
@@ -235,42 +211,39 @@ async def upload_callback(image_input,state, log_state, task_type, visual_chatgp
235
  original_size = model.original_size
236
  input_size = model.input_size
237
 
238
- if visual_chatgpt is not None:
239
- print('upload_callback: add caption to chatGPT memory')
240
- new_image_path = get_new_image_name('chat_image', func_name='upload')
241
- image_input.save(new_image_path)
242
- print("img_path",new_image_path)
243
- visual_chatgpt.current_image = new_image_path
244
- paragraph = get_gpt_response(openai_api_key, new_image_path,f"What's going on in this picture? in {language}")
245
- # visual_chatgpt.agent.memory.buffer = visual_chatgpt.agent.memory.buffer + visual_chatgpt.global_prompt
246
- if task_type=="task 3":
247
- name="Along the River During the Qingming Festival"
248
- artist="Zhang Zeduan"
249
- year="12th century (Song Dynasty)"
250
- material="Chinese painting"
251
- gender="male"
252
-
253
- elif task_type=="task 1":
254
- name ="The Ambassadors"
255
- artist ="Hans Holbein the Younger"
256
- year = "1533 (Northern Renaissance)"
257
- material="Realism"
258
- gender = "male"
259
-
260
- elif task_type=="task 2":
261
- name = "The Football Players"
262
- artist= "Albert Gleizes"
263
- year= "1912 (Cubism)"
264
- material="Cubism"
265
- gender= "male"
266
 
267
- else:
268
- parsed_data = get_gpt_response(openai_api_key, new_image_path,"Please provide the name, artist, year of creation (including the art historical period), and painting style used for this painting. Return the information in dictionary format without any newline characters. Format as follows: { \"name\": \"Name of the painting\", \"artist\": \"Name of the artist\", \"year\": \"Year of creation (Art historical period)\", \"style\": \"Painting style used in the painting\"}")
269
- print(parsed_data)
270
- parsed_data = json.loads(parsed_data.replace("'", "\""))
271
- name, artist, year, material= parsed_data["name"],parsed_data["artist"],parsed_data["year"], parsed_data["style"]
272
- gender="male"
273
- gender=gender.lower()
 
 
 
 
 
 
 
274
 
275
  if language=="English":
276
  if naritive_mapping[narritive]==0 :
@@ -317,7 +290,7 @@ async def upload_callback(image_input,state, log_state, task_type, visual_chatgp
317
 
318
 
319
  def inference_click(image_input, point_prompt, click_mode, enable_wiki, language, sentiment, factuality,
320
- length, image_embedding, state, click_state, original_size, input_size, text_refiner, visual_chatgpt,
321
  out_state, click_index_state, input_mask_state, input_points_state, input_labels_state, evt: gr.SelectData):
322
  click_index = evt.index
323
 
@@ -375,10 +348,9 @@ def inference_click(image_input, point_prompt, click_mode, enable_wiki, language
375
  input_labels_state = input_labels
376
  out_state = out
377
 
378
- if visual_chatgpt is not None:
379
- new_crop_save_path = get_new_image_name('chat_image', func_name='crop')
380
- Image.open(out["crop_save_path"]).save(new_crop_save_path)
381
- print("new crop save",new_crop_save_path)
382
 
383
  return state, state, click_state, image_input_nobackground, click_index_state, input_mask_state, input_points_state, input_labels_state, out_state,new_crop_save_path,image_input_nobackground
384
 
@@ -403,7 +375,7 @@ async def submit_caption(naritive, state,length, sentiment, factuality, language
403
  autoplay,paragraph,focus_type,openai_api_key,new_crop_save_path, gender,log_state,history):
404
 
405
 
406
- focus_value=focus_map[focus_type]
407
  click_index = click_index_state
408
 
409
  print("click_index",click_index)
@@ -418,14 +390,11 @@ async def submit_caption(naritive, state,length, sentiment, factuality, language
418
 
419
  log_state = log_state + [("Selected image point: {}, Input label: {}".format(input_points_state, input_labels_state), None)]
420
 
421
-
422
  print("Prompt:", prompt)
423
  print("click",click_index)
424
-
425
  log_state = log_state + [(naritive, None)]
426
 
427
 
428
- # if not args.disable_gpt and text_refiner:
429
  if not args.disable_gpt:
430
  print("new crop save",new_crop_save_path)
431
  focus_info=get_gpt_response(openai_api_key,new_crop_save_path,prompt)
@@ -448,7 +417,6 @@ async def submit_caption(naritive, state,length, sentiment, factuality, language
448
  history.append({"role": "assistant", "content": focus_info})
449
 
450
 
451
-
452
  print("new_cap",focus_info)
453
  read_info = re.sub(r'[#[\]!*]','',focus_info)
454
  read_info = emoji.replace_emoji(read_info,replace="")
@@ -479,19 +447,6 @@ async def submit_caption(naritive, state,length, sentiment, factuality, language
479
 
480
 
481
 
482
-
483
- def clear_chat_memory(visual_chatgpt, keep_global=False):
484
- if visual_chatgpt is not None:
485
- visual_chatgpt.memory.clear()
486
- visual_chatgpt.point_prompt = ""
487
- if keep_global:
488
- # visual_chatgpt.agent.memory.buffer = visual_chatgpt.global_prompt
489
- visual_chatgpt.agent.memory.save_context({"input": visual_chatgpt.global_prompt}, {"output": ""})
490
- else:
491
- visual_chatgpt.current_image = None
492
- visual_chatgpt.global_prompt = ""
493
-
494
-
495
  def export_chat_log(chat_state,log_list,narrative):
496
  try:
497
  chat_log=""
@@ -637,8 +592,6 @@ def get_recommendationscore(index,score,log_state):
637
  return log_state
638
 
639
 
640
-
641
-
642
  def toggle_icons_and_update_prompt(point_prompt):
643
  new_prompt = "Negative" if point_prompt == "Positive" else "Positive"
644
  new_add_icon = "assets/icons/plus-square-blue.png" if new_prompt == "Positive" else "assets/icons/plus-square.png"
@@ -681,7 +634,6 @@ def create_ui():
681
  origin_image = gr.State(None)
682
  image_embedding = gr.State(None)
683
  text_refiner = gr.State(None)
684
- visual_chatgpt = gr.State(None)
685
  original_size = gr.State(None)
686
  input_size = gr.State(None)
687
  paragraph = gr.State("")
@@ -920,11 +872,11 @@ def create_ui():
920
 
921
  openai_api_key.submit(init_openai_api_key, inputs=[openai_api_key],
922
  outputs=[export, modules_need_gpt1, modules_need_gpt3, modules_not_need_gpt,
923
- modules_not_need_gpt2, module_key_input ,module_notification_box, text_refiner, visual_chatgpt, notification_box,top_row,recommend,reco_reasons,instruct,modules_not_need_gpt3,sort_rec,reco_preview])
924
  enable_chatGPT_button.click(init_openai_api_key, inputs=[openai_api_key],
925
  outputs=[export,modules_need_gpt1, modules_need_gpt3,
926
  modules_not_need_gpt,
927
- modules_not_need_gpt2,module_key_input,module_notification_box, text_refiner, visual_chatgpt, notification_box,top_row,recommend,reco_reasons,instruct,modules_not_need_gpt3,sort_rec,reco_preview])
928
 
929
  artist_label.click(
930
  get_artistinfo,
@@ -953,7 +905,7 @@ def create_ui():
953
  queue=False,
954
  show_progress=False
955
  )
956
- clear_button_click.click(functools.partial(clear_chat_memory, keep_global=True), inputs=[visual_chatgpt])
957
 
958
  clear_button_text.click(
959
  lambda: ([], [], [[], [], [], []],[]),
@@ -962,7 +914,7 @@ def create_ui():
962
  queue=False,
963
  show_progress=False
964
  )
965
- clear_button_text.click(clear_chat_memory, inputs=[visual_chatgpt])
966
 
967
  image_input.clear(
968
  lambda: (None, [], [], [[], [], []], "", None, []),
@@ -972,25 +924,24 @@ def create_ui():
972
  show_progress=False
973
  )
974
 
975
- image_input.clear(clear_chat_memory, inputs=[visual_chatgpt])
976
 
977
 
978
- image_input.upload(upload_callback, [image_input, state, log_state,task_type, visual_chatgpt,openai_api_key,language,naritive,history_log,auto_play,session_type],
979
  [chatbot, state, origin_image, click_state, image_input,image_embedding, original_size, input_size,name_label,artist_label,year_label,material_label,\
980
  paragraph,artist,gender,image_path,log_state,history_log,output_audio])
981
 
982
 
983
 
984
- 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],
985
  [chatbot, state, aux_state,output_audio,log_state,history_log])
986
 
987
  chat_input.submit(lambda: {"text": ""}, None, chat_input)
988
 
989
- 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],
990
  [chatbot, state, origin_image, click_state, image_input, image_embedding, original_size, input_size,name_label,artist_label,year_label,material_label,\
991
  paragraph,artist,gender,image_path, log_state,history_log,output_audio])
992
 
993
- example_image.change(clear_chat_memory, inputs=[visual_chatgpt])
994
  example_image.change(
995
  lambda:([],[],[],None,[],gr.update(value="Preview")),
996
  [],
@@ -1000,7 +951,7 @@ def create_ui():
1000
  inference_click,
1001
  inputs=[
1002
  origin_image, point_prompt, click_mode, enable_wiki, language, sentiment, factuality, length,
1003
- image_embedding, state, click_state, original_size, input_size, text_refiner, visual_chatgpt,
1004
  out_state, click_index_state, input_mask_state, input_points_state, input_labels_state
1005
  ],
1006
  outputs=[chatbot, state, click_state, image_input, click_index_state, input_mask_state, input_points_state, input_labels_state, out_state,new_crop_save_path,image_input_nobackground],
 
8
  import gradio as gr
9
  import numpy as np
10
  from PIL import Image
 
11
  import emoji
12
  from langchain_community.chat_models import ChatOpenAI
13
  from langchain.schema import HumanMessage
 
16
  from caption_anything.utils.parser import parse_augment
17
  from caption_anything.captioner import build_captioner
18
  from caption_anything.segmenter import build_segmenter
19
+ from backend.chatbox import build_chatbot_tools, get_new_image_name
20
  from segment_anything import sam_model_registry
21
  import easyocr
22
  import re
23
  from langchain import __version__
24
  import pandas as pd
 
25
  import os
26
  import json
27
  import numpy as np
 
30
  from backend.recommendation import RecommendationConfig, ImageRecommender
31
  from backend.gpt_service import get_gpt_response, get_artistinfo, get_yearinfo
32
  from backend.texttospeech.tts import texttospeech
33
+ from backend.prompts.prompt_templates import PromptTemplates
34
 
35
  recommendation_config = RecommendationConfig()
36
  recommender = ImageRecommender(recommendation_config)
 
107
  return False
108
 
109
 
110
+ async def init_openai_api_key(api_key=""):
 
 
111
  if api_key and len(api_key) > 30:
112
  print(api_key)
113
  if validate_api_key(api_key):
114
+ return [gr.update(visible=True)]*4 + [gr.update(visible=False)]*2 + [gr.update(visible=True)]*2
 
 
 
 
 
 
 
115
  else:
116
  print("Invalid API key.")
117
  else:
118
  print("API key is too short.")
119
+ return [gr.update(visible=False)]*5 + [gr.update(visible=True)]*2 + ['Your OpenAI API Key is not available']+[gr.update(visible=False)]*7
 
 
 
 
 
120
 
121
 
122
  def get_click_prompt(chat_input, click_state, click_mode):
 
156
  raise NotImplementedError
157
 
158
  async def chat_input_callback(*args):
159
+ chat_input, state, aux_state ,language , autoplay,gender,api_key,image_input,log_state,history,persona = args
160
  message = chat_input["text"]
161
  if persona == "Narrator":
162
  prompt="Please help me answer the question with this painting {question} in {language}, with a response length of about 70 words.."
 
166
  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}, with a response length of about 70 words."
167
  prompt=prompt.format(question=message, language=language)
168
 
169
+ result=get_gpt_response(api_key, image_input,prompt+message,history)
170
+ read_info = re.sub(r'[#[\]!*]','',result)
171
+ read_info = emoji.replace_emoji(read_info,replace="")
172
+ state = state + [(message,result)]
173
+ log_state += [(message,"/////")]
174
+ log_state += [("/////",result)]
175
+
176
+ history.append({"role": "user", "content": message})
177
+ history.append({"role": "assistant", "content": result})
178
+
179
+ if autoplay==False:
180
+ return state, state, aux_state, None,log_state,history
181
 
182
+ else:
183
+ audio = await texttospeech(read_info,language,gender)
184
+ return state, state, aux_state, audio,log_state,history
185
+
 
 
 
 
 
 
 
186
 
187
 
188
+ async def upload_callback(image_input,state, log_state, task_type, openai_api_key=None,language="English",narritive=None,history=None,autoplay=True,session="Session 1"):
189
  print("narritive", narritive)
190
  if isinstance(image_input, dict): # if upload from sketcher_input, input contains image and mask
191
  image_input = image_input['background']
 
195
  elif isinstance(image_input, bytes):
196
  image_input = Image.open(io.BytesIO(image_input))
197
 
 
198
  click_state = [[], [], []]
 
 
199
  image_input = image_resize(image_input, res=1024)
200
 
201
  model = build_caption_anything_with_models(
 
211
  original_size = model.original_size
212
  input_size = model.input_size
213
 
214
+ print('upload_callback: add caption to chatGPT memory')
215
+ new_image_path = get_new_image_name('chat_image', func_name='upload')
216
+ image_input.save(new_image_path)
217
+ print("img_path",new_image_path)
218
+ paragraph = get_gpt_response(openai_api_key, new_image_path,f"What's going on in this picture? in {language}")
219
+ if task_type=="task 3":
220
+ name="Along the River During the Qingming Festival"
221
+ artist="Zhang Zeduan"
222
+ year="12th century (Song Dynasty)"
223
+ material="Chinese painting"
224
+ gender="male"
225
+
226
+ elif task_type=="task 1":
227
+ name ="The Ambassadors"
228
+ artist ="Hans Holbein the Younger"
229
+ year = "1533 (Northern Renaissance)"
230
+ material="Realism"
231
+ gender = "male"
 
 
 
 
 
 
 
 
 
 
232
 
233
+ elif task_type=="task 2":
234
+ name = "The Football Players"
235
+ artist= "Albert Gleizes"
236
+ year= "1912 (Cubism)"
237
+ material="Cubism"
238
+ gender= "male"
239
+
240
+ else:
241
+ parsed_data = get_gpt_response(openai_api_key, new_image_path,"Please provide the name, artist, year of creation (including the art historical period), and painting style used for this painting. Return the information in dictionary format without any newline characters. Format as follows: { \"name\": \"Name of the painting\", \"artist\": \"Name of the artist\", \"year\": \"Year of creation (Art historical period)\", \"style\": \"Painting style used in the painting\"}")
242
+ print(parsed_data)
243
+ parsed_data = json.loads(parsed_data.replace("'", "\""))
244
+ name, artist, year, material= parsed_data["name"],parsed_data["artist"],parsed_data["year"], parsed_data["style"]
245
+ gender="male"
246
+ gender=gender.lower()
247
 
248
  if language=="English":
249
  if naritive_mapping[narritive]==0 :
 
290
 
291
 
292
  def inference_click(image_input, point_prompt, click_mode, enable_wiki, language, sentiment, factuality,
293
+ length, image_embedding, state, click_state, original_size, input_size, text_refiner,
294
  out_state, click_index_state, input_mask_state, input_points_state, input_labels_state, evt: gr.SelectData):
295
  click_index = evt.index
296
 
 
348
  input_labels_state = input_labels
349
  out_state = out
350
 
351
+ new_crop_save_path = get_new_image_name('chat_image', func_name='crop')
352
+ Image.open(out["crop_save_path"]).save(new_crop_save_path)
353
+ print("new crop save",new_crop_save_path)
 
354
 
355
  return state, state, click_state, image_input_nobackground, click_index_state, input_mask_state, input_points_state, input_labels_state, out_state,new_crop_save_path,image_input_nobackground
356
 
 
375
  autoplay,paragraph,focus_type,openai_api_key,new_crop_save_path, gender,log_state,history):
376
 
377
 
378
+ focus_value = PromptTemplates.FOCUS_MAP[focus_type]
379
  click_index = click_index_state
380
 
381
  print("click_index",click_index)
 
390
 
391
  log_state = log_state + [("Selected image point: {}, Input label: {}".format(input_points_state, input_labels_state), None)]
392
 
 
393
  print("Prompt:", prompt)
394
  print("click",click_index)
 
395
  log_state = log_state + [(naritive, None)]
396
 
397
 
 
398
  if not args.disable_gpt:
399
  print("new crop save",new_crop_save_path)
400
  focus_info=get_gpt_response(openai_api_key,new_crop_save_path,prompt)
 
417
  history.append({"role": "assistant", "content": focus_info})
418
 
419
 
 
420
  print("new_cap",focus_info)
421
  read_info = re.sub(r'[#[\]!*]','',focus_info)
422
  read_info = emoji.replace_emoji(read_info,replace="")
 
447
 
448
 
449
 
 
 
 
 
 
 
 
 
 
 
 
 
 
450
  def export_chat_log(chat_state,log_list,narrative):
451
  try:
452
  chat_log=""
 
592
  return log_state
593
 
594
 
 
 
595
  def toggle_icons_and_update_prompt(point_prompt):
596
  new_prompt = "Negative" if point_prompt == "Positive" else "Positive"
597
  new_add_icon = "assets/icons/plus-square-blue.png" if new_prompt == "Positive" else "assets/icons/plus-square.png"
 
634
  origin_image = gr.State(None)
635
  image_embedding = gr.State(None)
636
  text_refiner = gr.State(None)
 
637
  original_size = gr.State(None)
638
  input_size = gr.State(None)
639
  paragraph = gr.State("")
 
872
 
873
  openai_api_key.submit(init_openai_api_key, inputs=[openai_api_key],
874
  outputs=[export, modules_need_gpt1, modules_need_gpt3, modules_not_need_gpt,
875
+ modules_not_need_gpt2, module_key_input ,module_notification_box, text_refiner, notification_box,top_row,recommend,reco_reasons,instruct,modules_not_need_gpt3,sort_rec,reco_preview])
876
  enable_chatGPT_button.click(init_openai_api_key, inputs=[openai_api_key],
877
  outputs=[export,modules_need_gpt1, modules_need_gpt3,
878
  modules_not_need_gpt,
879
+ modules_not_need_gpt2,module_key_input,module_notification_box, text_refiner, notification_box,top_row,recommend,reco_reasons,instruct,modules_not_need_gpt3,sort_rec,reco_preview])
880
 
881
  artist_label.click(
882
  get_artistinfo,
 
905
  queue=False,
906
  show_progress=False
907
  )
908
+
909
 
910
  clear_button_text.click(
911
  lambda: ([], [], [[], [], [], []],[]),
 
914
  queue=False,
915
  show_progress=False
916
  )
917
+
918
 
919
  image_input.clear(
920
  lambda: (None, [], [], [[], [], []], "", None, []),
 
924
  show_progress=False
925
  )
926
 
927
+
928
 
929
 
930
+ image_input.upload(upload_callback, [image_input, state, log_state,task_type,openai_api_key,language,naritive,history_log,auto_play,session_type],
931
  [chatbot, state, origin_image, click_state, image_input,image_embedding, original_size, input_size,name_label,artist_label,year_label,material_label,\
932
  paragraph,artist,gender,image_path,log_state,history_log,output_audio])
933
 
934
 
935
 
936
+ chat_input.submit(chat_input_callback, [chat_input,state, aux_state,language,auto_play,gender,openai_api_key,image_path,log_state,history_log,naritive],
937
  [chatbot, state, aux_state,output_audio,log_state,history_log])
938
 
939
  chat_input.submit(lambda: {"text": ""}, None, chat_input)
940
 
941
+ example_image.change(upload_callback, [example_image, state, log_state, task_type, openai_api_key,language,naritive,history_log,auto_play,session_type],
942
  [chatbot, state, origin_image, click_state, image_input, image_embedding, original_size, input_size,name_label,artist_label,year_label,material_label,\
943
  paragraph,artist,gender,image_path, log_state,history_log,output_audio])
944
 
 
945
  example_image.change(
946
  lambda:([],[],[],None,[],gr.update(value="Preview")),
947
  [],
 
951
  inference_click,
952
  inputs=[
953
  origin_image, point_prompt, click_mode, enable_wiki, language, sentiment, factuality, length,
954
+ image_embedding, state, click_state, original_size, input_size, text_refiner,
955
  out_state, click_index_state, input_mask_state, input_points_state, input_labels_state
956
  ],
957
  outputs=[chatbot, state, click_state, image_input, click_index_state, input_mask_state, input_points_state, input_labels_state, out_state,new_crop_save_path,image_input_nobackground],