Skip to content

Latest commit

 

History

History
60 lines (40 loc) · 1.81 KB

README.md

File metadata and controls

60 lines (40 loc) · 1.81 KB

COCO Annotation Converter

Description

COCO Annotation Converter is a Python script designed to convert annotations from the pred_coco.json format to the COCO Results Format. This tool is useful for those working with COCO datasets who need to transform predictions into a compatible format for analysis and evaluation.

Features

  • Support for Various Annotation Structures: Handles annotations as dictionaries containing the annotations key as well as lists of annotations.
  • Confidence Score Filtering: Allows setting a minimum score threshold to include only relevant detections.
  • Category Management: Maps category names to their respective IDs based on ground truth annotations.
  • Support for Segmentations and Keypoints: Includes segmentation and keypoint information if present in the annotations.

Requirements

  • Python 3.6 or higher

Installation

  1. Clone the Repository:

    git clone https://github.com/your-username/coco-annotation-converter.git
    cd coco-annotation-converter
  2. Create a Virtual Environment (Optional but Recommended):

    python3 -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install Dependencies:

    pip install -r requirements.txt

    If the requirements.txt file is not present, you can install dependencies manually:

    pip install argparse

Usage

Run the converter.py script via the command line, specifying the paths to the necessary files.

python converter.py --pred PATH_TO_PRED_COCO_JSON --output OUTPUT_PATH [--score_thresh THRESHOLD]

Or as external pip package as:

import converter
converter.setup_logging()
converter.convert_pred_coco('path/to/pred_coco.json', 'path/to/output.json')