Skip to content

Commit

Permalink
Docs updates: Add Explorer to tab, YOLOv5 in Guides and Usage in Quic…
Browse files Browse the repository at this point in the history
…kstart (ultralytics#7438)

Signed-off-by: Glenn Jocher <[email protected]>
Co-authored-by: Glenn Jocher <[email protected]>
Co-authored-by: Haixuan Xavier Tao <[email protected]>
  • Loading branch information
3 people authored Jan 9, 2024
1 parent 53150a9 commit a92adf8
Show file tree
Hide file tree
Showing 30 changed files with 227 additions and 105 deletions.
2 changes: 1 addition & 1 deletion docs/en/datasets/explorer/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords: Ultralytics, Explorer GUI, semantic search, vector similarity search,

# Explorer GUI

Explorer GUI is like a playground build using (Ultralytics Explorer API)[api.md]. It allows you to run semantic/vector similarity search, SQL queries and even search using natural language using our ask AI feature powered by LLMs.
Explorer GUI is like a playground build using [Ultralytics Explorer API](api.md). It allows you to run semantic/vector similarity search, SQL queries and even search using natural language using our ask AI feature powered by LLMs.

### Installation

Expand Down
13 changes: 7 additions & 6 deletions docs/en/datasets/explorer/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ keywords: Ultralytics Explorer, CV Dataset Tools, Semantic Search, SQL Dataset Q

# Ultralytics Explorer

Ultralytics Explorer is a tool for exploring CV datasets using semantic search, SQL queries and vector similarity search. It is also a Python API for accessing the same functionality.
<p>
<img width="1709" alt="Screenshot 2024-01-08 at 7 19 48 PM (1)" src="https://github.com/AyushExel/assets/assets/15766192/e536b0eb-6bce-43fe-b800-3e79510d2e5b">
</p>

Ultralytics Explorer is a tool for exploring CV datasets using semantic search, SQL queries, vector similarity search and even using natural language. It is also a Python API for accessing the same functionality.



### Installation of optional dependencies

Expand All @@ -33,8 +39,3 @@ yolo explorer
!!! note "Note"
Ask AI feature works using OpenAI, so you'll be prompted to set the api key for OpenAI when you first run the GUI.
You can set it like this - `yolo settings openai_api_key="..."`

Example
<p>
<img width="1709" alt="Screenshot 2024-01-08 at 7 19 48 PM (1)" src="https://github.com/AyushExel/assets/assets/15766192/e536b0eb-6bce-43fe-b800-3e79510d2e5b">
</p>
7 changes: 6 additions & 1 deletion docs/en/datasets/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ Ultralytics provides support for various datasets to facilitate computer vision

## 🌟 New: Ultralytics Explorer 🌟

Create embeddings for your dataset, search for similar images, run SQL queries and perform semantic search. You can get started with our GUI app or build your own using the API. Learn more [here](explorer/index.md).
Create embeddings for your dataset, search for similar images, run SQL queries, perform semantic search and even search using natural language! You can get started with our GUI app or build your own using the API. Learn more [here](explorer/index.md).

<p>
<img width="1709" alt="Screenshot 2024-01-08 at 7 19 48 PM (1)" src="https://github.com/AyushExel/assets/assets/15766192/e536b0eb-6bce-43fe-b800-3e79510d2e5b">
</p>


- Try the [GUI Demo](explorer/index.md)
- Learn more about the [Explorer API](explorer/index.md)
Expand Down
22 changes: 11 additions & 11 deletions docs/en/guides/object-blurring.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,47 @@ Object blurring with [Ultralytics YOLOv8](https://github.com/ultralytics/ultraly
from ultralytics import YOLO
from ultralytics.utils.plotting import Annotator, colors
import cv2

model = YOLO("yolov8n.pt")
names = model.names

cap = cv2.VideoCapture("path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))

# Blur ratio
blur_ratio = 50

# Video writer
video_writer = cv2.VideoWriter("object_blurring_output.avi",
cv2.VideoWriter_fourcc(*'mp4v'),
fps, (w, h))

while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or video processing has been successfully completed.")
break

results = model.predict(im0, show=False)
boxes = results[0].boxes.xyxy.cpu().tolist()
clss = results[0].boxes.cls.cpu().tolist()
annotator = Annotator(im0, line_width=2, example=names)

if boxes is not None:
for box, cls in zip(boxes, clss):
annotator.box_label(box, color=colors(int(cls), True), label=names[int(cls)])

obj = im0[int(box[1]):int(box[3]), int(box[0]):int(box[2])]
blur_obj = cv2.blur(obj, (blur_ratio, blur_ratio))

im0[int(box[1]):int(box[3]), int(box[0]):int(box[2])] = blur_obj

cv2.imshow("ultralytics", im0)
video_writer.write(im0)
if cv2.waitKey(1) & 0xFF == ord('q'):
break

cap.release()
video_writer.release()
cv2.destroyAllWindows()
Expand Down
24 changes: 12 additions & 12 deletions docs/en/guides/object-cropping.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,50 +24,50 @@ Object cropping with [Ultralytics YOLOv8](https://github.com/ultralytics/ultraly
from ultralytics.utils.plotting import Annotator, colors
import cv2
import os

model = YOLO("yolov8n.pt")
names = model.names

cap = cv2.VideoCapture("path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))

crop_dir_name = "ultralytics_crop"
if not os.path.exists(crop_dir_name):
os.mkdir(crop_dir_name)

# Video writer
video_writer = cv2.VideoWriter("object_cropping_output.avi",
cv2.VideoWriter_fourcc(*'mp4v'),
fps, (w, h))

idx = 0
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or video processing has been successfully completed.")
break

results = model.predict(im0, show=False)
boxes = results[0].boxes.xyxy.cpu().tolist()
clss = results[0].boxes.cls.cpu().tolist()
annotator = Annotator(im0, line_width=2, example=names)

if boxes is not None:
for box, cls in zip(boxes, clss):
idx += 1
annotator.box_label(box, color=colors(int(cls), True), label=names[int(cls)])

crop_obj = im0[int(box[1]):int(box[3]), int(box[0]):int(box[2])]

cv2.imwrite(os.path.join(crop_dir_name, str(idx)+".png"), crop_obj)

cv2.imshow("ultralytics", im0)
video_writer.write(im0)

if cv2.waitKey(1) & 0xFF == ord('q'):
break

cap.release()
video_writer.release()
cv2.destroyAllWindows()
Expand Down
6 changes: 1 addition & 5 deletions docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,13 @@ Introducing [Ultralytics](https://ultralytics.com) [YOLOv8](https://github.com/u

Explore the YOLOv8 Docs, a comprehensive resource designed to help you understand and utilize its features and capabilities. Whether you are a seasoned machine learning practitioner or new to the field, this hub aims to maximize YOLOv8's potential in your projects

# 🌟 New: Ultralytics Explorer 🌟

Create embeddings for your dataset, search for similar images, run SQL queries and perform semantic search. You can get started with our GUI app or build your own using the API. Learn more [here](datasets/explorer/index.md).

## Where to Start

- **Install** `ultralytics` with pip and get up and running in minutes &nbsp; [:material-clock-fast: Get Started](quickstart.md){ .md-button }
- **Predict** new images and videos with YOLOv8 &nbsp; [:octicons-image-16: Predict on Images](modes/predict.md){ .md-button }
- **Train** a new YOLOv8 model on your own custom dataset &nbsp; [:fontawesome-solid-brain: Train a Model](modes/train.md){ .md-button }
- **Tasks** YOLOv8 tasks like segment, classify, pose and track &nbsp; [:material-magnify-expand: Explore Tasks](tasks/index.md){ .md-button }
- **Explore** datasets with advanced semantic and SQL search &nbsp; [:material-magnify-expand: Run Explorer](datasets/explorer/index.md){ .md-button }
- **NEW 🚀 Explore** datasets with advanced semantic and SQL search &nbsp; [:material-magnify-expand: Explore a Dataset](datasets/explorer/index.md){ .md-button }

<p align="center">
<br>
Expand Down
4 changes: 4 additions & 0 deletions docs/en/reference/cfg/__init__.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ keywords: Ultralytics, YOLO, Configuration, cfg2dict, handle_deprecation, merge_

<br><br>

## ::: ultralytics.cfg.handle_explorer

<br><br>

## ::: ultralytics.cfg.parse_key_value_pair

<br><br>
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/solutions/distance_calculation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords: Ultralytics, YOLO, distance calculation, object tracking, data visuali

!!! Note

This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/solutions/distance_calculation.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/solutions/distance_calculation.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/solutions/heatmap.py) 🛠️. Thank you 🙏!
This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/solutions/distance_calculation.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/solutions/distance_calculation.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/solutions/distance_calculation.py) 🛠️. Thank you 🙏!

<br><br>

Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/solutions/speed_estimation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords: Ultralytics YOLO, speed estimation software, real-time vehicle trackin

!!! Note

This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/solutions/speed_estimation.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/solutions/speed_estimation.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/solutions/object_counter.py) 🛠️. Thank you 🙏!
This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/solutions/speed_estimation.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/solutions/speed_estimation.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/solutions/speed_estimation.py) 🛠️. Thank you 🙏!

<br><br>

Expand Down
47 changes: 47 additions & 0 deletions docs/en/usage/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,53 @@ Benchmark mode is used to profile the speed and accuracy of various export forma

[Benchmark Examples](../modes/benchmark.md){ .md-button }

## Explorer

Explorer API can be used to explore datasets with advanced semantic, vector-similarity and SQL search among other features. It also searching for images based on their content using natural language by utilizing the power of LLMs. The Explorer API allows you to write your own dataset exploration notebooks or scripts to get insights into your datasets.

!!! Example "Semantic Search Using Explorer"

=== "Using Images"

```python
from ultralytics import Explorer

# create an Explorer object
exp = Explorer(data='coco128.yaml', model='yolov8n.pt')
exp.create_embeddings_table()

similar = exp.get_similar(img='https://ultralytics.com/images/bus.jpg', limit=10)
print(similar.head())

# Search using multiple indices
similar = exp.get_similar(
img=['https://ultralytics.com/images/bus.jpg',
'https://ultralytics.com/images/bus.jpg'],
limit=10
)
print(similar.head())
```

=== "Using Dataset Indices"

```python
from ultralytics import Explorer

# create an Explorer object
exp = Explorer(data='coco128.yaml', model='yolov8n.pt')
exp.create_embeddings_table()

similar = exp.get_similar(idx=1, limit=10)
print(similar.head())

# Search using multiple indices
similar = exp.get_similar(idx=[1,10], limit=10)
print(similar.head())
```

[Explorer](../datasets/explorer/index.md){ .md-button }


## Using Trainers

`YOLO` model class is a high-level wrapper on the Trainer classes. Each YOLO task has its own trainer that inherits from `BaseTrainer`.
Expand Down
Loading

0 comments on commit a92adf8

Please sign in to comment.