Spaces:
Runtime error
Runtime error
update chat
Browse files
app.py
CHANGED
@@ -207,12 +207,24 @@ def gradio_reset(chat_state, img_list):
|
|
207 |
value="Upload & Start Chat", interactive=True), chat_state, img_list
|
208 |
|
209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
def upload_img(gr_img, text_input, chat_state,chatbot):
|
211 |
if gr_img is None:
|
212 |
return None, None, gr.update(interactive=True), chat_state, None
|
213 |
chat_state = []
|
214 |
img_list = []
|
215 |
-
|
|
|
216 |
llm_message = chat.upload_img(gr_img, chat_state, img_list)
|
217 |
return gr.update(interactive=False), gr.update(interactive=True, placeholder='Type and press Enter'), gr.update(
|
218 |
value="Start Chatting", interactive=False), chat_state, img_list
|
|
|
207 |
value="Upload & Start Chat", interactive=True), chat_state, img_list
|
208 |
|
209 |
|
210 |
+
def build_image(image):
|
211 |
+
if image is None:
|
212 |
+
return None
|
213 |
+
# res = draw_bounding_boxes(image=image, boxes=boxes_to_draw, colors=color_to_draw, width=8)
|
214 |
+
from torchvision.transforms import ToPILImage
|
215 |
+
# res = ToPILImage()(res)
|
216 |
+
_, path = tempfile.mkstemp(suffix='.jpg', dir=TEMP_FILE_DIR)
|
217 |
+
image.save(path)
|
218 |
+
|
219 |
+
return path
|
220 |
+
|
221 |
def upload_img(gr_img, text_input, chat_state,chatbot):
|
222 |
if gr_img is None:
|
223 |
return None, None, gr.update(interactive=True), chat_state, None
|
224 |
chat_state = []
|
225 |
img_list = []
|
226 |
+
path = build_image(gr_img)
|
227 |
+
chatbot = chatbot + [[(path,), None]]
|
228 |
llm_message = chat.upload_img(gr_img, chat_state, img_list)
|
229 |
return gr.update(interactive=False), gr.update(interactive=True, placeholder='Type and press Enter'), gr.update(
|
230 |
value="Start Chatting", interactive=False), chat_state, img_list
|