Apply new Ruff actions to Python codeblocks (#13783)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Glenn Jocher 2024-06-18 20:51:37 +02:00 committed by GitHub
parent c0305f4e15
commit 6bddeda34b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 95 additions and 99 deletions

View file

@ -60,12 +60,6 @@ pip install -U ultralytics sahi
Here's how to import the necessary modules and download a YOLOv8 model and some test images:
```python
from pathlib import Path
from IPython.display import Image
from sahi import AutoDetectionModel
from sahi.predict import get_prediction, get_sliced_prediction, predict
from sahi.utils.cv import read_image
from sahi.utils.file import download_from_url
from sahi.utils.yolov8 import download_yolov8s_model
@ -91,6 +85,8 @@ download_from_url(
You can instantiate a YOLOv8 model for object detection like this:
```python
from sahi import AutoDetectionModel
detection_model = AutoDetectionModel.from_pretrained(
model_type="yolov8",
model_path=yolov8_model_path,
@ -104,6 +100,8 @@ detection_model = AutoDetectionModel.from_pretrained(
Perform standard inference using an image path or a numpy image.
```python
from sahi.predict import get_prediction
# With an image path
result = get_prediction("demo_data/small-vehicles1.jpeg", detection_model)
@ -125,6 +123,8 @@ Image("demo_data/prediction_visual.png")
Perform sliced inference by specifying the slice dimensions and overlap ratios:
```python
from sahi.predict import get_sliced_prediction
result = get_sliced_prediction(
"demo_data/small-vehicles1.jpeg",
detection_model,
@ -155,6 +155,8 @@ result.to_fiftyone_detections()[:3]
For batch prediction on a directory of images:
```python
from sahi.predict import predict
predict(
model_type="yolov8",
model_path="path/to/yolov8n.pt",