diff --git a/docs/en/guides/index.md b/docs/en/guides/index.md index 39aead68..ddc36248 100644 --- a/docs/en/guides/index.md +++ b/docs/en/guides/index.md @@ -45,25 +45,6 @@ Here's a compilation of in-depth guides to help you master different aspects of - [Steps of a Computer Vision Project ](steps-of-a-cv-project.md) ๐Ÿš€ NEW: Learn about the key steps involved in a computer vision project, including defining goals, selecting models, preparing data, and evaluating results. - [Defining A Computer Vision Project's Goals](defining-project-goals.md) ๐Ÿš€ NEW: Walk through how to effectively define clear and measurable goals for your computer vision project. Learn the importance of a well-defined problem statement and how it creates a roadmap for your project. -## Real-World Projects - -![Ultralytics Solutions Thumbnail](https://github.com/RizwanMunawar/RizwanMunawar/assets/62513924/44c8b148-7a9d-43e4-b7bf-272a7ac4e636) - -- [Object Counting](object-counting.md) ๐Ÿš€ NEW: Explore the process of real-time object counting with Ultralytics YOLOv8 and acquire the knowledge to effectively count objects in a live video stream. -- [Object Cropping](object-cropping.md) ๐Ÿš€ NEW: Explore object cropping using YOLOv8 for precise extraction of objects from images and videos. -- [Object Blurring](object-blurring.md) ๐Ÿš€ NEW: Apply object blurring with YOLOv8 for privacy protection in image and video processing. -- [Workouts Monitoring](workouts-monitoring.md) ๐Ÿš€ NEW: Discover the comprehensive approach to monitoring workouts with Ultralytics YOLOv8. Acquire the skills and insights necessary to effectively use YOLOv8 for tracking and analyzing various aspects of fitness routines in real time. -- [Objects Counting in Regions](region-counting.md) ๐Ÿš€ NEW: Explore counting objects in specific regions with Ultralytics YOLOv8 for precise and efficient object detection in varied areas. -- [Security Alarm System](security-alarm-system.md) ๐Ÿš€ NEW: Discover the process of creating a security alarm system with Ultralytics YOLOv8. This system triggers alerts upon detecting new objects in the frame. Subsequently, you can customize the code to align with your specific use case. -- [Heatmaps](heatmaps.md) ๐Ÿš€ NEW: Elevate your understanding of data with our Detection Heatmaps! These intuitive visual tools use vibrant color gradients to vividly illustrate the intensity of data values across a matrix. Essential in computer vision, heatmaps are skillfully designed to highlight areas of interest, providing an immediate, impactful way to interpret spatial information. -- [Instance Segmentation with Object Tracking](instance-segmentation-and-tracking.md) ๐Ÿš€ NEW: Explore our feature on [Object Segmentation](../tasks/segment.md) in Bounding Boxes Shape, providing a visual representation of precise object boundaries for enhanced understanding and analysis. -- [VisionEye View Objects Mapping](vision-eye.md) ๐Ÿš€ NEW: This feature aim computers to discern and focus on specific objects, much like the way the human eye observes details from a particular viewpoint. -- [Speed Estimation](speed-estimation.md) ๐Ÿš€ NEW: Speed estimation in computer vision relies on analyzing object motion through techniques like [object tracking](../modes/track.md), crucial for applications like autonomous vehicles and traffic monitoring. -- [Distance Calculation](distance-calculation.md) ๐Ÿš€ NEW: Distance calculation, which involves measuring the separation between two objects within a defined space, is a crucial aspect. In the context of Ultralytics YOLOv8, the method employed for this involves using the bounding box centroid to determine the distance associated with user-highlighted bounding boxes. -- [Queue Management](queue-management.md) ๐Ÿš€ NEW: Queue management is the practice of efficiently controlling and directing the flow of people or tasks, often through strategic planning and technology implementation, to minimize wait times and improve overall productivity. -- [Parking Management](parking-management.md) ๐Ÿš€ NEW: Parking management involves efficiently organizing and directing the flow of vehicles in parking areas, often through strategic planning and technology integration, to optimize space utilization and enhance user experience. -- [Analytics](analytics.md) ๐Ÿ“Š NEW: Analytics involves the systematic computational analysis of data or statistics. It is used for discovering, interpreting, and communicating significant patterns in data, and for applying data patterns towards effective decision-making. Analytics can be descriptive, predictive, or prescriptive in nature, and it is integral to data-driven strategies in various industries. - ## Contribute to Our Guides We welcome contributions from the community! If you've mastered a particular aspect of Ultralytics YOLO that's not yet covered in our guides, we encourage you to share your expertise. Writing a guide is a great way to give back to the community and help us make our documentation more comprehensive and user-friendly. diff --git a/docs/en/hub/index.md b/docs/en/hub/index.md index 8ebcc38f..935ac754 100644 --- a/docs/en/hub/index.md +++ b/docs/en/hub/index.md @@ -6,11 +6,32 @@ keywords: Ultralytics HUB, YOLOv5, YOLOv8, model training, AI platform, object d # Ultralytics HUB - - Ultralytics HUB preview image - -
+ +ไธญๆ–‡ | +ํ•œ๊ตญ์–ด | +ๆ—ฅๆœฌ่ชž | +ะ ัƒััะบะธะน | +Deutsch | +Franรงais | +Espaรฑol | +Portuguรชs | +Tรผrkรงe | +Tiแบฟng Viแป‡t | +เคนเคฟเคจเฅเคฆเฅ€ | +ุงู„ุนุฑุจูŠุฉ +
+
+ +CI CPU Open In Colab Discord +
+ +๐Ÿ‘‹ Hello from the [Ultralytics](https://ultralytics.com/) Team! We've been working hard these last few months to launch [Ultralytics HUB](https://bit.ly/ultralytics_hub), a new web tool for training and deploying all your YOLOv5 and YOLOv8 ๐Ÿš€ models from one spot! + +We hope that the resources here will help you get the most out of HUB. Please browse the HUB Docs for details, raise an issue on GitHub for support, and join our Discord community for questions and discussions! + +
+
Ultralytics GitHub space Ultralytics LinkedIn @@ -24,17 +45,8 @@ keywords: Ultralytics HUB, YOLOv5, YOLOv8, model training, AI platform, object d Ultralytics Instagram space Ultralytics Discord -
-
- - CI - - Open In Colab
-๐Ÿ‘‹ Hello from the [Ultralytics](https://ultralytics.com/) Team! - -We've been working hard over the past few months to launch [Ultralytics HUB](https://bit.ly/ultralytics_hub), a new platform for training, monitoring, and deploying all your YOLOv5 and YOLOv8 ๐Ÿš€ models from one spot! ## Introduction diff --git a/docs/en/hub/inference-api.md b/docs/en/hub/inference-api.md index 4e9e286f..1b0ace5f 100644 --- a/docs/en/hub/inference-api.md +++ b/docs/en/hub/inference-api.md @@ -69,13 +69,13 @@ curl -X POST "https://api.ultralytics.com/v1/predict/MODEL_ID" \ See the table below for a full list of available inference arguments. -| Argument | Default | Type | Description | -|--------------|---------|---------|----------------------------------------| -| `image` | | `image` | image file | -| `url` | | `str` | URL of the image if not passing a file | -| `size` | `640` | `int` | valid range `32` - `1280` pixels | -| `confidence` | `0.25` | `float` | valid range `0.01` - `1.0` | -| `iou` | `0.45` | `float` | valid range `0.0` - `0.95` | +| Argument | Default | Type | Description | +|--------------|---------|---------|----------------------------------------------------------------------| +| `image` | | `image` | Image file to be used for inference. | +| `url` | | `str` | URL of the image if not passing a file. | +| `size` | `640` | `int` | Size of the input image, valid range is `32` - `1280` pixels. | +| `confidence` | `0.25` | `float` | Confidence threshold for predictions, valid range `0.01` - `1.0`. | +| `iou` | `0.45` | `float` | Intersection over Union (IoU) threshold, valid range `0.0` - `0.95`. | ## Response diff --git a/docs/en/solutions/index.md b/docs/en/solutions/index.md new file mode 100644 index 00000000..00f043f2 --- /dev/null +++ b/docs/en/solutions/index.md @@ -0,0 +1,38 @@ +--- +comments: true +description: Discover real-world applications and solutions using Ultralytics' YOLO models. Learn how to implement object counting, cropping, blurring, workout monitoring, security systems, and more with YOLOv8. +keywords: Ultralytics, YOLO, Object Detection, Real-World Projects, Object Counting, Object Cropping, Object Blurring, Workout Monitoring, Security Systems, Heatmaps, Instance Segmentation, Object Tracking, VisionEye, Speed Estimation, Distance Calculation, Queue Management, Parking Management, Analytics +--- + +# Ultralytics Solutions: Harness YOLOv8 to Solve Real-World Problems + +Ultralytics Solutions provide cutting-edge applications of YOLO models, offering real-world solutions like object counting, blurring, and security systems, enhancing efficiency and accuracy in diverse industries. Discover the power of YOLOv8 for practical, impactful implementations. + +![Ultralytics Solutions Thumbnail](https://github.com/RizwanMunawar/RizwanMunawar/assets/62513924/44c8b148-7a9d-43e4-b7bf-272a7ac4e636) + +## Solutions + +Here's our curated list of Ultralytics solutions that can be used to create awesome computer vision projects. + +- [Object Counting](../guides/object-counting.md) ๐Ÿš€ NEW: Learn to perform real-time object counting with YOLOv8. Gain the expertise to accurately count objects in live video streams. +- [Object Cropping](../guides/object-cropping.md) ๐Ÿš€ NEW: Master object cropping with YOLOv8 for precise extraction of objects from images and videos. +- [Object Blurring](../guides/object-blurring.md) ๐Ÿš€ NEW: Apply object blurring using YOLOv8 to protect privacy in image and video processing. +- [Workouts Monitoring](../guides/workouts-monitoring.md) ๐Ÿš€ NEW: Discover how to monitor workouts using YOLOv8. Learn to track and analyze various fitness routines in real time. +- [Objects Counting in Regions](../guides/region-counting.md) ๐Ÿš€ NEW: Count objects in specific regions using YOLOv8 for accurate detection in varied areas. +- [Security Alarm System](../guides/security-alarm-system.md) ๐Ÿš€ NEW: Create a security alarm system with YOLOv8 that triggers alerts upon detecting new objects. Customize the system to fit your specific needs. +- [Heatmaps](../guides/heatmaps.md) ๐Ÿš€ NEW: Utilize detection heatmaps to visualize data intensity across a matrix, providing clear insights in computer vision tasks. +- [Instance Segmentation with Object Tracking](../guides/instance-segmentation-and-tracking.md) ๐Ÿš€ NEW: Implement instance segmentation and object tracking with YOLOv8 to achieve precise object boundaries and continuous monitoring. +- [VisionEye View Objects Mapping](../guides/vision-eye.md) ๐Ÿš€ NEW: Develop systems that mimic human eye focus on specific objects, enhancing the computer's ability to discern and prioritize details. +- [Speed Estimation](../guides/speed-estimation.md) ๐Ÿš€ NEW: Estimate object speed using YOLOv8 and object tracking techniques, crucial for applications like autonomous vehicles and traffic monitoring. +- [Distance Calculation](../guides/distance-calculation.md) ๐Ÿš€ NEW: Calculate distances between objects using bounding box centroids in YOLOv8, essential for spatial analysis. +- [Queue Management](../guides/queue-management.md) ๐Ÿš€ NEW: Implement efficient queue management systems to minimize wait times and improve productivity using YOLOv8. +- [Parking Management](../guides/parking-management.md) ๐Ÿš€ NEW: Organize and direct vehicle flow in parking areas with YOLOv8, optimizing space utilization and user experience. +- [Analytics](../guides/analytics.md) ๐Ÿ“Š NEW: Conduct comprehensive data analysis to discover patterns and make informed decisions, leveraging YOLOv8 for descriptive, predictive, and prescriptive analytics. + +## Contribute to Our Solutions + +We welcome contributions from the community! If you've mastered a particular aspect of Ultralytics YOLO that's not yet covered in our solutions, we encourage you to share your expertise. Writing a guide is a great way to give back to the community and help us make our documentation more comprehensive and user-friendly. + +To get started, please read our [Contributing Guide](../help/contributing.md) for guidelines on how to open up a Pull Request (PR) ๐Ÿ› ๏ธ. We look forward to your contributions! + +Let's work together to make the Ultralytics YOLO ecosystem more robust and versatile ๐Ÿ™! diff --git a/mkdocs.yml b/mkdocs.yml index f7489681..26d361d5 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -156,11 +156,13 @@ nav: - models/index.md - Datasets: - datasets/index.md + - Solutions: + - solutions/index.md - Guides: - guides/index.md - - New ๐Ÿš€ Analytics: guides/analytics.md - Explorer: - datasets/explorer/index.md + - NEW ๐Ÿš€ Analytics: guides/analytics.md # for promotion of new pages - Languages: - ๐Ÿ‡ฌ๐Ÿ‡ง  English: https://ultralytics.com/docs/ - ๐Ÿ‡จ๐Ÿ‡ณ  ็ฎ€ไฝ“ไธญๆ–‡: https://docs.ultralytics.com/zh/ @@ -184,6 +186,20 @@ nav: - Configuration: usage/cfg.md - Simple Utilities: usage/simple-utilities.md - Advanced Customization: usage/engine.md + - Modes: + - modes/index.md + - Tasks: + - tasks/index.md + - Models: + - models/index.md + - Datasets: + - datasets/index.md + - Solutions: + - solutions/index.md + - Guides: + - guides/index.md + - Explorer: + - datasets/explorer/index.md - Modes: - modes/index.md - Train: modes/train.md @@ -217,7 +233,7 @@ nav: - YOLO-World (Real-Time Open-Vocabulary Object Detection): models/yolo-world.md - Datasets: - datasets/index.md - - NEW ๐Ÿš€ Explorer: + - Explorer: - datasets/explorer/index.md - Explorer API: datasets/explorer/api.md - Explorer Dashboard: datasets/explorer/dashboard.md @@ -269,11 +285,22 @@ nav: - DOTA8: datasets/obb/dota8.md - Multi-Object Tracking: - datasets/track/index.md - - NEW ๐Ÿš€ Explorer: - - datasets/explorer/index.md - - Explorer API: datasets/explorer/api.md - - Explorer Dashboard Demo: datasets/explorer/dashboard.md - - VOC Exploration Example: datasets/explorer/explorer.ipynb + - NEW ๐Ÿš€ Solutions: + - solutions/index.md + - NEW ๐Ÿš€ Analytics: guides/analytics.md + - Object Counting: guides/object-counting.md + - Object Cropping: guides/object-cropping.md + - Object Blurring: guides/object-blurring.md + - Workouts Monitoring: guides/workouts-monitoring.md + - Objects Counting in Regions: guides/region-counting.md + - Security Alarm System: guides/security-alarm-system.md + - Heatmaps: guides/heatmaps.md + - Instance Segmentation with Object Tracking: guides/instance-segmentation-and-tracking.md + - VisionEye Mapping: guides/vision-eye.md + - Speed Estimation: guides/speed-estimation.md + - Distance Calculation: guides/distance-calculation.md + - Queue Management: guides/queue-management.md + - Parking Management: guides/parking-management.md - Guides: - guides/index.md - YOLO Common Issues: guides/yolo-common-issues.md @@ -295,21 +322,11 @@ nav: - OpenVINO Latency vs Throughput modes: guides/optimizing-openvino-latency-vs-throughput-modes.md - Steps of a Computer Vision Project: guides/steps-of-a-cv-project.md - Defining A Computer Vision Project's Goals: guides/defining-project-goals.md - - Real-World Projects: - - NEW ๐Ÿš€ Analytics: guides/analytics.md - - Object Counting: guides/object-counting.md - - Object Cropping: guides/object-cropping.md - - Object Blurring: guides/object-blurring.md - - Workouts Monitoring: guides/workouts-monitoring.md - - Objects Counting in Regions: guides/region-counting.md - - Security Alarm System: guides/security-alarm-system.md - - Heatmaps: guides/heatmaps.md - - Instance Segmentation with Object Tracking: guides/instance-segmentation-and-tracking.md - - VisionEye Mapping: guides/vision-eye.md - - Speed Estimation: guides/speed-estimation.md - - Distance Calculation: guides/distance-calculation.md - - Queue Management: guides/queue-management.md - - Parking Management: guides/parking-management.md + - Explorer: + - datasets/explorer/index.md + - Explorer API: datasets/explorer/api.md + - Explorer Dashboard Demo: datasets/explorer/dashboard.md + - VOC Exploration Example: datasets/explorer/explorer.ipynb - YOLOv5: - yolov5/index.md - Quickstart: yolov5/quickstart_tutorial.md diff --git a/tests/test_cli.py b/tests/test_cli.py index 3f710c3c..90ec9f60 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -3,6 +3,7 @@ import subprocess import pytest +from PIL import Image from tests import CUDA_DEVICE_COUNT, CUDA_IS_AVAILABLE from ultralytics.cfg import TASK2DATA, TASK2MODEL, TASKS @@ -74,26 +75,27 @@ def test_fastsam(task="segment", model=WEIGHTS_DIR / "FastSAM-s.pt", data="coco8 sam_model = FastSAM(model) # or FastSAM-x.pt # Run inference on an image - everything_results = sam_model(source, device="cpu", retina_masks=True, imgsz=1024, conf=0.4, iou=0.9) + for s in (source, Image.open(source)): + everything_results = sam_model(s, device="cpu", retina_masks=True, imgsz=320, conf=0.4, iou=0.9) - # Remove small regions - new_masks, _ = Predictor.remove_small_regions(everything_results[0].masks.data, min_area=20) + # Remove small regions + new_masks, _ = Predictor.remove_small_regions(everything_results[0].masks.data, min_area=20) - # Everything prompt - prompt_process = FastSAMPrompt(source, everything_results, device="cpu") - ann = prompt_process.everything_prompt() + # Everything prompt + prompt_process = FastSAMPrompt(s, everything_results, device="cpu") + ann = prompt_process.everything_prompt() - # Bbox default shape [0,0,0,0] -> [x1,y1,x2,y2] - ann = prompt_process.box_prompt(bbox=[200, 200, 300, 300]) + # Bbox default shape [0,0,0,0] -> [x1,y1,x2,y2] + ann = prompt_process.box_prompt(bbox=[200, 200, 300, 300]) - # Text prompt - ann = prompt_process.text_prompt(text="a photo of a dog") + # Text prompt + ann = prompt_process.text_prompt(text="a photo of a dog") - # Point prompt - # Points default [[0,0]] [[x1,y1],[x2,y2]] - # Point_label default [0] [1,0] 0:background, 1:foreground - ann = prompt_process.point_prompt(points=[[200, 200]], pointlabel=[1]) - prompt_process.plot(annotations=ann, output="./") + # Point prompt + # Points default [[0,0]] [[x1,y1],[x2,y2]] + # Point_label default [0] [1,0] 0:background, 1:foreground + ann = prompt_process.point_prompt(points=[[200, 200]], pointlabel=[1]) + prompt_process.plot(annotations=ann, output="./") def test_mobilesam(): diff --git a/ultralytics/models/fastsam/prompt.py b/ultralytics/models/fastsam/prompt.py index 59d93da2..154a1de0 100644 --- a/ultralytics/models/fastsam/prompt.py +++ b/ultralytics/models/fastsam/prompt.py @@ -24,6 +24,8 @@ class FastSAMPrompt: def __init__(self, source, results, device="cuda") -> None: """Initializes FastSAMPrompt with given source, results and device, and assigns clip for linear assignment.""" + if isinstance(source, (str, Path)) and os.path.isdir(source): + raise ValueError(f"FastSAM only accepts image paths and PIL Image sources, not directories.") self.device = device self.results = results self.source = source @@ -261,8 +263,6 @@ class FastSAMPrompt: def _crop_image(self, format_results): """Crops an image based on provided annotation format and returns cropped images and related data.""" - if os.path.isdir(self.source): - raise ValueError(f"'{self.source}' is a directory, not a valid source for this function.") image = Image.fromarray(cv2.cvtColor(self.results[0].orig_img, cv2.COLOR_BGR2RGB)) ori_w, ori_h = image.size annotations = format_results @@ -287,8 +287,6 @@ class FastSAMPrompt: """Modifies the bounding box properties and calculates IoU between masks and bounding box.""" if self.results[0].masks is not None: assert bbox[2] != 0 and bbox[3] != 0 - if os.path.isdir(self.source): - raise ValueError(f"'{self.source}' is a directory, not a valid source for this function.") masks = self.results[0].masks.data target_height, target_width = self.results[0].orig_shape h = masks.shape[1] @@ -321,8 +319,6 @@ class FastSAMPrompt: def point_prompt(self, points, pointlabel): # numpy """Adjusts points on detected masks based on user input and returns the modified results.""" if self.results[0].masks is not None: - if os.path.isdir(self.source): - raise ValueError(f"'{self.source}' is a directory, not a valid source for this function.") masks = self._format_results(self.results[0], 0) target_height, target_width = self.results[0].orig_shape h = masks[0]["segmentation"].shape[0]