Tonic commited on
Commit
66499ca
·
1 Parent(s): c6fbaee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -21
app.py CHANGED
@@ -112,24 +112,21 @@ def _launch_demo(args, model, tokenizer):
112
  print("User uploaded an image.")
113
  query = {'image': chat_query[0]}
114
  else:
115
- print("User: " + _parse_text(chat_query))
116
- query = {'text': chat_query}
117
- history_cp = copy.deepcopy(task_history)
118
- full_response = ""
119
- history = process_history_for_model(history_cp)
120
- response, history = model.chat(tokenizer, query=query, history=history)
121
- image = tokenizer.draw_bbox_on_latest_picture(response, history)
122
- if image is not None:
123
- image_path = save_image(image)
124
- _chatbot[-1] = (chat_query, (image_path,))
125
- response = process_response(response)
126
- else:
127
- _chatbot[-1] = (chat_query, response)
128
- task_history = update_task_history(task_history, history, response)
129
-
130
- return _chatbot
131
-
132
-
133
 
134
  def regenerate(_chatbot, task_history):
135
  if not task_history:
@@ -149,9 +146,9 @@ def _launch_demo(args, model, tokenizer):
149
  task_text = text
150
  if len(text) >= 2 and text[-1] in PUNCTUATION and text[-2] not in PUNCTUATION:
151
  task_text = text[:-1]
152
- history = history + [(_parse_text(text), None)]
153
- task_history = task_history + [(task_text, None)]
154
- return history, task_history, ""
155
 
156
  def add_file(history, task_history, file):
157
  if file is None:
 
112
  print("User uploaded an image.")
113
  query = {'image': chat_query[0]}
114
  else:
115
+ print("User: " + _parse_text(chat_query))
116
+ query = {'text': chat_query}
117
+ history_cp = copy.deepcopy(task_history)
118
+ full_response = ""
119
+ history = process_history_for_model(history_cp)
120
+ response, history = model.chat(tokenizer, query=query, history=history)
121
+ image = tokenizer.draw_bbox_on_latest_picture(response, history)
122
+ if image is not None:
123
+ image_path = save_image(image)
124
+ _chatbot[-1] = (chat_query, (image_path,))
125
+ response = process_response(response)
126
+ else:
127
+ _chatbot[-1] = (chat_query, response)
128
+ task_history = update_task_history(task_history, history, response)
129
+ return _chatbot
 
 
 
130
 
131
  def regenerate(_chatbot, task_history):
132
  if not task_history:
 
146
  task_text = text
147
  if len(text) >= 2 and text[-1] in PUNCTUATION and text[-2] not in PUNCTUATION:
148
  task_text = text[:-1]
149
+ history = history + [(_parse_text(text), None)]
150
+ task_history = task_history + [(task_text, None)]
151
+ return history, task_history, ""
152
 
153
  def add_file(history, task_history, file):
154
  if file is None: