Update app.py
Browse files
app.py
CHANGED
|
@@ -38,7 +38,15 @@ def _get_args():
|
|
| 38 |
args = parser.parse_args()
|
| 39 |
return args
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
def _load_model_tokenizer(args):
|
| 43 |
model_id = args.checkpoint_path
|
| 44 |
model_dir = snapshot_download(model_id, revision=args.revision)
|
|
@@ -230,13 +238,7 @@ Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder
|
|
| 230 |
)
|
| 231 |
|
| 232 |
submit_file_btn.click(
|
| 233 |
-
fn=
|
| 234 |
-
inputs=[chatbot, task_history],
|
| 235 |
-
outputs=[chatbot]
|
| 236 |
-
)
|
| 237 |
-
|
| 238 |
-
submit_file_btn.click(
|
| 239 |
-
fn=add_file,
|
| 240 |
inputs=[chatbot, task_history, file_upload],
|
| 241 |
outputs=[chatbot, task_history]
|
| 242 |
)
|
|
|
|
| 38 |
args = parser.parse_args()
|
| 39 |
return args
|
| 40 |
|
| 41 |
+
def handle_image_submission(_chatbot, task_history, file):
|
| 42 |
+
if file is None:
|
| 43 |
+
return _chatbot, task_history # Return if no file is uploaded
|
| 44 |
+
file_path = save_image(file)
|
| 45 |
+
history_item = ((file_path,), None)
|
| 46 |
+
_chatbot.append(history_item)
|
| 47 |
+
task_history.append(history_item)
|
| 48 |
+
return predict(_chatbot, task_history)
|
| 49 |
+
|
| 50 |
def _load_model_tokenizer(args):
|
| 51 |
model_id = args.checkpoint_path
|
| 52 |
model_dir = snapshot_download(model_id, revision=args.revision)
|
|
|
|
| 238 |
)
|
| 239 |
|
| 240 |
submit_file_btn.click(
|
| 241 |
+
fn=handle_image_submission,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
inputs=[chatbot, task_history, file_upload],
|
| 243 |
outputs=[chatbot, task_history]
|
| 244 |
)
|