-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gpt4v_vqa] update eusilsp lib and add simple script
- Loading branch information
1 parent
ff9d5c0
commit a963fb9
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env roseus | ||
|
||
(load "package://gpt4v_vqa/euslisp/utils.l") | ||
|
||
(ros::roseus "run_simple_vqa") | ||
|
||
(print "Question is \"Please describe the image briefly.\"") | ||
(print (format nil "Answer is ~a" (run-vqa "Please describe the image briefly."))) | ||
(exit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
(ros::load-ros-manifest "jsk_recognition_msgs") | ||
|
||
(defparameter *vqa-action* nil) | ||
|
||
(defun init-vqa-action (&key (timeout 10)) | ||
(unless *vqa-action* | ||
(setq *vqa-action* | ||
(instance ros::simple-action-client :init | ||
"/vqa/inference_server" jsk_recognition_msgs::VQATaskAction))) | ||
(send *vqa-action* :wait-for-server timeout) | ||
) | ||
|
||
(defun run-vqa (question &optional msg_image &key (timeout 30)) | ||
"run vqa action client. return answer string or nil if failed." | ||
(if (not (init-vqa-action)) | ||
(return-from run-vqa nil)) | ||
(let* (result answer | ||
(action-goal (instance jsk_recognition_msgs::VQATaskGoal :init))) | ||
(send action-goal :questions (list question)) | ||
(if msg_image | ||
(send action-goal :image msg_image) | ||
) | ||
(send *vqa-action* :send-goal action-goal) | ||
(unless (send *vqa-action* :wait-for-result :timeout timeout) | ||
(send *vqa-action* :cancel-all-goals) | ||
(ros::ros-error "No result returned from /vqa action server") | ||
(return-from run-vqa nil)) | ||
(setq result (send *vqa-action* :get-result)) | ||
(if (and result (> (length (send result :result :result)) 0)) | ||
(send (elt (send result :result :result) 0) :answer) | ||
nil) | ||
) | ||
) |