Vision-CAIR commited on
Commit
15fb106
1 Parent(s): f48d9b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -66,13 +66,15 @@ print('Initialization Finished')
66
  # ========================================
67
 
68
  def gradio_reset(chat_state, img_list):
69
- chat_state.messages = []
70
- img_list = []
 
 
71
  return None, gr.update(value=None, interactive=True), gr.update(placeholder='Please upload your image first', interactive=False), gr.update(value="Upload & Start Chat", interactive=True), chat_state, img_list
72
 
73
  def upload_img(gr_img, text_input, chat_state):
74
  if gr_img is None:
75
- return None, None, gr.update(interactive=True)
76
  chat_state = CONV_VISION.copy()
77
  img_list = []
78
  llm_message = chat.upload_img(gr_img, chat_state, img_list)
 
66
  # ========================================
67
 
68
  def gradio_reset(chat_state, img_list):
69
+ if chat_state is not None:
70
+ chat_state.messages = []
71
+ if img_list is not None:
72
+ img_list = []
73
  return None, gr.update(value=None, interactive=True), gr.update(placeholder='Please upload your image first', interactive=False), gr.update(value="Upload & Start Chat", interactive=True), chat_state, img_list
74
 
75
  def upload_img(gr_img, text_input, chat_state):
76
  if gr_img is None:
77
+ return None, None, gr.update(interactive=True), chat_state, None
78
  chat_state = CONV_VISION.copy()
79
  img_list = []
80
  llm_message = chat.upload_img(gr_img, chat_state, img_list)