Skip to content

autoAnnoter its a tool to auto annotate data using a exisiting models

License

Notifications You must be signed in to change notification settings

naseemap47/autoAnnoter

Repository files navigation

autoAnnoter


autoAnnoter: Its a tool to auto annotate data using a exisiting model

πŸ› οΈ Tools

πŸ› οΈ Augumentaion

Augument your annotation files (Object detection) PASCAL VOC (XML) or YOLO (TXT)

Auto annotate any class πŸš€

Open-Vocabulary Detection Model

  • Grounding DINO
  • OWL-ViT
  • YOLO-World
  • PaliGemma
  • Florence-2

Open-Vocabulary Detection

1. Grounding DINO πŸ¦•

Grounding DINO is text to detection model. So we need to give text prompt that correspond to respective class.

2. OWL-ViT

OWL-ViT is an open-vocabulary object detector. It means that it can detect objects in images based on free-text queries without the need to fine-tune the model on labeled datasets..

3. YOLO-World

The YOLO-World Model introduces an advanced, real-time Ultralytics YOLOv8-based approach for Open-Vocabulary Detection tasks. This innovation enables the detection of any object within an image based on descriptive texts.

Clone this GitHub Repository

git clone https://github.com/naseemap47/autoAnnoter.git

Install Dependencies

Recommended:

conda create -n auto python=3.9 -y
conda activate auto
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch -y
pip install -r requirements.txt

OR

cd autoAnnoter/
pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
pip install -r requirements.txt

Auto annotate any class with Open-Vocabulary Detection Model

To do this, we needs to create prompt.json

JSON keys should be text prompt to Open-Vocabulary Detection Model.
But the values for the each keys should be class names for that detection.

Example:

Here I need to train one custom model that can predict high quality cap and low quality cap.
So for this I give my Open-Vocabulary Detection Model text prompt as red cap and yellow caps, to annotate my high quality cap and low quality cap classes.

I give this example to show you that, some times we need to give Open-Vocabulary Detection Model text prompt as more elaborate way, like my example.

out11

{
    "red caps": "high quality cap",
    "yellow caps": "low quality cap"
}

This approch we can use when the object is same, but have different feature like color.

1. Grounding DINO πŸ¦•

Args

-i, --dataset: path to dataset/dir
-p, --prompt: path to prompt.json
-bt, --box_thld: Box Threshold
-tt, --txt_thld: text threshold

To auto-annotate Grounding DINO model, we need to give text prompt that correspond to respective class.

Example:

python3 dino.py --dataset images/ --prompt prompt.json

2. OWL-ViT

Args

-i, --dataset: path to dataset/dir
-p, --prompt: path to prompt.json
-bt, --box_thld: bounding box Threshold

To auto-annotate OWL-ViT model, we need to give text prompt that correspond to respective class.

Example:

python3 owlvit.py --dataset images/ --prompt prompt.json

3. YOLO-World

Args

-i, --data: path to dataset/dir
-p, --prompt: path to prompt.json
-c, --conf: detection confidence
-m, --model: Choose model version/type

'yolov8s-world.pt', 'yolov8s-worldv2.pt'
'yolov8m-world.pt', 'yolov8m-worldv2.pt'
'yolov8l-world.pt', 'yolov8l-worldv2.pt'
'yolov8x-world.pt', 'yolov8x-worldv2.pt

-f, --format: annotation format

'txt', 'xml'

To auto-annotate YOLO-World model, we need to give text prompt that correspond to respective class.

Example:

python3 yolo_world.py --data images/ --prompt prompt.json --conf 0.8 \
                  --model yolov8m-worldv2.pt --format txt

Auto annotate any class with Pre-Trained Detection Model

1. ONNX Model

Args

-x, --xml: to annotate in XML format
-t, --txt: to annotate in (.txt) format
-i, --dataset: path to dataset/dir
-c, --classes: path to classes.txt
-m, --model: path to ONNX model
-s, --size: Size of image used to train the model
-conf, --confidence: Model detection Confidence (0<confidence<1)
-r, --remove: List of classes need to remove
-k, --keep: List of classes need to keep

Example:

To .xml

python3 autoAnnot.py --xml --dataset images/ --classes classes.txt \
                     --model models/model.onnx --size 224 --confidence 0.75

To .txt

python3 autoAnnot.py --txt --dataset images/ --classes classes.txt \
                     --model models/model.onnx --size 224 --confidence 0.75

To Remove classes from auto-annotation

python3 autoAnnot.py --txt --dataset images/ --classes classes.txt \
                     --model models/model.onnx --size 224 --confidence 0.75 \
                     --remove 'person' 'car

To Keep classes from auto-annotation

python3 autoAnnot.py --txt --dataset images/ --classes classes.txt \
                     --model models/model.onnx --size 224 --confidence 0.75 \
                     --keep 'person' 'car

2. YOLO Model

Args

-i, --dataset: path to dataset/dir
-mt, --model_type: Choose YOLO Model "YOLOv7 or YOLOv8"
-m, --model: path to best.pt (YOLO) model
-conf, --confidence: Model detection Confidence (0<confidence<1)
-r, --remove: List of classes need to remove
-k, --keep: List of classes need to keep

for YOLO-NAS Model
-t, --type: Choose YOLO-NAS model type
example: yolo_nas_s, yolo_nas_m, yolo_nas_l
-n, --num: number of classes that model trained on

Examples:

1. YOLOv7 Model

python3 autoAnotYolo.py --dataset dataset/images --model_type yolov7 \
                        --model runs/train/weights/best.pt --confidence 0.8
  • To Remove classes from auto-annotation
python3 autoAnotYolo.py --dataset dataset/images --model_type yolov7 \
                        --model runs/train/weights/best.pt --confidence 0.8 \
                        --remove 'bus'
  • To Keep classes from auto-annotation
python3 autoAnotYolo.py --dataset dataset/images --model_type yolov7 \
                        --model runs/train/weights/best.pt --confidence 0.8 \
                        --keep 'bus'

2. YOLOv8 Model

python3 autoAnotYolo.py --dataset dataset/images --model_type yolov8 \
                        --model runs/train/weights/best.pt --confidence 0.8
  • To Remove classes from auto-annotation
python3 autoAnotYolo.py --dataset dataset/images --model_type yolov8 \
                        --model runs/train/weights/best.pt --confidence 0.8 \
                        --remove 'elephant' 'cat' 'bear'
  • To Keep classes from auto-annotation
python3 autoAnotYolo.py --dataset dataset/images --model_type yolov8 \
                        --model runs/train/weights/best.pt --confidence 0.8 \
                        --keep 'cat'

3. YOLO-NAS Model

Custom Model

python3 autoAnotYolo.py --dataset dataset/images --model_type yolonas \
                        --model runs/train/weights/best.pt --type yolo_nas_s \
                        --num 8 --confidence 0.8

COCO Model

python3 autoAnotYolo.py --dataset dataset/images --model_type yolonas \
                        --model coco --type yolo_nas_s \
                        --confidence 0.8
  • To Remove classes from auto-annotation
python3 autoAnotYolo.py --dataset dataset/images --model_type yolonas \
                        --model runs/train/weights/best.pt --type yolo_nas_s \
                        --num 80 --confidence 0.8 \
                        --remove 'car'
  • To Keep classes from auto-annotation
python3 autoAnotYolo.py --dataset dataset/images --model_type yolonas \
                        --model runs/train/weights/best.pt --type yolo_nas_s \
                        --num 32 --confidence 0.8 \
                        --keep 'car'

About

autoAnnoter its a tool to auto annotate data using a exisiting models

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages