Skip to content

Commit

Permalink
Convert directory fbcode/surreal to use the Ruff Formatter
Browse files Browse the repository at this point in the history
Summary:
Converts the directory specified to use the Ruff formatter in pyfmt

ruff_dog

If this diff causes merge conflicts when rebasing, please run
`hg status -n -0 --change . -I '**/*.{py,pyi}' | xargs -0 arc pyfmt`
on your diff, and amend any changes before rebasing onto latest.
That should help reduce or eliminate any merge conflicts.

allow-large-files

Reviewed By: zertosh

Differential Revision: D63858542

fbshipit-source-id: 302f3632afaf8b16bc434cd8d8ededc75aa70938
  • Loading branch information
Thomas Polasek authored and facebook-github-bot committed Oct 4, 2024
1 parent 328de2e commit 83d2ea8
Show file tree
Hide file tree
Showing 18 changed files with 7 additions and 45 deletions.
10 changes: 1 addition & 9 deletions hot3d/Hot3DVisualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@


class Hot3DVisualizer:

def __init__(
self,
hot3d_data_provider: Hot3dDataProvider,
hand_type: HandType = HandType.Umetrack,
) -> None:

self._hot3d_data_provider = hot3d_data_provider
# Device calibration and Image stream data
self._device_data_provider = hot3d_data_provider.device_data_provider
Expand Down Expand Up @@ -329,15 +327,13 @@ def log_dynamic_assets(
## Eye Gaze image reprojection
#
if self._hot3d_data_provider.get_device_type() is Headset.Aria:

# We are showing EyeGaze reprojection only on the RGB image stream
if stream_id != StreamId("214-1"):
continue

# Reproject EyeGaze for raw and pinhole images
camera_configurations = [FISHEYE624, LINEAR]
for camera_model in camera_configurations:

eye_gaze_reprojection_data = (
self._device_data_provider.get_eye_gaze_in_camera(
stream_id, timestamp_ns, camera_model=camera_model
Expand Down Expand Up @@ -365,9 +361,7 @@ def log_dynamic_assets(

# Log 3D eye gaze
if aria_eye_gaze_data is not None:
T_device_CPF = (
self._device_data_provider.get_device_calibration().get_transform_device_cpf()
)
T_device_CPF = self._device_data_provider.get_device_calibration().get_transform_device_cpf()
# Compute eye_gaze vector at depth_m (30cm for a proxy 3D vector to display)
gaze_vector_in_cpf = get_eyegaze_point_at_depth(
aria_eye_gaze_data.yaw, aria_eye_gaze_data.pitch, depth_m=0.3
Expand Down Expand Up @@ -431,7 +425,6 @@ def log_hands(
hand_pose_collection = hand_poses_with_dt.pose3d_collection

for hand_pose_data in hand_pose_collection.poses.values():

if hand_pose_data.is_left_hand():
logged_left_hand_data = True
elif hand_pose_data.is_right_hand():
Expand Down Expand Up @@ -510,7 +503,6 @@ def log_object_poses(
object_uid,
object_pose3d,
) in objects_pose3d_collection.poses.items():

object_name = object_library.object_id_to_name_dict[object_uid]
object_name = object_name + "_" + str(object_uid)
object_cad_asset_filepath = ObjectLibrary.get_cad_asset_path(
Expand Down
3 changes: 0 additions & 3 deletions hot3d/clips/vis_clips.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def vis_clip(

# Visualize object contours.
if objects is not None:

masks_vis = None
if len(objects) and (vis_amodal_masks or vis_modal_masks):
masks_vis = np.zeros_like(image)
Expand Down Expand Up @@ -170,7 +169,6 @@ def vis_clip(

# Visualize hand contours.
for hand_mesh in hand_meshes.values():

# Render the hand model (outputs: rgb, mask, depth).
_, mask, _ = rasterizer.rasterize_mesh(
verts=hand_mesh.vertices,
Expand All @@ -194,7 +192,6 @@ def vis_clip(


def main() -> None:

parser = argparse.ArgumentParser()
parser.add_argument(
"--clips_dir",
Expand Down
1 change: 0 additions & 1 deletion hot3d/data_downloader/dataset_downloader_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def __init__(
sequences: Optional[List[str]] = None,
overwrite: bool = False,
):

# add slam summary if any slam data is requested
if "mps_slam_summary" not in data_types:
if (
Expand Down
1 change: 0 additions & 1 deletion hot3d/data_loaders/AriaDataProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@


class AriaDataProvider:

def __init__(
self, vrs_filepath: str, mps_folder_path: Optional[str] = None
) -> None:
Expand Down
10 changes: 3 additions & 7 deletions hot3d/data_loaders/HandBox2dDataProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ class HandBox2dCollectionWithDt:


class HandBox2dProvider:

def __init__(
self, box2d_trajectory_collection: HandBox2dTrajectoryCollection
) -> None:

self._box2d_trajectory_collection = box2d_trajectory_collection

self._sorted_timestamp_ns_list: Dict[str, List[int]] = {}
Expand Down Expand Up @@ -123,7 +121,6 @@ def get_bbox_at_timestamp(


def parse_box2ds_from_csv_reader(csv_reader) -> HandBox2dTrajectoryCollection:

box2d_trajectory_collection: HandBox2dTrajectoryCollection = {}

# Read the header row
Expand All @@ -134,7 +131,6 @@ def parse_box2ds_from_csv_reader(csv_reader) -> HandBox2dTrajectoryCollection:

# Read the rest of the rows in the CSV file
for row in csv_reader:

stream_id = str(StreamId(row[header.index("stream_id")]))
timestamp_ns = int(row[header.index("timestamp[ns]")])
hand_index = int(row[header.index("hand_index")])
Expand Down Expand Up @@ -165,9 +161,9 @@ def parse_box2ds_from_csv_reader(csv_reader) -> HandBox2dTrajectoryCollection:
timestamp_ns=timestamp_ns, box2ds={}
)

box2d_trajectory_collection[stream_id][timestamp_ns].box2ds[
hand_index
] = object_box2d
box2d_trajectory_collection[stream_id][timestamp_ns].box2ds[hand_index] = (
object_box2d
)
return box2d_trajectory_collection


Expand Down
2 changes: 0 additions & 2 deletions hot3d/data_loaders/HandDataProviderBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ class HandPose3dCollectionWithDt:


class HandDataProviderBase:

def __init__(
self,
) -> None:

self._hand_poses = None
self._sorted_timestamp_ns_list: List[int]

Expand Down
2 changes: 0 additions & 2 deletions hot3d/data_loaders/ManoHandDataProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@


class MANOHandDataProvider(HandDataProviderBase):

def __init__(
self,
hand_pose_trajectory_filepath: str,
mano_layer: MANOHandModel,
) -> None:

super().__init__()
super()._init_hand_poses(hand_pose_trajectory_filepath)

Expand Down
10 changes: 3 additions & 7 deletions hot3d/data_loaders/ObjectBox2dDataProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ class ObjectBox2dCollectionWithDt:


class ObjectBox2dProvider:

def __init__(
self, box2d_trajectory_collection: ObjectBox2dTrajectoryCollection
) -> None:

self._box2d_trajectory_collection = box2d_trajectory_collection

self._sorted_timestamp_ns_list: Dict[str, List[int]] = {}
Expand Down Expand Up @@ -150,7 +148,6 @@ def get_bbox_at_timestamp(


def parse_box2ds_from_csv_reader(csv_reader) -> ObjectBox2dTrajectoryCollection:

box2d_trajectory_collection: ObjectBox2dTrajectoryCollection = {}

# Read the header row
Expand All @@ -161,7 +158,6 @@ def parse_box2ds_from_csv_reader(csv_reader) -> ObjectBox2dTrajectoryCollection:

# Read the rest of the rows in the CSV file
for row in csv_reader:

stream_id = str(StreamId(row[header.index("stream_id")]))
timestamp_ns = int(row[header.index("timestamp[ns]")])
object_uid = str(row[header.index("object_uid")])
Expand Down Expand Up @@ -192,9 +188,9 @@ def parse_box2ds_from_csv_reader(csv_reader) -> ObjectBox2dTrajectoryCollection:
ObjectBox2dCollection(timestamp_ns=timestamp_ns, box2ds={})
)

box2d_trajectory_collection[stream_id][timestamp_ns].box2ds[
object_uid
] = object_box2d
box2d_trajectory_collection[stream_id][timestamp_ns].box2ds[object_uid] = (
object_box2d
)
return box2d_trajectory_collection


Expand Down
1 change: 0 additions & 1 deletion hot3d/data_loaders/PathProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def is_valid(self) -> bool:
class Hot3dDataPathProvider(object):
@staticmethod
def fromRecordingFolder(recording_instance_folderpath) -> SequenceDatasetPathsBase:

metadata_filepath = os.path.join(recording_instance_folderpath, "metadata.json")
metadata_json = load_json(metadata_filepath)
headset = Headset[metadata_json["headset"]]
Expand Down
1 change: 0 additions & 1 deletion hot3d/data_loaders/QuestDataProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@


class QuestDataProvider:

def __init__(self, vrs_filepath: str, device_calibration_filepath: str) -> None:
self._vrs_reader = SyncVRSReader(vrs_filepath)
# Configure Image conversion
Expand Down
2 changes: 0 additions & 2 deletions hot3d/data_loaders/UmeTrackHandDataProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ def load_hand_model_from_file(filename: str) -> Optional[UmeTrackHandModelData]:


class UmeTrackHandDataProvider(HandDataProviderBase):

def __init__(
self, hand_pose_trajectory_filepath: str, hand_profile_filepath: str
) -> None:

super().__init__()
super()._init_hand_poses(hand_pose_trajectory_filepath)

Expand Down
1 change: 0 additions & 1 deletion hot3d/data_loaders/loader_masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ def combine_timestamped_mask_data(
mask_list: List[TimestampedMask],
operator: str = "and", # i.e 'and' or 'or'
) -> TimestampedMask:

if len(mask_list) > 0:
if not all(len(d) == len(mask_list[0]) for d in mask_list):
raise ValueError("Mask data must have the same length")
Expand Down
1 change: 0 additions & 1 deletion hot3d/data_loaders/loader_object_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def asset_folder_name(self) -> str:
return self._asset_folder

def _get_object_id_name_mappings(self, object_info_json):

object_id_to_name_dict = {
k: v["instance_name"]
for k, v in object_info_json.items()
Expand Down
2 changes: 0 additions & 2 deletions hot3d/data_loaders/tests/test_AriaDataProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@


try:

data_path = Path(str(importlib.resources.files(__package__).joinpath("test_data/")))

except ImportError:

data_path = Path(__file__).parent

sequence_path = data_path / "data_sample/Aria/P0003_c701bd11"
Expand Down
1 change: 0 additions & 1 deletion hot3d/data_loaders/tests/test_HandBox2dDataProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@


try:

data_path = Path(
importlib.resources.files(__package__).joinpath(
"test_data/",
Expand Down
1 change: 0 additions & 1 deletion hot3d/data_loaders/tests/test_ObjectBox2dDataProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@


try:

data_path = Path(
importlib.resources.files(__package__).joinpath(
"test_data/",
Expand Down
1 change: 0 additions & 1 deletion hot3d/data_loaders/tests/test_frameset.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def setUp(self) -> None:
super().setUp()

def test_compute_framesets(self) -> None:

stream_timestamps = {
"s0": sorted([100, 200, 300, 400, 500, 600, 702]),
"s1": sorted([103, 202, 298, 400, 450, 604, 710]),
Expand Down
2 changes: 0 additions & 2 deletions hot3d/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def execute_rerun(
fail_on_missing_data: bool,
hand_type: str,
):

if not os.path.exists(sequence_folder):
raise RuntimeError(f"Sequence folder {sequence_folder} does not exist")
if not os.path.exists(object_library_folder):
Expand Down Expand Up @@ -140,7 +139,6 @@ def execute_rerun(
#
# Loop over the timestamps of the sequence and visualize corresponding data
for timestamp in tqdm(timestamps[timestamps_slice]):

rr.set_time_nanos("synchronization_time", int(timestamp))
rr.set_time_sequence("timestamp", timestamp)

Expand Down

0 comments on commit 83d2ea8

Please sign in to comment.