Update app.py
Browse files
app.py
CHANGED
@@ -38,7 +38,9 @@ def _get_args():
|
|
38 |
return args
|
39 |
|
40 |
def handle_image_submission(_chatbot, task_history, file):
|
|
|
41 |
if file is None:
|
|
|
42 |
return _chatbot, task_history
|
43 |
file_path = save_image(file, uploaded_file_dir) # Renamed for clarity
|
44 |
history_item = ((file_path,), None)
|
@@ -146,8 +148,8 @@ def _launch_demo(args, model, tokenizer):
|
|
146 |
|
147 |
if 'image' in query[0]:
|
148 |
image = tokenizer.draw_bbox_on_latest_picture(response)
|
149 |
-
|
150 |
-
image_path =
|
151 |
_chatbot[-1] = (chat_query, (image_path,))
|
152 |
else:
|
153 |
_chatbot[-1] = (chat_query, "No image to display.")
|
@@ -156,7 +158,7 @@ def _launch_demo(args, model, tokenizer):
|
|
156 |
return _chatbot
|
157 |
|
158 |
|
159 |
-
def
|
160 |
if image is None:
|
161 |
return None
|
162 |
temp_dir = secrets.token_hex(20)
|
|
|
38 |
return args
|
39 |
|
40 |
def handle_image_submission(_chatbot, task_history, file):
|
41 |
+
print("handle_image_submission called")
|
42 |
if file is None:
|
43 |
+
print("No file uploaded")
|
44 |
return _chatbot, task_history
|
45 |
file_path = save_image(file, uploaded_file_dir) # Renamed for clarity
|
46 |
history_item = ((file_path,), None)
|
|
|
148 |
|
149 |
if 'image' in query[0]:
|
150 |
image = tokenizer.draw_bbox_on_latest_picture(response)
|
151 |
+
if image is not None:
|
152 |
+
image_path = save_image(image, uploaded_file_dir)
|
153 |
_chatbot[-1] = (chat_query, (image_path,))
|
154 |
else:
|
155 |
_chatbot[-1] = (chat_query, "No image to display.")
|
|
|
158 |
return _chatbot
|
159 |
|
160 |
|
161 |
+
def save_uploaded_image(image_file, upload_dir):
|
162 |
if image is None:
|
163 |
return None
|
164 |
temp_dir = secrets.token_hex(20)
|