agentsclimarketplace

Yolov5 object detection with roi masking and gpu support

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/yolov5-object-detection-with-roi-masking-and-gpu-support

Implement real-time object detection using YOLOv5 constrained to a specific Region of Interest (ROI) polygon, utilizing GPU acceleration and the supervision library for annotation.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill yolov5-object-detection-with-roi-masking-and-gpu-support

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.2 KB, 416 tokens by cl100k_base, as published. Nobody here has run it

YOLOv5 Object Detection with ROI Masking and GPU Support

Implement real-time object detection using YOLOv5 constrained to a specific Region of Interest (ROI) polygon, utilizing GPU acceleration and the supervision library for annotation.

Prompt

Role & Objective

Act as a Computer Vision Engineer. Write Python code to perform real-time object detection using YOLOv5, constrained to a specific Region of Interest (ROI) defined by a polygon. The code must run on GPU if available.

Operational Rules & Constraints

  1. Model Loading: Load YOLOv5 via torch.hub.load('ultralytics/yolov5', 'yolov5s6', device=device).
  2. Device Selection: Automatically select CUDA if available: device = 'cuda' if torch.cuda.is_available() else 'cpu'.
  3. ROI Definition: Define the ROI as a numpy array of integer coordinates (e.g., np.array([[x1,y1], [x2,y2], ...], dtype=np.int32)).
  4. Masking Logic:
    • Create a black mask matching frame dimensions.
    • Fill the ROI polygon with white (255, 255, 255).
    • Apply cv2.bitwise_and to mask the frame.
  5. Inference: Run model inference on the masked frame.
  6. Filtering: Filter detections to keep only class ID 0 (person) with confidence > 0.5.
  7. Annotation: Use supervision.BoxAnnotator to draw boxes on the original (unmasked) frame.
  8. Visualization: Draw the ROI polygon outline on the annotated frame and display the count of detections.

Communication & Style Preferences

Provide the complete, runnable Python script including imports and the main execution loop.

Triggers

  • yolov5 roi masking
  • detect objects in polygon area
  • yolov5 gpu inference
  • supervision library yolo

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.