Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A pull request for all the changes integrated into the Nov23 demo #378

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
79ab852
Revise emotion detector node to be single topic subscriber
derkmed Oct 26, 2023
b50f844
Add Visual Question Answerer Node
derkmed Oct 26, 2023
595713a
Add new visual question answering prompt (teacher mode)
derkmed Oct 26, 2023
ed30958
Add dialogue history to visual question answering
derkmed Oct 26, 2023
00dad55
Add Centroid Strategy for Detected Objects
derkmed Oct 27, 2023
f399390
Add Last n Objects to Visual Question Answering Node
derkmed Oct 27, 2023
a1722d5
Add Live Visual QA Tmux Config
derkmed Oct 27, 2023
a50c777
Change intent detection to always publish to interpreted topic
derkmed Oct 27, 2023
f0e6151
Remove expected emotion detection publishing
derkmed Oct 27, 2023
db610a6
Remove legacy intent detector node
derkmed Oct 28, 2023
b00175b
Add centroid 2d strategy queue
derkmed Oct 28, 2023
d9daf47
Add Centroid 2D Strategy Queue Test for no insertions
derkmed Oct 30, 2023
f5cf171
Integrate 2d centroid distance queueing into visual question answering
derkmed Oct 30, 2023
7af13f7
Rename CENTER filter type to CENTROID
derkmed Oct 30, 2023
36e2f57
Add live tmux config for Centroid Visual QA
derkmed Oct 30, 2023
8e87f2f
Remove deprecated queueing code in visual question answering
derkmed Oct 30, 2023
6af4b23
Change tmuxinator configs for visual question answering to be debug_m…
derkmed Oct 30, 2023
ac83c22
Fix live object detectio overlay tmux configuration
derkmed Oct 30, 2023
c9de08c
Add tmux config fixes
derkmed Oct 30, 2023
b4934f2
Fix emotion detector code and remove filtering
derkmed Oct 31, 2023
3cd0ffe
Add optional target phrase filtering
derkmed Oct 31, 2023
d2fd595
Remove dialogue history TODO
derkmed Oct 31, 2023
33cdfe3
Change emotion detector to base to reduce GPT queries
derkmed Oct 31, 2023
42af572
Refactor bounding boxes and centroid 2d strategy queueing
derkmed Oct 31, 2023
4b35a7d
Integrate centered and surrounding observables together in visual que…
derkmed Oct 31, 2023
96bba91
Add general purpose dialogue utterance message
derkmed Nov 2, 2023
b6709a0
Refactor Dialogue System Nodes to inherit from BaseDialogueSystemNode…
derkmed Nov 2, 2023
020ad07
Add surrounding quotations to user question utterance
derkmed Nov 2, 2023
919a26c
Rearrange visual and vocal dialogue system tmux configurations
derkmed Nov 2, 2023
cfdf435
Add timeout parameter to dialogue system nodes
derkmed Nov 2, 2023
b8d6efd
Remove outdated filter type code in Visual Question Answering Node
derkmed Nov 2, 2023
ae8fd47
Add ignorables parameter to Visual Question Answering Node
derkmed Nov 2, 2023
1f16ada
Delete unused prompt instructions in Visual Question Answering Node
derkmed Nov 2, 2023
af07598
Apply code formatting
derkmed Nov 2, 2023
a615dc5
Merge remote-tracking branch 'upstream/master' into HEAD
ovenmitt Nov 2, 2023
fef1a3b
Merge remote-tracking branch 'upstream/master' into HEAD
ovenmitt Nov 2, 2023
5cd28c0
Merge remote-tracking branch 'upstream/master' into HEAD
ovenmitt Nov 3, 2023
efe27d9
Merge remote-tracking branch 'upstream/master' into HEAD
ovenmitt Nov 3, 2023
3277e73
Refactor optional field derivation in prompt construction
derkmed Nov 4, 2023
b733344
Add object clarification intent and fix intent and emotion detection …
derkmed Nov 4, 2023
f67c384
Add override case for detected object clarification intent
derkmed Nov 4, 2023
d9fbb98
Revise visual question answering prompt
derkmed Nov 4, 2023
18f7adf
Add latest live vqa tmux config
derkmed Nov 4, 2023
83e6dbe
Change object clarification response message
derkmed Nov 5, 2023
97f42e2
Changes for voice demo
ovenmitt Nov 5, 2023
6610e7a
Merge with object clarification detection
ovenmitt Nov 5, 2023
2727083
Adding utterance to feedback generator
ovenmitt Nov 6, 2023
5f91c8d
final touches
ovenmitt Nov 6, 2023
c3bdccb
Small fixes for demo
ovenmitt Nov 7, 2023
91daa8d
Optimize prompt for demo
ovenmitt Nov 8, 2023
dbd99d3
Last adjustments for demo
ovenmitt Nov 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions angel_system/data/common/bounding_boxes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from typing import *


class BoundingBoxes:
def __init__(
self,
left: List[int],
right: List[int],
top: List[int],
bottom: List[int],
item: List[Any],
):
"""
Wrapper of bounding boxes and a contained entity corresponding to each bounding box.
The item is intentionally kept ambiguous to provide flexibility (e.g. can pass in
an object label that corresponds to each bounding box or a tuple of an object label and
its confidence score).
"""
self.left = left
self.right = right
self.top = top
self.bottom = bottom
self.item = item
6 changes: 0 additions & 6 deletions angel_system/global_step_prediction/global_step_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,6 @@ def conditionally_reset_irrational_trackers(self, tracker, skip=False):
):
print("reset condition hit!!")
# import ipdb; ipdb.set_trace()
if tracker["recipe"] == "coffee":
print(f"tea step = {self.trackers[1]['current_granular_step']}")
for tracker_ind in self.find_trackers_by_recipe(
resetter_granular_step[recipe][1]
):
Expand All @@ -696,10 +694,6 @@ def conditionally_reset_irrational_trackers(self, tracker, skip=False):
][0]
):
self.reset_one_tracker(tracker_ind)
if tracker["recipe"] == "coffee":
print(
f"tea step after = {self.trackers[1]['current_granular_step']}"
)
else:
for recipe in resetter_granular_step:
granular_steps = [
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import logging
import heapq
from scipy.spatial import distance
import threading
from typing import *

from angel_system.data.common.bounding_boxes import BoundingBoxes

LOG = logging.getLogger(__name__)


class Centroid2DStrategyQueue:
"""
Little class to handle priority queueing of detected object bounding boxes
based on their centroid (center coordinate of the bounding box).
Items are stored in a priority queue based on a timestamp integer.
When items are popped from the queue, the `last_n` items *before* a provided
timestamp are returned.


Typical Example Usage:
q = Centroid2DStrategyQueue(n=1, k=2)
q.add(timestamp=1, BoundingBoxes(..., [('obj1', 'obj2', 'obj3')]))
q.add(timestamp=2, BoundingBoxes(..., [('obj1', 'obj2', 'obj3')]))
q.get_n_before(2)
"""

def __init__(
self,
n: int,
center_x: int,
center_y: int,
k: int = 1,
log_func: Optional[Callable[..., None]] = None,
):
"""
Additional arguments are passed to the logging method
:param n: Whenever objects are retrieved, return the last n entries.
:param k: Acquires the top k objects that are the most centered given their centroid.
:param log_func: Optional callable to be invoked to receive the
message. If this is `None`, the local Logger instance to this
module is used.
"""
self._log_func = log_func

self.n = n
self.k = k

# This is the main priority queue. Each item should be a Tuple[int, Any] in which
# the elements correspond to (Integer Timestamp, Any Object). An example of the queued
# object's second element could be a Tuple of the top K detected objects.
self.pq = []
self.center_x = center_x
self.center_y = center_y
self.lock = threading.Lock()

def get_queue(self):
return self.pq

def add(self, timestamp: int, bounding_boxed_item: BoundingBoxes):
self.lock.acquire()
k_most_centered_objects = self._get_k_most_center_objects(bounding_boxed_item)
heapq.heappush(self.pq, (timestamp, k_most_centered_objects))
self.lock.release()

def get_n_before(self, timestamp: int) -> List[Any]:
"""
Gets the self.n items before the provided timestamp.
"""
items = []
self.lock.acquire()
while self.pq:
next_timestamp, _ = self.pq[0]
if next_timestamp < timestamp:
items.append(heapq.heappop(self.pq))
else:
break
self.lock.release()
if self._log_func:
self._log_func(
f"Read up to {self.n} items from queue"
+ "; ".join([f"{item} @ Time={time}" for time, item in items])
)
return items[-self.n :] if items else items

def _get_k_most_center_objects(self, bb: BoundingBoxes) -> List[Any]:
"""
Acquires the top k objects with respect to centroid distance from the center pixel.
Returns a list of Tuples of (centroid distance, top k most centered objects)
"""
k_most_centered_objects = []

# Sort the bounding boxes in order of distance from centroid to center pixel.
zipped = zip(bb.item, bb.left, bb.right, bb.top, bb.bottom)
for item, left, right, top, bottom in zipped:
centroid_x, centroid_y = self._get_centroid(left, right, top, bottom)
dist = distance.euclidean(
[centroid_x, centroid_y], [self.center_x, self.center_y]
)
heapq.heappush(k_most_centered_objects, (dist, item))

# Return the top k centered objects based on centroid distance.
result = []
for _ in range(self.k):
if not k_most_centered_objects:
break
result.append(heapq.heappop(k_most_centered_objects))
return result

def _get_centroid(
self, left: int, right: int, top: int, bottom: int
) -> Tuple[int, int]:
"""
Calculates the center 2D pixel of a 2D bounding box.
"""
width_center = left + int((right - left) / 2)
height_center = top + int((bottom - top) / 2)
return [width_center, height_center]
Loading