Skip to content
Snippets Groups Projects

Visualization Notebook

Open Lennart Heinbokel requested to merge feature/visualization_notebook into main
2 files
+ 84
1
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 82
0
%% Cell type:markdown id: tags:
# Visualize YOLOv8 Predictions
In this notebook, you can spin-up a Voxel51 instance to visualize some predictions from the YOLOv8 model.
%% Cell type:markdown id: tags:
### Imports
%% Cell type:code id: tags:
``` python
# Suppress Ultralytics logging
import os; os.environ["YOLO_VERBOSE"] = "False"
import fiftyone as fo
import fiftyone.zoo as foz
import fiftyone.utils.ultralytics as fou
from ultralytics import YOLO
import fiftyone as fo
import fiftyone.utils.ultralytics as fou
from ultralytics import YOLO
```
%% Cell type:markdown id: tags:
### Set parameters
%% Cell type:code id: tags:
``` python
DATASET_DIR = "/Users/lheinbokel/Desktop/things/SUTURO1_DATA_imgs_from_bags/milestone_2/2023-01-23/2023-01-23_objects_on_table" # Path to a folder containing images dataset_dir
MODEL_WEIGHTS = "/Users/lheinbokel/Desktop/best.pt" # Path to a .pt file containing model weights
```
%% Cell type:markdown id: tags:
### Load dataset
%% Cell type:code id: tags:
``` python
# The type of the dataset being imported
dataset_type = fo.types.ImageDirectory
# Import the dataset
dataset = fo.Dataset.from_dir(
dataset_dir=dataset_dir,
dataset_type=dataset_type,
)
```
%% Cell type:markdown id: tags:
### Run inference on the dataset
%% Cell type:code id: tags:
``` python
model = YOLO(MODEL_WEIGHTS)
for sample in dataset.iter_samples(progress=True):
result = model(sample.filepath)[0]
sample["boxes"] = fou.to_detections(result)
sample.save()
```
%% Cell type:markdown id: tags:
### Visualize predictions
%% Cell type:code id: tags:
``` python
session = fo.launch_app(dataset, address="localhost", port=5151)
```
%% Cell type:code id: tags:
``` python
```
Loading