Skip to content

Commit

Permalink
Merge branch 'main' into feat/fix_details
Browse files Browse the repository at this point in the history
  • Loading branch information
klemen1999 committed Jan 30, 2025
2 parents d4451a0 + 6cce15b commit f13d9bb
Show file tree
Hide file tree
Showing 8 changed files with 477 additions and 17 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ on:
description: 'Branch to run the tests on. Default: main'
required: true
default: 'main'
testbed:
description: 'Testbed to run the tests on. Available: oak4-pro, oak4-s'
required: true
default: 'oak4-pro'
depthai-version:
description: 'Version of depthai to install. Default: alpha11'
required: true
Expand Down Expand Up @@ -53,7 +49,7 @@ jobs:
run: |
export RESERVATION_NAME="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}#${{ matrix.python-version}}"
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
hil --testbed ${{ github.event.inputs.testbed }} --wait --reservation-name $RESERVATION_NAME --commands "cd /home/hil/depthai-nodes" "git checkout main" "git pull" "git checkout ${{ github.event.inputs.branch }}" "git pull" "source venv/bin/activate" "pip install --extra-index-url ${{secrets.LUXONIS_EXTRA_INDEX_URL}} depthai==${{ github.event.inputs.depthai-version }}" "cd tests/end_to_end" "source <(python setup_camera_ips.py)" "export HUBAI_TEAM_SLUG=${{ secrets.HUBAI_TEAM_SLUG }}" "export HUBAI_API_KEY=${{ secrets.HUBAI_API_KEY }}" "python main.py ${{ github.event.inputs.additional-parameter }}" "deactivate"
hil --capabilities "depthai-core-hil" --wait --reservation-name $RESERVATION_NAME --before-docker-pull "echo ${{secrets.GHCR_PAT}} | docker login ghcr.io -u ${{secrets.GHCR_USER}} --password-stdin" --docker-image ghcr.io/luxonis/depthai-nodes-testing --docker-run-args "--env LUXONIS_EXTRA_INDEX_URL=${{secrets.LUXONIS_EXTRA_INDEX_URL}} --env DEPTHAI_VERSION=${{ github.event.inputs.depthai-version }} --env HUBAI_TEAM_SLUG=${{ secrets.HUBAI_TEAM_SLUG }} --env HUBAI_API_KEY=${{ secrets.HUBAI_API_KEY }} --env BRANCH=${{ github.event.inputs.branch }} --env FLAGS=\"${{ github.event.inputs.additional-parameter }}\""
else
hil --testbed-list oak4-pro oak4-s --wait --reservation-name $RESERVATION_NAME --commands "cd /home/hil/depthai-nodes" "git checkout main" "git pull" "source venv/bin/activate" "pip install --extra-index-url ${{secrets.LUXONIS_EXTRA_INDEX_URL}} depthai==3.0.0a11" "cd tests/end_to_end" "source <(python setup_camera_ips.py)" "export HUBAI_TEAM_SLUG=${{ secrets.HUBAI_TEAM_SLUG }}" "export HUBAI_API_KEY=${{ secrets.HUBAI_API_KEY }}" "python main.py -all" "deactivate"
hil --capabilities "depthai-core-hil" --wait --reservation-name $RESERVATION_NAME --before-docker-pull "echo ${{secrets.GHCR_PAT}} | docker login ghcr.io -u ${{secrets.GHCR_USER}} --password-stdin" --docker-image ghcr.io/luxonis/depthai-nodes-testing --docker-run-args "--env LUXONIS_EXTRA_INDEX_URL=${{secrets.LUXONIS_EXTRA_INDEX_URL}} --env DEPTHAI_VERSION=\"3.0.0a11\" --env HUBAI_TEAM_SLUG=${{ secrets.HUBAI_TEAM_SLUG }} --env HUBAI_API_KEY=${{ secrets.HUBAI_API_KEY }} --env BRANCH=\"main\" --env FLAGS=\"-all\""
fi
8 changes: 2 additions & 6 deletions .github/workflows/integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ on:
description: 'Branch to run the tests on. Default: main'
required: true
default: 'main'
testbed:
description: 'Testbed to run the tests on. Available: oak4-pro, oak4-s'
required: true
default: 'oak4-s'
depthai-version:
description: 'Version of depthai to install. Default: alpha11'
required: true
Expand Down Expand Up @@ -53,7 +49,7 @@ jobs:
run: |
export RESERVATION_NAME="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}#${{ matrix.python-version}}"
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
hil --testbed ${{ github.event.inputs.testbed }} --wait --reservation-name $RESERVATION_NAME --commands "cd /home/hil/depthai-nodes" "git checkout main" "git pull" "git checkout ${{ github.event.inputs.branch }}" "git pull" "source venv/bin/activate" "pip install --extra-index-url ${{secrets.LUXONIS_EXTRA_INDEX_URL}} depthai==${{ github.event.inputs.depthai-version }}" "cd tests/integration_tests" "export B2_APPLICATION_KEY=${{ secrets.B2_APPLICATION_KEY }}" "export B2_APPLICATION_KEY_ID=${{ secrets.B2_APPLICATION_KEY_ID }}" "python main.py ${{ github.event.inputs.additional-parameter }}" "deactivate"
hil --capabilities "depthai-core-hil" --wait --reservation-name $RESERVATION_NAME --before-docker-pull "echo ${{secrets.GHCR_PAT}} | docker login ghcr.io -u ${{secrets.GHCR_USER}} --password-stdin" --docker-image ghcr.io/luxonis/depthai-nodes-integration-testing --docker-run-args "--env LUXONIS_EXTRA_INDEX_URL=${{secrets.LUXONIS_EXTRA_INDEX_URL}} --env DEPTHAI_VERSION=${{ github.event.inputs.depthai-version }} --env B2_APPLICATION_KEY=${{ secrets.B2_APPLICATION_KEY }} --env B2_APPLICATION_KEY_ID=${{ secrets.B2_APPLICATION_KEY_ID }} --env BRANCH=${{ github.event.inputs.branch }} --env FLAGS=\"${{ github.event.inputs.additional-parameter }}\""
else
hil --testbed-list oak4-s oak4-pro --wait --reservation-name $RESERVATION_NAME --commands "cd /home/hil/depthai-nodes" "git checkout main" "git pull" "git checkout ${{ github.head_ref }}" "git pull" "source venv/bin/activate" "pip install --extra-index-url ${{secrets.LUXONIS_EXTRA_INDEX_URL}} depthai==3.0.0a11" "cd tests/integration_tests" "export B2_APPLICATION_KEY=${{ secrets.B2_APPLICATION_KEY }}" "export B2_APPLICATION_KEY_ID=${{ secrets.B2_APPLICATION_KEY_ID }}" "python main.py -all --download" "deactivate"
hil --capabilities "depthai-core-hil" --wait --reservation-name $RESERVATION_NAME --before-docker-pull "echo ${{secrets.GHCR_PAT}} | docker login ghcr.io -u ${{secrets.GHCR_USER}} --password-stdin" --docker-image ghcr.io/luxonis/depthai-nodes-integration-testing --docker-run-args "--env LUXONIS_EXTRA_INDEX_URL=${{secrets.LUXONIS_EXTRA_INDEX_URL}} --env DEPTHAI_VERSION=\"3.0.0a11\" --env B2_APPLICATION_KEY=${{ secrets.B2_APPLICATION_KEY }} --env B2_APPLICATION_KEY_ID=${{ secrets.B2_APPLICATION_KEY_ID }} --env BRANCH=${{ github.head_ref }} --env FLAGS=\"-all --download\""
fi
3 changes: 3 additions & 0 deletions depthai_nodes/nodes/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .detection_config_generator import generate_script_content

__all__ = ["generate_script_content"]
81 changes: 81 additions & 0 deletions depthai_nodes/nodes/utils/detection_config_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
from typing import List, Optional


def generate_script_content(
platform: str,
resize_width: int,
resize_height: int,
padding: float = 0,
valid_labels: Optional[List[int]] = None,
) -> str:
"""The function generates the script content for the dai.Script node.
It is used to crop and resize the input image based on the detected object. It can
also work with padding around the detection bounding box and filter detections by
labels.
@param platform: Target platform for the script. Supported values: 'rvc2', 'rvc4'
@type platform: str
@param resize_width: Target width for the resized image
@type resize_width: int
@param resize_height: Target height for the resized image
@type resize_height: int
@param padding: Additional padding around the detection in normalized coordinates
(0-1)
@type padding: float
@param valid_labels: List of valid label indices to filter detections. If None, all
detections are processed
@type valid_labels: Optional[List[int]]
@return: Generated script content as a string
@rtype: str
"""

if platform.lower() == "rvc2":
cfg_content = f"""
cfg = ImageManipConfig()
cfg.setCropRect(det.xmin - {padding}, det.ymin - {padding}, det.xmax + {padding}, det.ymax + {padding})
cfg.setResize({resize_width}, {resize_height})
cfg.setKeepAspectRatio(False)
"""
elif platform.lower() == "rvc4":
cfg_content = f"""
cfg = ImageManipConfigV2()
rect = RotatedRect()
rect.center.x = (det.xmin + det.xmax) / 2
rect.center.y = (det.ymin + det.ymax) / 2
rect.size.width = det.xmax - det.xmin
rect.size.height = det.ymax - det.ymin
rect.size.width = rect.size.width + {padding} * 2
rect.size.height = rect.size.height + {padding} * 2
rect.angle = 0
cfg.addCropRotatedRect(rect=rect, normalizedCoords=True)
cfg.setOutputSize({resize_width}, {resize_height})
"""
else:
raise ValueError("Unsupported platform")
validate_label = (
f"""
if det.label not in {valid_labels}:
continue
"""
if valid_labels
else ""
)
return f"""
try:
while True:
frame = node.inputs['preview'].get()
dets = node.inputs['det_in'].get()
for i, det in enumerate(dets.detections):
{validate_label.strip()}
{cfg_content.strip()}
node.outputs['manip_cfg'].send(cfg)
node.outputs['manip_img'].send(frame)
except Exception as e:
node.warn(str(e))
"""
29 changes: 29 additions & 0 deletions tests/end_to_end/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use the official Python 3.8 image from the Docker Hub
FROM python:3.8-slim

# Set the working directory
WORKDIR /app

# Install git
RUN apt-get update && apt-get install -y git

RUN apt install libgl1-mesa-glx -y
RUN apt-get install ffmpeg libsm6 libxext6 -y

# Clone the depthai-nodes repository
RUN git clone https://github.com/luxonis/depthai-nodes.git

# Set the working directory to the cloned repository
WORKDIR /app/depthai-nodes

# Install the depthai-nodes package
RUN pip install -e .

# Install the development requirements
RUN pip install -r requirements-dev.txt

# Set the working directory to the tests directory
WORKDIR /app/depthai-nodes/tests/end_to_end

# Run the setup script and the tests
ENTRYPOINT ["bash", "-c", "git checkout main && git pull && git checkout $BRANCH && git pull && pip install --extra-index-url $LUXONIS_EXTRA_INDEX_URL depthai==$DEPTHAI_VERSION && source <(python setup_camera_ips.py) && python main.py $FLAGS"]
29 changes: 29 additions & 0 deletions tests/integration_tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use the official Python 3.8 image from the Docker Hub
FROM python:3.8-slim

# Set the working directory
WORKDIR /app

# Install git
RUN apt-get update && apt-get install -y git

RUN apt install libgl1-mesa-glx -y
RUN apt-get install ffmpeg libsm6 libxext6 -y

# Clone the depthai-nodes repository
RUN git clone https://github.com/luxonis/depthai-nodes.git

# Set the working directory to the cloned repository
WORKDIR /app/depthai-nodes

# Install the depthai-nodes package
RUN pip install -e .

# Install the development requirements
RUN pip install -r requirements-dev.txt

# Set the working directory to the tests directory
WORKDIR /app/depthai-nodes/tests/integration_tests

# Run the setup script and the tests
ENTRYPOINT ["bash", "-c", "git checkout main && git pull && git checkout $BRANCH && git pull && pip install --extra-index-url $LUXONIS_EXTRA_INDEX_URL depthai==$DEPTHAI_VERSION && python -u main.py $FLAGS"]
10 changes: 5 additions & 5 deletions tests/integration_tests/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
"ClassificationSequenceParser": ["luxonis/paddle-text-recognition:320x48"],
"EmbeddingsParser": ["luxonis/arcface:lfw-112x112"],
"FastSAMParser": ["luxonis/fastsam-s:512x288"],
"HRNetParser": ["luxonis/lite-hrnet:18-coco-256x192"],
"ImageOutputParser": ["luxonis/dncnn3:240x320"],
"HRNetParser": ["luxonis/lite-hrnet:18-coco-192x256"],
"ImageOutputParser": ["luxonis/dncnn3:320x240"],
"KeypointParser": ["luxonis/mediapipe-face-landmarker:192x192"],
"LaneDetectionParser": ["luxonis/ultra-fast-lane-detection:culane-800x288"],
"MapOutputParser": ["luxonis/dm-count:sha-144x256"],
"MapOutputParser": ["luxonis/dm-count:sha-426x240"],
"MPPalmDetectionParser": ["luxonis/mediapipe-palm-detection:192x192"],
"MLSDParser": ["luxonis/m-lsd-tiny:512x512"],
"PPTextDetectionParser": ["luxonis/paddle-text-detection:256x256"],
"SCRFDParser": ["luxonis/scrfd-face-detection:10g-640x640"],
"SegmentationParser": [
"luxonis/mediapipe-selfie-segmentation:144x256",
"luxonis/mediapipe-selfie-segmentation:256x144",
"luxonis/deeplab-v3-plus:256x256",
],
"SuperAnimalParser": ["luxonis/superanimal-landmarker:256x256"],
"YOLOExtendedParser": [
"luxonis/yolov8-instance-segmentation-nano:coco-512x288",
"luxonis/yolov8-nano-pose-estimation:coco-512x288",
],
"YuNetParser": ["luxonis/yunet:new-240x320"],
"YuNetParser": ["luxonis/yunet:320x240"],
"RegressionParser": ["luxonis/gaze-estimation-adas:60x60"],
}
Loading

0 comments on commit f13d9bb

Please sign in to comment.