Implementation:Obss Sahi Coco2fiftyone
| Knowledge Sources | |
|---|---|
| Domains | Visualization, COCO, Evaluation |
| Last Updated | 2026-02-08 12:00 GMT |
Overview
CLI script that loads COCO datasets and detection results into FiftyOne for interactive visualization and evaluation.
Description
The coco2fiftyone script provides a command-line interface for importing COCO-formatted datasets and detection results into the FiftyOne visualization platform. It creates a FiftyOne dataset from COCO images and annotations, optionally adds one or more detection result JSON files as prediction labels, evaluates the first result set against ground truth (computing false positives), and launches the FiftyOne app sorted by false positive count for error analysis.
Usage
Run this script from the sahi CLI when you want to visually inspect detection results against COCO ground truth using FiftyOne, particularly for analyzing false positive patterns.
Code Reference
Source Location
- Repository: Obss_Sahi
- File: sahi/scripts/coco2fiftyone.py
- Lines: 1-81
Signature
def main(
image_dir: str,
dataset_json_path: str,
*result_json_paths,
iou_thresh: float = 0.5,
) -> None:
"""
Args:
image_dir (str): directory for coco images
dataset_json_path (str): file path for the coco dataset json file
result_json_paths (str): one or more paths for the coco result json file
iou_thresh (float): iou threshold for coco evaluation
"""
Import
from sahi.scripts.coco2fiftyone import main
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| image_dir | str | Yes | Directory containing COCO images |
| dataset_json_path | str | Yes | Path to COCO annotation JSON file |
| result_json_paths | str (variadic) | No | One or more COCO result JSON paths |
| iou_thresh | float | No (default 0.5) | IOU threshold for evaluation |
Outputs
| Name | Type | Description |
|---|---|---|
| FiftyOne session | Interactive app | Browser-based visualization at localhost |
Usage Examples
Visualize Dataset with Results
# Via CLI (using python-fire)
python -m sahi.scripts.coco2fiftyone \
--image_dir /path/to/images \
--dataset_json_path /path/to/annotations.json \
/path/to/result1.json /path/to/result2.json \
--iou_thresh 0.5
Programmatic Usage
from sahi.scripts.coco2fiftyone import main
main(
image_dir="/data/coco/images",
dataset_json_path="/data/coco/annotations.json",
"/data/results/model_a.json",
"/data/results/model_b.json",
iou_thresh=0.5,
)