Metadata-Version: 2.1
Name: YALTAi
Version: 0.1.0
Summary: You Actually Look Twice At it, YOLOv5-Kraken adapter for region detection 
Home-page: https://github.com/ponteineptique/yaltai
Author: Thibault Clérice
License: MIT
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.8.0
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Pillow (>=7.1.2)
Requires-Dist: PyYAML (>=5.3.1)
Requires-Dist: fast-deskew
Requires-Dist: ipython
Requires-Dist: kraken (==4.3.1)
Requires-Dist: matplotlib (>=3.2.2)
Requires-Dist: mean-average-precision (==2021.4.26.0)
Requires-Dist: numpy (<=1.23.99,>=1.23.0)
Requires-Dist: opencv-python (>=4.1.1)
Requires-Dist: pandas (>=1.1.4)
Requires-Dist: protobuf (<=3.20.1)
Requires-Dist: psutil
Requires-Dist: requests (>=2.23.0)
Requires-Dist: scipy (>=1.4.1)
Requires-Dist: seaborn (>=0.11.0)
Requires-Dist: tabulate (~=0.8.10)
Requires-Dist: tensorboard (>=2.4.1)
Requires-Dist: thop (>=0.1.1)
Requires-Dist: tqdm (>=4.64.0)


# YALTAi
You Actually Look Twice At it

This provides an adapter for Kraken to use YOLOv5 Object Detection routine.

This tool can be used for both segmenting and conversion of models.

# Routine

## Instal

```bash
pip install YALTAi
```

## Training

Convert (and split optionally) your data

```bash
# Keeps .1 data in the validation set and convert all alto into YOLOv5 format
#  Keeps the segmonto information up to the regions
yaltai alto-to-yolo PATH/TO/ALTOorPAGE/*.xml my-dataset --shuffle .1 --segmonto region
```

And then [train YOLO](https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data) 

```bash
# Download YOLOv5
git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
git checkout v6.2
pip install -r requirements.txt  # install
# Train your YOLOv5 data (YOLOv5 is installed with YALTAi)
python train.py --data "../my-dataset/config.yml" --batch-size 4 --img 640 --weights yolov5x.pt --epochs 50
```

## Predicting

YALTAi has the same CLI interface as Kraken, so:

- You can use base BLLA model for line or provide yours with `-m model.mlmodel`
- Use a GPU (`--device cuda:0`) or a CPU (`--device cpu`)
- Apply on batch (`*.jpg`)

```bash
# Retrieve the best.pt after the training
# It should be in runs/train/exp[NUMBER]/weights/best.pt
# And then annotate your new data with the same CLI API as Kraken !
yaltai kraken --device cuda:0 -I "*.jpg" --suffix ".xml" segment --yolo runs/train/exp5/weights/best.pt
```

## Metrics

The metrics produced from various libraries never gives the same mAP or Precision. I tried

- `object-detection-metrics==0.4`
- `mapCalc`
- `mean-average-precision` which ended up being the chosen one (cleanest in terms of how I can access info) 

and of course I compared with YOLOv5 raw results. Nothing worked the same. And the library YOLOv5 derives its metrics from is uninstallable through pip.


