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

Colour Estimation added as part of Feature service! (not used by receptionist) #253

Closed
wants to merge 422 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
422 commits
Select commit Hold shift + click to select a range
c90c6bb
Removed "PrintSay" class as it doesn't work. Updated bodypix services.
Jun 24, 2024
90d8c3c
Merge remote-tracking branch 'upstream/main'
Jun 24, 2024
b612ed9
Adapt
haiwei-luo Jun 24, 2024
205897e
Merge branch 'main' of github.com:haiwei-luo/Base into main
haiwei-luo Jun 24, 2024
2864f87
Returning confidence of the prediction.
Jun 25, 2024
4dc892d
Reformatted the code
Jun 25, 2024
a687aec
Stopped using segmentation.
Jun 25, 2024
4f25c0f
Returned cloth category strings.
Jun 25, 2024
913eda1
added look at person back.
Jun 25, 2024
6eed3d9
Catch if attributes detection fail in main state machine
haiwei-luo Jun 26, 2024
97a0277
Remove learning face for guest2
haiwei-luo Jun 26, 2024
f2ba060
Identify look at person bug and reformatting
haiwei-luo Jun 26, 2024
4cf1a84
Handling no empty seat and no detection
haiwei-luo Jun 26, 2024
683636f
Add flag to indicate no detections
haiwei-luo Jun 26, 2024
b3e889a
Fix bugs
haiwei-luo Jun 26, 2024
b570683
removed wrong -0,5
Jun 27, 2024
c81cc2b
Merge https://github.com/haiwei-luo/Base
Jun 27, 2024
118b461
Added conditions for testing on roslocal.
Jun 27, 2024
0c1cb36
Added validate keypoints into the state.
Jun 27, 2024
049ceab
Updated missing body part detection.
Jun 27, 2024
83d3329
Updated detect_keypoints in bodipix.
Jun 27, 2024
600435b
Updated camera movement suggestions.
Jun 27, 2024
8a80b4d
refactor: move asking for name and drink into more generic func
m-barker Jun 30, 2024
5d16f59
refactor: move going to waiting area to own function
m-barker Jun 30, 2024
46257c1
added maximum attempts to adjust camera.
Jun 30, 2024
086d589
refactor: add guide guest function
m-barker Jun 30, 2024
ffc4ca2
Merge branch 'main' of https://github.com/LASR-at-Home/Base into rece…
m-barker Jun 30, 2024
7ce0365
refactor: always debug.
jws-1 Jun 30, 2024
e615705
refactor: redundant initialisation.
jws-1 Jun 30, 2024
f9a345b
refactor: make learn_face take a list of images as input.
jws-1 Jun 30, 2024
4f0850f
refactorr: remove LearnFace skill.
jws-1 Jun 30, 2024
1c6d79d
refactor: combine LookToPoint and LookToGivenPoint.
jws-1 Jun 30, 2024
2c4d4f3
refactor: use PlayMotion instead of LookToGivenPoint.
jws-1 Jun 30, 2024
05b088d
feat: get cropped images of person to pass to LearnFace.
jws-1 Jun 30, 2024
352ed14
refactor: remove unused variable.
jws-1 Jun 30, 2024
220494b
refactor: don't say that no attributes were detected, just don't say …
jws-1 Jun 30, 2024
706bc7b
WIP: compute person point
m-barker Jun 30, 2024
aa20000
Merge branch 'receptionist-polishing' of https://github.com/LASR-at-H…
m-barker Jun 30, 2024
0dadf1b
feat: WIP sofa
fireblonde Jun 30, 2024
a328fe6
Merge commit '0dadf1b9' into receptionist-polishing
fireblonde Jun 30, 2024
c11bfa2
Merge branch 'main' of https://github.com/LASR-at-Home/Base into rece…
m-barker Jun 30, 2024
c20ccf8
refactor: remove commented line.
jws-1 Jun 30, 2024
d1cf209
fix: std_msgs -> sensor_msgs :/
jws-1 Jun 30, 2024
7147270
fix/refactor: launch file.
jws-1 Jun 30, 2024
661aac5
fix: remember to set default argument.
jws-1 Jun 30, 2024
8d74cf3
feat: use opencv for backend detector (2-3x speedup).
jws-1 Jun 30, 2024
c7d8525
fix: learn face state.
jws-1 Jun 30, 2024
8efd731
feat: update launch file.
jws-1 Jun 30, 2024
2324251
feat: HandleGuest state, for concurrent learning of faces, extracting
jws-1 Jun 30, 2024
6b9bdfb
fix: update cropped detection calls.
jws-1 Jun 30, 2024
4e7c61f
Think now the coordinates are wrong, probably y and x should inverse,…
Jun 30, 2024
77810a3
fix: the debug publisher in detect 3d area
fireblonde Jul 1, 2024
4829216
chore: take kitchen points
fireblonde Jul 1, 2024
c027180
feat: exclude the sofa from the seating area
fireblonde Jul 1, 2024
2d3f82a
feat: exclude the sofa from the seating area in test
fireblonde Jul 1, 2024
7eca44e
fix: missing args
fireblonde Jul 1, 2024
f2d5fc3
feat: the intersect
fireblonde Jul 1, 2024
2421861
chore: update the poses
fireblonde Jul 1, 2024
880bd74
Works but soooooo slow.
Jul 1, 2024
e0cb3a3
Still have some wrong coordinate issue but much better now.
Jul 1, 2024
1930bba
fix: cropped detection usage.
jws-1 Jul 2, 2024
06bff3a
feat: don't ask to repeat name/drink several times.
jws-1 Jul 2, 2024
0437b6c
feat: make sure to return failed if service raises an exception.
jws-1 Jul 2, 2024
06ad0b3
feat: more explicit failures.
jws-1 Jul 2, 2024
df00bef
feat: better error handling.
jws-1 Jul 2, 2024
dcb2f09
fix: transitions.
jws-1 Jul 2, 2024
4a43c96
fix: don't speak inside DescribePeople.
jws-1 Jul 2, 2024
334fc14
feat: pointcloud sweep state machine
m-barker Jul 2, 2024
7fbb184
Merge branch 'receptionist-polishing' of https://github.com/LASR-at-H…
m-barker Jul 2, 2024
353ed0b
Test
haiwei-luo Jul 2, 2024
4e33b11
Merge branch 'receptionist-polishing' of github.com:LASR-at-Home/Base…
haiwei-luo Jul 2, 2024
a6fd165
fix: look for the correct person.
jws-1 Jul 2, 2024
97cbee7
Robot now looks 'very left' to look at guest
haiwei-luo Jul 2, 2024
4e80a28
feat: run and process sweep detections
m-barker Jul 2, 2024
2be26a6
Merge branch 'receptionist-polishing' of https://github.com/LASR-at-H…
m-barker Jul 2, 2024
54fcc81
In general this works now, needs bit more polish, also need to clean …
Jul 2, 2024
7358134
commit the current slow version before update to new brand.
Jul 2, 2024
e2c3543
Merge remote-tracking branch 'upstream/receptionist-polishing'
Jul 2, 2024
96ab223
feat: new tf pcl package
m-barker Jul 2, 2024
ba3b4aa
No learning face for 2nd guest
haiwei-luo Jul 2, 2024
a9e8aff
Merge branch 'receptionist-polishing' of github.com:LASR-at-Home/Base…
haiwei-luo Jul 2, 2024
c19baec
Remove print statement
haiwei-luo Jul 2, 2024
0c2ed2e
Replace get image using the service state, see if it's faster.
Jul 2, 2024
cee4f68
WORKS FINALLY!!!
Jul 2, 2024
26cd6b3
Remove saying attributes for host
haiwei-luo Jul 2, 2024
8873e7b
feat: late night deat detections
m-barker Jul 2, 2024
a9bf6ef
Merge branch 'receptionist-polishing' of https://github.com/LASR-at-H…
m-barker Jul 2, 2024
0382916
refactor a little bit.
Jul 2, 2024
8bd3a51
feat(WIP): use new sweep for seating guest.
jws-1 Jul 3, 2024
3ea003f
feat: take target_frame as input.
jws-1 Jul 3, 2024
8bf5f20
fix: do tf.
jws-1 Jul 3, 2024
b600bb1
fix: seating.
jws-1 Jul 3, 2024
175ad86
fix: imports.
jws-1 Jul 3, 2024
6fabe99
Made adjust camera an idividual state machine that runs compleately i…
Jul 3, 2024
32bb259
Merge remote-tracking branch 'upstream/receptionist-polishing'
Jul 3, 2024
7ed0fd6
Added adjust camera into the state machine.
Jul 3, 2024
42e6e02
fixed a small bug that parameters of GetCroppedImage is now different.
Jul 3, 2024
893efa5
wip: load of shit
jws-1 Jul 3, 2024
3a2a429
fixed some little bugs
Jul 3, 2024
82e656b
Merge remote-tracking branch 'upstream/receptionist-polishing'
Jul 3, 2024
76d5acd
Let's see if this change of CDRequest works.
Jul 3, 2024
823e530
haha find this bug of Matt's
Jul 3, 2024
3c20212
Do not use mask for feature detection!
Jul 3, 2024
79b88cf
Preload the bodipix model so that hopefully now it's quicker.
Jul 3, 2024
35ec4d6
quick fix of load model
Jul 3, 2024
8ebf362
Handle known guests
haiwei-luo Jul 3, 2024
2f7263e
Refactor: FindAndLookAt
haiwei-luo Jul 3, 2024
6d6c936
I MEANT KNOWN HOST NOT NAMED GUEST MY BRAIN IS FRIED
haiwei-luo Jul 3, 2024
1c1641d
Fix bug
haiwei-luo Jul 3, 2024
c8ac894
feat: change backend detector.
jws-1 Jul 4, 2024
e0f30ef
chore: update lab config.
jws-1 Jul 4, 2024
67f48d9
Squashed commit of the following:
jws-1 Jul 4, 2024
49a9f64
feat(wip): bring sofas back, get rid of some unnecessary speech.
jws-1 Jul 4, 2024
6e124ff
feat: clip embedding service
m-barker Jul 4, 2024
869a065
Merge branch 'receptionist-polishing' of https://github.com/LASR-at-H…
m-barker Jul 4, 2024
0d5a061
changed that default max_attempts from 1000 to 3 sorry ;)
Jul 4, 2024
fbb62ec
Merge remote-tracking branch 'upstream/receptionist-polishing'
Jul 4, 2024
dc0aa2a
Cleaned the code a bit and lowered the tallest state. A further adjus…
Jul 4, 2024
d0f17b4
Lower the threshold for turning the head a liiiiittttlllle bit smalle…
Jul 4, 2024
71f7359
more shit
jws-1 Jul 4, 2024
1a0f743
less shit?
jws-1 Jul 4, 2024
9ec5469
fix: don't sleep.
jws-1 Jul 4, 2024
f536bf8
feat: sadly not working face detections :(
m-barker Jul 4, 2024
73ed7d2
Merge branch 'receptionist-polishing' of https://github.com/LASR-at-H…
m-barker Jul 4, 2024
7c07e43
something
jws-1 Jul 5, 2024
e6e083a
make state machine for getting name and drink
haiwei-luo Jul 5, 2024
7a085cc
refactor: black
jws-1 Jul 5, 2024
39a5aac
feat: create panorama
m-barker Jul 5, 2024
b9d1bc7
Merge branch 'receptionist-polishing' of https://github.com/LASR-at-H…
m-barker Jul 5, 2024
66c387b
Add speech recovery (local)
haiwei-luo Jul 5, 2024
25dc1d6
Revert lab yaml changes
haiwei-luo Jul 5, 2024
56e2495
Merge branch 'receptionist-polishing' of github.com:LASR-at-Home/Base…
haiwei-luo Jul 5, 2024
6e989b8
Setup jellyfish dependency
haiwei-luo Jul 5, 2024
4cddb4e
the skills for gpsr
Sveali41 Jul 5, 2024
d5a8f39
Incorporate speech recovery as separate state
haiwei-luo Jul 5, 2024
8110475
Merge branch 'main' of https://github.com/Sveali41/LASR_SVEA
Sveali41 Jul 5, 2024
0868f59
Minor cleanup
haiwei-luo Jul 5, 2024
b685170
Merge remote-tracking branch 'upstream/main'
Sveali41 Jul 5, 2024
4c357d0
Incorporate speech recovery into main state machine
haiwei-luo Jul 5, 2024
0c1621e
Fix empty sentence input
haiwei-luo Jul 5, 2024
378a475
Add back commented code
haiwei-luo Jul 5, 2024
925ab2f
Fix state machine
haiwei-luo Jul 5, 2024
d0d4ade
Merge remote-tracking branch 'upstream/receptionist-polishing'
Jul 5, 2024
14f14fc
Merge branch 'main' of https://github.com/m-barker/Base into gpsr-sta…
m-barker Jul 6, 2024
ff6ce7d
Merge branch 'main' of github.com:LASR-at-Home/Base into gpsr-state-m…
m-barker Jul 6, 2024
d97d2c3
Prepare merge.
jws-1 Jul 6, 2024
621a17e
Get rid of old msg.
jws-1 Jul 6, 2024
b88d209
refactor: black
jws-1 Jul 6, 2024
6c35e33
Merge branch 'LASR-at-Home:main' into main
Sveali41 Jul 6, 2024
a7d04ef
feat: GPSR fixes
m-barker Jul 6, 2024
cecb669
Merge remote-tracking branch 'upstream/main'
Sveali41 Jul 6, 2024
89322b4
Merge remote-tracking branch 'upstream/main'
Jul 6, 2024
a5c9447
Merge branch 'main' of https://github.com/MBTMBTMBT/LASR_ben
Jul 6, 2024
7d68023
feat: add launch file needed for existing gpsr skills
m-barker Jul 6, 2024
09acf32
feat: tidying
m-barker Jul 7, 2024
89d1c00
Have a quick fix of hat-hair issue, and a quick remove of the dress (…
Jul 7, 2024
16ff8da
a quick fix of hat-hair penalty.
Jul 7, 2024
3fca2ce
modified adjust_camera a little such as it generally is lowered down …
Jul 7, 2024
667f9cf
I feel that the 'closest' and 'futherest' of cropped_detection is kin…
Jul 7, 2024
314ba28
probably the most common usage of GetCroppedImage is 'closest' so mak…
Jul 7, 2024
0ae1d71
modified all the 'reverse' parts.
Jul 7, 2024
fa3c56f
feat(GPSR): object properties (count/weight/size) (#151)
Sveali41 Jul 6, 2024
2408a7c
Receptionist sweeping + speech updates (#240)
jws-1 Jul 6, 2024
1a69396
feat: add energy thresh and max phrase limits to speech server (#241)
m-barker Jul 6, 2024
7fc002c
Receptionist vector database (#242)
m-barker Jul 6, 2024
d585a5a
Rethinking following (#234)
jws-1 Jul 6, 2024
b8af83d
Bodypix update (#243)
jws-1 Jul 7, 2024
db2c3b7
feat: merge and parameterise FindPerson skills.
jws-1 Jul 8, 2024
5d78d47
feat(WIP): super super simple guide.
jws-1 Jul 8, 2024
7a17677
feat: deliver
jws-1 Jul 8, 2024
b438e6c
feat: place.
jws-1 Jul 8, 2024
ebab6e6
feat: take.
jws-1 Jul 8, 2024
6fe74db
fix: import
jws-1 Jul 8, 2024
b163055
fix: order of imports
jws-1 Jul 8, 2024
9c5fc54
fix: load motions
jws-1 Jul 8, 2024
4304701
fix: set contained state and add actually execute the waypoint iterator.
jws-1 Jul 8, 2024
72b0872
fix: DETECT3D -> DETECT
jws-1 Jul 8, 2024
de932ec
feat: helpers for getting a pose along a path at a given distance fro…
jws-1 Jul 8, 2024
3bc5ee8
feat: approach the person.
jws-1 Jul 8, 2024
677ad2a
fix: don't double the goal tolerance.
jws-1 Jul 8, 2024
34122d2
fix: transitions
jws-1 Jul 8, 2024
85075c6
refactor: get rid of redundant skills.
jws-1 Jul 8, 2024
8d987ba
feat: stubs for DetectClothing and DetectPose.
jws-1 Jul 8, 2024
a80c0f9
feat: answer
jws-1 Jul 8, 2024
0029e3a
feat: add todos and edit launch file
m-barker Jul 8, 2024
ffe875b
Merge branch 'gpsr-state-machine-factory' of https://github.com/LASR-…
m-barker Jul 8, 2024
7c44db5
corrected a small mistake of removing the 'dress' category.
Jul 8, 2024
d72b43b
gpsr changes
Sveali41 Jul 8, 2024
e684d42
feat: gpsr interface and mic testing stuff
m-barker Jul 8, 2024
0b55f15
Merge branch 'main' into HEAD
Sveali41 Jul 8, 2024
9542870
feat: meet.
jws-1 Jul 8, 2024
0c32ed8
changes for object detection state machine
Sveali41 Jul 8, 2024
a99d6ff
Merge branch 'gpsr-state-machine-factory' of https://github.com/LASR-…
Sveali41 Jul 8, 2024
ed253ed
add count object to the state factory
Sveali41 Jul 8, 2024
c155821
add tell the biggest/heaviest thing at a location
Sveali41 Jul 8, 2024
dbd68a9
feat: example yaml.
jws-1 Jul 8, 2024
f773e17
simplify configuration
jws-1 Jul 8, 2024
b8057ed
feat: get polygons.
jws-1 Jul 8, 2024
466681a
feat: add guide skill
m-barker Jul 8, 2024
94c03a5
Merge branch 'gpsr-state-machine-factory' of https://github.com/LASR-…
m-barker Jul 8, 2024
fed7188
fix: elif.
jws-1 Jul 8, 2024
0cb8d96
fix: imports
jws-1 Jul 8, 2024
489122e
feat: add personInfo
m-barker Jul 8, 2024
2e1ce1e
Merge branch 'gpsr-state-machine-factory' of https://github.com/LASR-…
m-barker Jul 8, 2024
31b568b
feat: combine tell/talk
m-barker Jul 8, 2024
5057811
fix: imports
jws-1 Jul 9, 2024
ba8833b
fix: transitions.
jws-1 Jul 9, 2024
b7f6a48
fix: some shit
jws-1 Jul 9, 2024
0ba12a9
feat: handle me
m-barker Jul 9, 2024
82d49e7
Merge branch 'gpsr-state-machine-factory' of https://github.com/LASR-…
m-barker Jul 9, 2024
081a7f3
fix: handle location
jws-1 Jul 9, 2024
be40036
fix: config
jws-1 Jul 9, 2024
b16db6d
feat: additional gesture
jws-1 Jul 9, 2024
b852fcb
chore: update launch file.
jws-1 Jul 9, 2024
a286476
fix: find and guide.
jws-1 Jul 9, 2024
203a536
fix: gesture detection
jws-1 Jul 9, 2024
1e3ce2b
refactor: remove unused imports.
jws-1 Jul 9, 2024
78774f9
feat: store detected gesture to output keys, and don't require a spec…
jws-1 Jul 9, 2024
6db6f8d
feat: TODOs and QA
jws-1 Jul 9, 2024
cd07e7a
feat: follow
jws-1 Jul 9, 2024
e3700a8
refactor: pass image to clip.
jws-1 Jul 9, 2024
7408a40
feat: find person in pose.
jws-1 Jul 9, 2024
c8210c5
not todo anymore :)
jws-1 Jul 9, 2024
afe278d
fix: raise NotImplementedErrors
jws-1 Jul 9, 2024
4f71201
fix: propogate object_category
jws-1 Jul 9, 2024
bcc3e24
fix: utter object name / category
jws-1 Jul 9, 2024
2e5bb9b
fix: take and place.
jws-1 Jul 9, 2024
30cc76e
Changed matt's reverse list back.
Jul 9, 2024
406d746
Added new colour estimation of cloth.
Jul 9, 2024
11bf0d8
Merge remote-tracking branch 'upstream/main'
Jul 9, 2024
6fd7234
up to date to the main.
Jul 9, 2024
fe353da
reformatted some files.
Jul 9, 2024
c467823
correct the launch file, didn't find any issues that cause adjust cam…
Jul 9, 2024
0fd439d
Added some test information outputs, seems everything is fine. Should…
Jul 9, 2024
aab2906
fixed a few issue that makes the service die.
Jul 9, 2024
3d6af2c
Changes to object_comparison
Sveali41 Jul 9, 2024
b2600a7
docs: distinguish between helpers, verbs and the sm builder.
jws-1 Jul 9, 2024
7d65861
feat(WIP): find person (and get query info)
jws-1 Jul 10, 2024
677a087
Merge remote-tracking branch 'upstream/gpsr-state-machine-factory'
Jul 10, 2024
471ee60
reformatted
Jul 10, 2024
0db122c
fix: launch syntax.
jws-1 Jul 11, 2024
10cd6bd
Merge remote-tracking branch 'base/main' into gpsr-state-machine-factory
jws-1 Jul 11, 2024
f0907a2
Merge remote-tracking branch 'base/gpsr-state-machine-factory' into HEAD
jws-1 Jul 11, 2024
6dd9096
Have to give up the model I had been worked on for over a month and b…
Jul 12, 2024
c36dc29
Merge branch 'main' of https://github.com/MBTMBTMBT/LASR_ben
Jul 12, 2024
4274567
updated.
Jul 12, 2024
313a906
Kept unused labels to have zero confidence in order not to break the …
Jul 12, 2024
b6eec38
Merge remote-tracking branch 'upstream/main'
Jul 15, 2024
8feecb4
Merge remote-tracking branch 'upstream/main'
Jul 16, 2024
21ed42f
commented out some old wrong imports.
Jul 16, 2024
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import rospy


from geometry_msgs.msg import (
Point,
Pose,
PoseStamped,
Quaternion,
)
from nav_msgs.srv import GetPlan
from nav_msgs.msg import Path

import numpy as np
import math
from scipy.spatial.transform import Rotation as R
from itertools import permutations

from typing import Union, List
Expand All @@ -27,3 +36,49 @@ def min_hamiltonian_path(start: Pose, poses: List[Pose]) -> Union[None, List[Pos
best_order = list(perm)

return best_order


def get_pose_on_path(
p1: PoseStamped, p2: PoseStamped, dist_to_goal: float = 1.0, tolerance: float = 0.5
) -> Union[None, PoseStamped]:
make_plan: rospy.ServiceProxy = rospy.ServiceProxy("/move_base/make_plan", GetPlan)

chosen_pose: Union[None, PoseStamped] = None

rospy.loginfo(f"Getting plan from {p1} to {p2}.")

if p1.header.frame_id != p2.header.frame_id != "map":
rospy.loginfo(
f"Frames of reference are not 'map' ({p1.header.frame_id} and {p2.header.frame_id})."
)
return chosen_pose

try:
make_plan.wait_for_service(timeout=rospy.Duration.from_sec(10.0))
except rospy.ROSException:
rospy.loginfo("Service /move_base/make_plan not available.")
return chosen_pose

try:
plan: Path = make_plan(p1, p2, tolerance).plan
except rospy.ServiceException as e:
rospy.loginfo(e)
return chosen_pose

rospy.loginfo(f"Got plan with {len(plan.poses)} poses.")

if len(plan.poses) > 0:
for pose in reversed(plan.poses):
if euclidian_distance(pose.pose.position, p2.pose.position) >= dist_to_goal:
chosen_pose = pose
break

return chosen_pose


def compute_face_quat(p1: Pose, p2: Pose) -> Quaternion:
dx: float = p2.position.x - p1.position.x
dy: float = p2.position.y - p1.position.y
theta_deg = np.degrees(math.atan2(dy, dx))
x, y, z, w = R.from_euler("z", theta_deg, degrees=True).as_quat()
return Quaternion(x, y, z, w)
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class TranscribeSpeechAction(object):
self._listening = False

self._action_server.start()
rospy.loginfo(f"Speech Action server {self._action_name} started")

def _configure_microphone(self) -> sr.Microphone:
"""Configures the microphone for listening to speech based on the
Expand Down Expand Up @@ -332,8 +333,8 @@ def configure_model_params(config: dict) -> speech_model_params:
model_params.mic_device = config["mic_device"]
if config["no_warmup"]:
model_params.warmup = False
if config["energy_threshold"]:
model_params.energy_threshold = config["energy_threshold"]
# if config["energy_threshold"]:
# model_params.energy_threshold = config["energy_threshold"]
if config["pause_threshold"]:
model_params.pause_threshold = config["pause_threshold"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def main():
args = parse_args()

recognizer = sr.Recognizer()
recognizer.pause_threshold = 2
microphone = sr.Microphone(device_index=args["device_index"], sample_rate=16000)
threshold = 100
recognizer.dynamic_energy_threshold = False
Expand All @@ -39,7 +40,9 @@ def main():
while transcription_result != "":
print(f"Listening...")
with microphone as source:
wav_data = recognizer.listen(source).get_wav_data()
wav_data = recognizer.listen(
source, phrase_time_limit=10, timeout=5
).get_wav_data()
print(f"Processing...")
# Magic number 32768.0 is the maximum value of a 16-bit signed integer
float_data = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

if USE_ACTIONLIB:
client = actionlib.SimpleActionClient("transcribe_speech", TranscribeSpeechAction)
rospy.loginfo("Waiting for server...")
client.wait_for_server()
repeating = False
rospy.loginfo("Done waiting")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ def main(args: dict) -> None:
output_dir = args["output_dir"]

r = sr.Recognizer()
with sr.Microphone(device_index=13, sample_rate=16000) as source:
r.pause_threshold = 2
with sr.Microphone(device_index=9, sample_rate=16000) as source:
print("Say something!")
audio = r.listen(source, timeout=5, phrase_time_limit=5)
audio = r.listen(source, timeout=5, phrase_time_limit=10)
print("Finished listening")

with open(os.path.join(output_dir, "microphone.raw"), "wb") as f:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ def _3d_bbox_crop(
)
for det in detections
]

if crop_method == "closest":
detections = [det for _, det in sorted(zip(distances, detections))]
distances.sort()

elif crop_method == "furthest":
detections = [
det for _, det in sorted(zip(distances, detections), reverse=True)
Expand Down
4 changes: 2 additions & 2 deletions common/vision/lasr_vision_feature_extraction/nodes/service
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ from lasr_vision_msgs.srv import (
TorchFaceFeatureDetectionDescriptionResponse,
)
from lasr_vision_feature_extraction.categories_and_attributes import (
CategoriesAndAttributes,
CelebAMaskHQCategoriesAndAttributes,
# CategoriesAndAttributes,
# CelebAMaskHQCategoriesAndAttributes,
DeepFashion2GeneralizedCategoriesAndAttributes,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
from os import path

import cv2
import numpy as np
import rospkg
Expand All @@ -11,12 +10,10 @@
import torchvision.models as models
from lasr_vision_feature_extraction.categories_and_attributes import (
CategoriesAndAttributes,
CelebAMaskHQCategoriesAndAttributes,
DeepFashion2GeneralizedCategoriesAndAttributes,
)
from lasr_vision_feature_extraction.image_with_masks_and_attributes import (
ImageWithMasksAndAttributes,
ImageOfPerson,
ImageOfCloth,
)
from lasr_vision_msgs.srv import Vqa, VqaRequest
Expand Down Expand Up @@ -55,129 +52,6 @@ def forward(self, x_copy, x):
return x


class UNetWithResnetEncoder(nn.Module):
def __init__(self, num_classes, in_channels=3, freeze_bn=False, sigmoid=True):
super(UNetWithResnetEncoder, self).__init__()
self.sigmoid = sigmoid
self.resnet = models.resnet34(
pretrained=False
) # Initialize with a ResNet model
if in_channels != 3:
self.resnet.conv1 = nn.Conv2d(
in_channels, 64, kernel_size=7, stride=2, padding=3, bias=False
)

self.encoder1 = nn.Sequential(
self.resnet.conv1, self.resnet.bn1, self.resnet.relu
)
self.encoder2 = self.resnet.layer1
self.encoder3 = self.resnet.layer2
self.encoder4 = self.resnet.layer3
self.encoder5 = self.resnet.layer4

self.up1 = Decoder(512, 256, 256)
self.up2 = Decoder(256, 128, 128)
self.up3 = Decoder(128, 64, 64)
self.up4 = Decoder(64, 64, 64)

self.final_conv = nn.Conv2d(64, num_classes, kernel_size=1)
self._initialize_weights()

if freeze_bn:
self.freeze_bn()

def _initialize_weights(self):
for module in self.modules():
if isinstance(module, nn.Conv2d) or isinstance(module, nn.ConvTranspose2d):
nn.init.kaiming_normal_(module.weight)
if module.bias is not None:
module.bias.data.zero_()
elif isinstance(module, nn.BatchNorm2d):
module.weight.data.fill_(1)
module.bias.data.zero_()

def forward(self, x):
x1 = self.encoder1(x)
x2 = self.encoder2(x1)
x3 = self.encoder3(x2)
x4 = self.encoder4(x3)
x5 = self.encoder5(x4)

x = self.up1(x4, x5)
x = self.up2(x3, x)
x = self.up3(x2, x)
x = self.up4(x1, x)
x = F.interpolate(
x, size=(x.size(2) * 2, x.size(3) * 2), mode="bilinear", align_corners=True
)

x = self.final_conv(x)

if self.sigmoid:
x = torch.sigmoid(x)
return x

def freeze_bn(self):
for module in self.modules():
if isinstance(module, nn.BatchNorm2d):
module.eval()

def unfreeze_bn(self):
for module in self.modules():
if isinstance(module, nn.BatchNorm2d):
module.train()


class MultiLabelResNet(nn.Module):
def __init__(self, num_labels, input_channels=3, sigmoid=True):
super(MultiLabelResNet, self).__init__()
self.model = models.resnet34(pretrained=False)
self.sigmoid = sigmoid

if input_channels != 3:
self.model.conv1 = nn.Conv2d(
input_channels, 64, kernel_size=7, stride=2, padding=3, bias=False
)

num_ftrs = self.model.fc.in_features

self.model.fc = nn.Linear(num_ftrs, num_labels)

def forward(self, x):
x = self.model(x)
if self.sigmoid:
x = torch.sigmoid(x)
return x


class CombinedModel(nn.Module):
def __init__(
self, segment_model: nn.Module, predict_model: nn.Module, cat_layers: int = None
):
super(CombinedModel, self).__init__()
self.segment_model = segment_model
self.predict_model = predict_model
self.cat_layers = cat_layers
self.freeze_seg = False

def forward(self, x: torch.Tensor):
seg_masks = self.segment_model(x)
seg_masks_ = seg_masks.detach()
if self.cat_layers:
seg_masks_ = seg_masks_[:, 0 : self.cat_layers]
x = torch.cat((x, seg_masks_), dim=1)
else:
x = torch.cat((x, seg_masks_), dim=1)
logic_outputs = self.predict_model(x)
return seg_masks, logic_outputs

def freeze_segment_model(self):
self.segment_model.eval()

def unfreeze_segment_model(self):
self.segment_model.train()


class SegmentPredictor(nn.Module):
def __init__(self, num_masks, num_labels, in_channels=3, sigmoid=True):
super(SegmentPredictor, self).__init__()
Expand Down Expand Up @@ -445,32 +319,6 @@ def predict(self, rgb_image: np.ndarray) -> ImageWithMasksAndAttributes:
return image_obj


def load_face_classifier_model():
cat_layers = CelebAMaskHQCategoriesAndAttributes.merged_categories.keys().__len__()
segment_model = UNetWithResnetEncoder(num_classes=cat_layers)
predictions = (
len(CelebAMaskHQCategoriesAndAttributes.attributes)
- len(CelebAMaskHQCategoriesAndAttributes.avoided_attributes)
+ len(CelebAMaskHQCategoriesAndAttributes.mask_labels)
)
predict_model = MultiLabelResNet(
num_labels=predictions, input_channels=cat_layers + 3
)
model = CombinedModel(segment_model, predict_model, cat_layers=cat_layers)
model.eval()

r = rospkg.RosPack()
model, _, _, _ = load_torch_model(
model,
None,
path=path.join(
r.get_path("lasr_vision_feature_extraction"), "models", "face_model.pth"
),
cpu_only=True,
)
return model


def load_cloth_classifier_model():
num_classes = len(DeepFashion2GeneralizedCategoriesAndAttributes.attributes)
model = SegmentPredictorBbox(
Expand Down Expand Up @@ -597,7 +445,12 @@ def predict_frame(
rst_person["hair_shape"] = "long hair"

result = {
**rst_person,
"has_hair": 0.0,
"hair_colour": "Not used.",
"hair_shape": "Not used.",
"facial_hair": 0.0,
"glasses": 0.0,
"hat": 0.0,
**rst_cloth,
}

Expand Down
Loading
Loading