177 lines
6.7 KiB
Markdown
177 lines
6.7 KiB
Markdown
# YOLO26: 8 Computer Vision Tasks on Images (Jetson Orin Nano)
|
|
|
|
## Task Title
|
|
|
|
Run 8 YOLO26 computer vision tasks on a single input image using Python.
|
|
|
|
## Description
|
|
|
|
One script runs the YOLO26 model family on one image and saves every result into a `results/` folder. Each task loads its own YOLO26 nano model, runs it once on the image and saves an annotated image or files.
|
|
|
|
Tasks in the script:
|
|
|
|
1. Detection: boxes, class names and confidence.
|
|
2. Tracking: runs the tracker on a single image. With only one frame there is no time dimension, so IDs do not persist. Use the video version for real tracking.
|
|
3. Segmentation: pixel-level masks.
|
|
4. Pose estimation: 17 human keypoints and skeleton (needs a person in the image).
|
|
5. Classification: one label for the whole image with probability.
|
|
6. ROI extraction: crops each detected box out of the image and saves each crop.
|
|
7. Depth estimation: native YOLO26 depth model, saved as a colorized depth image plus the raw depth array.
|
|
8. OBB (oriented bounding boxes): rotated boxes (needs aerial or satellite style images).
|
|
|
|
## Hardware and Software
|
|
|
|
- Device: NVIDIA Jetson Orin Nano (JetPack with CUDA and TensorRT)
|
|
- Language: Python 3
|
|
- Libraries: ultralytics, opencv-python, numpy
|
|
- Input: one image such as `test.jpg` in the same folder as the script
|
|
|
|
## Installation
|
|
|
|
```
|
|
pip install -U ultralytics
|
|
```
|
|
|
|
On Jetson, install the JetPack-matched PyTorch and torchvision builds first (see the Jetson guide in the references). Model weights download automatically on first run, so the first run needs internet.
|
|
|
|
## Folder Layout
|
|
|
|
```
|
|
your_folder/
|
|
yolo26_8_tasks_image.py (rename to match your script file name)
|
|
test.jpg (your input image)
|
|
results/ (created automatically)
|
|
```
|
|
|
|
## Command to Run
|
|
|
|
```
|
|
python3 yolo26_8_tasks_image.py
|
|
```
|
|
|
|
To use a different image, change the image path variable at the top of the script.
|
|
|
|
## Models Used
|
|
|
|
- Task 1, 2 and 6: `yolo26n.pt` (detection, COCO 80 classes)
|
|
- Task 3: `yolo26n-seg.pt` (instance segmentation)
|
|
- Task 4: `yolo26n-pose.pt` (17 human keypoints)
|
|
- Task 5: `yolo26n-cls.pt` (ImageNet 1000 classes)
|
|
- Task 7: `yolo26n-depth.pt` (per-pixel metric depth in meters)
|
|
- Task 8: `yolo26n-obb.pt` (DOTA aerial classes)
|
|
|
|
## How It Works
|
|
|
|
1. The script checks that the image exists and loads it.
|
|
2. Each task runs in its own `try/except`, so if one task fails the others still run.
|
|
3. For each task the model is called on the image and `result.plot()` gives the annotated image, which is saved to `results/`.
|
|
4. ROI extraction takes the detection boxes and crops each one from the original image.
|
|
5. Depth estimation reads the per-pixel depth map in meters, applies a color map and saves it as an image. It also saves the raw depth values as a `.npy` file.
|
|
|
|
## Output Files (inside `results/`)
|
|
|
|
These are the expected names. Your script may use slightly different names, so match them to what is in your folder.
|
|
|
|
- `1_detection.jpg` : detection result
|
|
- `2_tracking.jpg` : tracking result (single frame)
|
|
- `3_segmentation.jpg` : segmentation result
|
|
- `4_pose.jpg` : pose result
|
|
- `5_classification.jpg` : classification result with label
|
|
- `6_roi_crops/` : cropped objects, one image per detected box
|
|
- `7_depth.png` : colorized depth map
|
|
- `7_depth.npy` : raw depth values in meters
|
|
- `8_obb.jpg` : OBB result
|
|
|
|
## Sample Output (add your screenshots here)
|
|
|
|
Copy the result images into an `images` folder next to this README and update the names below.
|
|
|
|
Input image:
|
|
|
|

|
|
|
|
Detection:
|
|
|
|

|
|
|
|
Tracking:
|
|
|
|

|
|
|
|
Segmentation:
|
|
|
|

|
|
|
|
Pose estimation:
|
|
|
|

|
|
|
|
Classification:
|
|
|
|

|
|
|
|
ROI crops:
|
|
|
|

|
|
|
|
Depth estimation:
|
|
|
|

|
|
|
|
OBB:
|
|
|
|

|
|
|
|
## Verify the Output
|
|
|
|
- [ ] Each finished task prints `Saved:` with its path.
|
|
- [ ] `results/` contains one output per task.
|
|
- [ ] Detection boxes sit on the right objects with sensible labels.
|
|
- [ ] Segmentation masks follow the object shape.
|
|
- [ ] Pose shows a skeleton on each person (only if the image has a person).
|
|
- [ ] Classification shows one label with a probability.
|
|
- [ ] ROI crops folder has one image per detected object.
|
|
- [ ] Depth image shows near and far areas in clearly different colors.
|
|
- [ ] OBB shows rotated boxes (only for aerial style images).
|
|
|
|
## Notes and Limitations
|
|
|
|
- Tracking on one image cannot keep IDs across frames. It is only useful as a demo of the output format. Use the video script for real tracking.
|
|
- Pose finds human keypoints only. With no person in the image the output has no skeleton.
|
|
- OBB is trained on aerial and satellite classes, so everyday photos usually return no boxes. Test it with aerial images.
|
|
- Classification expects one main subject. If the image has many objects the label is only a rough guess.
|
|
- ROI is not a separate YOLO model. It crops the detected boxes from the original image.
|
|
|
|
## Optional: Faster Inference with TensorRT
|
|
|
|
```
|
|
yolo export model=yolo26n.pt format=engine half=True
|
|
```
|
|
|
|
Then replace `YOLO("yolo26n.pt")` with `YOLO("yolo26n.engine")`.
|
|
|
|
## Troubleshooting
|
|
|
|
- Image not found: put the image in the script folder or fix the path in the script.
|
|
- Empty results for pose or OBB: use an image with a person (pose) or an aerial image (OBB).
|
|
- Out of memory on Jetson: close other apps or run one task at a time.
|
|
- Slow first run: weights download and the model warms up on the first call.
|
|
- Window does not open over SSH: this script saves files, so open the images from the `results/` folder instead.
|
|
|
|
## References
|
|
|
|
- [Ultralytics YOLO26 models](https://docs.ultralytics.com/models/yolo26/)
|
|
- [Object detection task](https://docs.ultralytics.com/tasks/detect/)
|
|
- [Object tracking mode](https://docs.ultralytics.com/modes/track/)
|
|
- [Instance segmentation task](https://docs.ultralytics.com/tasks/segment/)
|
|
- [Pose estimation task](https://docs.ultralytics.com/tasks/pose/)
|
|
- [Image classification task](https://docs.ultralytics.com/tasks/classify/)
|
|
- [Oriented bounding boxes (OBB) task](https://docs.ultralytics.com/tasks/obb/)
|
|
- [Depth estimation task](https://docs.ultralytics.com/tasks/depth/)
|
|
- [Predict mode](https://docs.ultralytics.com/modes/predict/)
|
|
- [Ultralytics on NVIDIA Jetson guide](https://docs.ultralytics.com/guides/nvidia-jetson/)
|
|
- [TensorRT export](https://docs.ultralytics.com/integrations/tensorrt/)
|
|
- [Ultralytics GitHub](https://github.com/ultralytics/ultralytics)
|
|
- [Ultralytics on PyPI](https://pypi.org/project/ultralytics/)
|
|
- [OpenCV image reading and writing](https://docs.opencv.org/4.x/db/deb/tutorial_display_image.html)
|