-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make QueryImage a ServiceState.
- Loading branch information
Showing
2 changed files
with
20 additions
and
10 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
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 |
---|---|---|
@@ -1,15 +1,24 @@ | ||
import smach_ros | ||
from lasr_vision_clip.srv import Vqa | ||
from lasr_vision_msgs.srv import Vqa, VqaRequest | ||
|
||
from typing import List, Union | ||
|
||
|
||
class QueryImage(smach_ros.ServiceState): | ||
|
||
def __init__( | ||
self, | ||
): | ||
super(smach_ros.ServiceState, self).__init__( | ||
"/clip_vqa/query_service", | ||
Vqa, | ||
request_slots=["answers"], | ||
response_slots=["answer", "similarity_score"], | ||
) | ||
def __init__(self, possible_answers: Union[None, List[str]] = None): | ||
|
||
if possible_answers is not None: | ||
super(QueryImage, self).__init__( | ||
"/clip_vqa/query_service", | ||
Vqa, | ||
request=VqaRequest(possible_answers=possible_answers), | ||
response_slots=["answer", "similarity"], | ||
) | ||
else: | ||
super(QueryImage, self).__init__( | ||
"/clip_vqa/query_service", | ||
Vqa, | ||
request_slots=["possible_answers"], | ||
response_slots=["answer", "similarity"], | ||
) |