Fix mkdocs.yml raw image URLs (#14213)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Burhan <62214284+Burhan-Q@users.noreply.github.com>
This commit is contained in:
parent
d5db9c916f
commit
5d479c73c2
69 changed files with 4767 additions and 223 deletions
|
|
@ -4,7 +4,7 @@ description: Learn to create line graphs, bar plots, and pie charts using Python
|
|||
keywords: Ultralytics, YOLOv8, data visualization, line graphs, bar plots, pie charts, Python, analytics, tutorial, guide
|
||||
---
|
||||
|
||||
# Analytics using Ultralytics YOLOv8 📊
|
||||
# Analytics using Ultralytics YOLOv8
|
||||
|
||||
## Introduction
|
||||
|
||||
|
|
@ -324,3 +324,170 @@ Here's a table with the `Analytics` arguments:
|
|||
## Conclusion
|
||||
|
||||
Understanding when and how to use different types of visualizations is crucial for effective data analysis. Line graphs, bar plots, and pie charts are fundamental tools that can help you convey your data's story more clearly and effectively.
|
||||
|
||||
## FAQ
|
||||
|
||||
### How do I create a line graph using Ultralytics YOLOv8 Analytics?
|
||||
|
||||
To create a line graph using Ultralytics YOLOv8 Analytics, follow these steps:
|
||||
|
||||
1. Load a YOLOv8 model and open your video file.
|
||||
2. Initialize the `Analytics` class with the type set to "line."
|
||||
3. Iterate through video frames, updating the line graph with relevant data, such as object counts per frame.
|
||||
4. Save the output video displaying the line graph.
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
import cv2
|
||||
|
||||
from ultralytics import YOLO, solutions
|
||||
|
||||
model = YOLO("yolov8s.pt")
|
||||
cap = cv2.VideoCapture("Path/to/video/file.mp4")
|
||||
out = cv2.VideoWriter("line_plot.avi", cv2.VideoWriter_fourcc(*"MJPG"), fps, (w, h))
|
||||
|
||||
analytics = solutions.Analytics(type="line", writer=out, im0_shape=(w, h), view_img=True)
|
||||
|
||||
while cap.isOpened():
|
||||
success, frame = cap.read()
|
||||
if success:
|
||||
results = model.track(frame, persist=True)
|
||||
total_counts = sum([1 for box in results[0].boxes.xyxy])
|
||||
analytics.update_line(frame_count, total_counts)
|
||||
if cv2.waitKey(1) & 0xFF == ord("q"):
|
||||
break
|
||||
|
||||
cap.release()
|
||||
out.release()
|
||||
cv2.destroyAllWindows()
|
||||
```
|
||||
|
||||
For further details on configuring the `Analytics` class, visit the [Analytics using Ultralytics YOLOv8 📊](#analytics-using-ultralytics-yolov8) section.
|
||||
|
||||
### What are the benefits of using Ultralytics YOLOv8 for creating bar plots?
|
||||
|
||||
Using Ultralytics YOLOv8 for creating bar plots offers several benefits:
|
||||
|
||||
1. **Real-time Data Visualization**: Seamlessly integrate object detection results into bar plots for dynamic updates.
|
||||
2. **Ease of Use**: Simple API and functions make it straightforward to implement and visualize data.
|
||||
3. **Customization**: Customize titles, labels, colors, and more to fit your specific requirements.
|
||||
4. **Efficiency**: Efficiently handle large amounts of data and update plots in real-time during video processing.
|
||||
|
||||
Use the following example to generate a bar plot:
|
||||
|
||||
```python
|
||||
import cv2
|
||||
|
||||
from ultralytics import YOLO, solutions
|
||||
|
||||
model = YOLO("yolov8s.pt")
|
||||
cap = cv2.VideoCapture("Path/to/video/file.mp4")
|
||||
out = cv2.VideoWriter("bar_plot.avi", cv2.VideoWriter_fourcc(*"MJPG"), fps, (w, h))
|
||||
|
||||
analytics = solutions.Analytics(type="bar", writer=out, im0_shape=(w, h), view_img=True)
|
||||
|
||||
while cap.isOpened():
|
||||
success, frame = cap.read()
|
||||
if success:
|
||||
results = model.track(frame, persist=True)
|
||||
clswise_count = {
|
||||
model.names[int(cls)]: boxes.size(0)
|
||||
for cls, boxes in zip(results[0].boxes.cls.tolist(), results[0].boxes.xyxy)
|
||||
}
|
||||
analytics.update_bar(clswise_count)
|
||||
if cv2.waitKey(1) & 0xFF == ord("q"):
|
||||
break
|
||||
|
||||
cap.release()
|
||||
out.release()
|
||||
cv2.destroyAllWindows()
|
||||
```
|
||||
|
||||
To learn more, visit the [Bar Plot](#visual-samples) section in the guide.
|
||||
|
||||
### Why should I use Ultralytics YOLOv8 for creating pie charts in my data visualization projects?
|
||||
|
||||
Ultralytics YOLOv8 is an excellent choice for creating pie charts because:
|
||||
|
||||
1. **Integration with Object Detection**: Directly integrate object detection results into pie charts for immediate insights.
|
||||
2. **User-Friendly API**: Simple to set up and use with minimal code.
|
||||
3. **Customizable**: Various customization options for colors, labels, and more.
|
||||
4. **Real-time Updates**: Handle and visualize data in real-time, which is ideal for video analytics projects.
|
||||
|
||||
Here's a quick example:
|
||||
|
||||
```python
|
||||
import cv2
|
||||
|
||||
from ultralytics import YOLO, solutions
|
||||
|
||||
model = YOLO("yolov8s.pt")
|
||||
cap = cv2.VideoCapture("Path/to/video/file.mp4")
|
||||
out = cv2.VideoWriter("pie_chart.avi", cv2.VideoWriter_fourcc(*"MJPG"), fps, (w, h))
|
||||
|
||||
analytics = solutions.Analytics(type="pie", writer=out, im0_shape=(w, h), view_img=True)
|
||||
|
||||
while cap.isOpened():
|
||||
success, frame = cap.read()
|
||||
if success:
|
||||
results = model.track(frame, persist=True)
|
||||
clswise_count = {
|
||||
model.names[int(cls)]: boxes.size(0)
|
||||
for cls, boxes in zip(results[0].boxes.cls.tolist(), results[0].boxes.xyxy)
|
||||
}
|
||||
analytics.update_pie(clswise_count)
|
||||
if cv2.waitKey(1) & 0xFF == ord("q"):
|
||||
break
|
||||
|
||||
cap.release()
|
||||
out.release()
|
||||
cv2.destroyAllWindows()
|
||||
```
|
||||
|
||||
For more information, refer to the [Pie Chart](#visual-samples) section in the guide.
|
||||
|
||||
### Can Ultralytics YOLOv8 be used to track objects and dynamically update visualizations?
|
||||
|
||||
Yes, Ultralytics YOLOv8 can be used to track objects and dynamically update visualizations. It supports tracking multiple objects in real-time and can update various visualizations like line graphs, bar plots, and pie charts based on the tracked objects' data.
|
||||
|
||||
Example for tracking and updating a line graph:
|
||||
|
||||
```python
|
||||
import cv2
|
||||
|
||||
from ultralytics import YOLO, solutions
|
||||
|
||||
model = YOLO("yolov8s.pt")
|
||||
cap = cv2.VideoCapture("Path/to/video/file.mp4")
|
||||
out = cv2.VideoWriter("line_plot.avi", cv2.VideoWriter_fourcc(*"MJPG"), fps, (w, h))
|
||||
|
||||
analytics = solutions.Analytics(type="line", writer=out, im0_shape=(w, h), view_img=True)
|
||||
|
||||
while cap.isOpened():
|
||||
success, frame = cap.read()
|
||||
if success:
|
||||
results = model.track(frame, persist=True)
|
||||
total_counts = sum([1 for box in results[0].boxes.xyxy])
|
||||
analytics.update_line(frame_count, total_counts)
|
||||
if cv2.waitKey(1) & 0xFF == ord("q"):
|
||||
break
|
||||
|
||||
cap.release()
|
||||
out.release()
|
||||
cv2.destroyAllWindows()
|
||||
```
|
||||
|
||||
To learn about the complete functionality, see the [Tracking](../modes/track.md) section.
|
||||
|
||||
### What makes Ultralytics YOLOv8 different from other object detection solutions like OpenCV and TensorFlow?
|
||||
|
||||
Ultralytics YOLOv8 stands out from other object detection solutions like OpenCV and TensorFlow for multiple reasons:
|
||||
|
||||
1. **State-of-the-art Accuracy**: YOLOv8 provides superior accuracy in object detection, segmentation, and classification tasks.
|
||||
2. **Ease of Use**: User-friendly API allows for quick implementation and integration without extensive coding.
|
||||
3. **Real-time Performance**: Optimized for high-speed inference, suitable for real-time applications.
|
||||
4. **Diverse Applications**: Supports various tasks including multi-object tracking, custom model training, and exporting to different formats like ONNX, TensorRT, and CoreML.
|
||||
5. **Comprehensive Documentation**: Extensive [documentation](https://docs.ultralytics.com/) and [blog resources](https://www.ultralytics.com/blog) to guide users through every step.
|
||||
|
||||
For more detailed comparisons and use cases, explore our [Ultralytics Blog](https://www.ultralytics.com/blog/ai-use-cases-transforming-your-future).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue