Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/ci-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
model: [yolov5n]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v6
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
torch: "1.8.0" # min torch version CI https://pypi.org/project/torchvision/
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merge-main-into-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
- uses: actions/setup-python@v6
with:
python-version: "3.x"
cache: "pip"
Expand Down
13 changes: 8 additions & 5 deletions testcode.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import time
import cv2
import torch
import numpy as np
import sys

import cv2
import numpy as np
import torch
from unitree_sdk2py.core.channel import ChannelFactoryInitialize
from unitree_sdk2py.go2.video.video_client import VideoClient


# ----------------------------
# Preprocess and detect
# ----------------------------
Expand All @@ -17,6 +17,7 @@ def preprocess(frame):
img = np.ascontiguousarray(img) / 255.0
return torch.tensor(img).float().unsqueeze(0)


def detect_person(model, frame, conf_thresh=0.5):
img = preprocess(frame)
with torch.no_grad():
Expand All @@ -28,6 +29,7 @@ def detect_person(model, frame, conf_thresh=0.5):
boxes.append((x1, y1, x2 - x1, y2 - y1))
return boxes


# ----------------------------
# Main Camera Loop
# ----------------------------
Expand All @@ -50,7 +52,7 @@ def camera_loop(model):

boxes = detect_person(model, frame)

for (x, y, w, h) in boxes:
for x, y, w, h in boxes:
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
cv2.putText(frame, "Person", (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2)

Expand All @@ -61,6 +63,7 @@ def camera_loop(model):

cv2.destroyAllWindows()


# ----------------------------
# Main
# ----------------------------
Expand Down
6 changes: 3 additions & 3 deletions utils/triton.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, url: str):
self.model_name = model_repository.models[0].name
self.metadata = self.client.get_model_metadata(self.model_name, as_json=True)

def create_input_placeholders() -> typing.List[InferInput]:
def create_input_placeholders() -> list[InferInput]:
return [
InferInput(i["name"], [int(s) for s in i["shape"]], i["datatype"]) for i in self.metadata["inputs"]
]
Expand All @@ -42,7 +42,7 @@ def create_input_placeholders() -> typing.List[InferInput]:
self.model_name = model_repository[0]["name"]
self.metadata = self.client.get_model_metadata(self.model_name)

def create_input_placeholders() -> typing.List[InferInput]:
def create_input_placeholders() -> list[InferInput]:
return [
InferInput(i["name"], [int(s) for s in i["shape"]], i["datatype"]) for i in self.metadata["inputs"]
]
Expand All @@ -54,7 +54,7 @@ def runtime(self):
"""Returns the model runtime."""
return self.metadata.get("backend", self.metadata.get("platform"))

def __call__(self, *args, **kwargs) -> typing.Union[torch.Tensor, typing.Tuple[torch.Tensor, ...]]:
def __call__(self, *args, **kwargs) -> typing.Union[torch.Tensor, tuple[torch.Tensor, ...]]:
"""
Invokes the model.

Expand Down