Skip to content
Snippets Groups Projects
README.md 1.65 KiB
Newer Older
guis98's avatar
guis98 committed
# 0. Directory structure:

```
Hens Tracking

├── data
│   ├── frames
│   │   └── frame_0.jpg, frame_1.jpg, ..., frame_204.jpg
│   └── video
│       └──  video.mkv

├──  train
│   ├── images
│   │   └── first 185 images
│   └── labels

├──  val
│   ├── images
│   │   └── remaining 20 images
│   └── labels

├──  annotate.py

├──  get_stuff.py

├──  track.py

└── data.yaml
```

# 1. Annotated the frames using `ultralytics auto annotator`

> Run `python annotate.py` 

(See output `annotate_output.txt`)
guis98's avatar
guis98 committed

guis98's avatar
guis98 committed
This creates a folder under `data` named 'frames_auto_annotate_labels' and gives a .txt file for each frame containing the segmentations of the hens it detected.
guis98's avatar
guis98 committed


guis98's avatar
guis98 committed
# 2. Put the labels into a proper structure for training i.e. specify custom class (hen)
guis98's avatar
guis98 committed

guis98's avatar
guis98 committed
> Run `python get_stuff.py`
guis98's avatar
guis98 committed

guis98's avatar
guis98 committed
This will put all the necesaary files under `train/labels`. Move the last 20 files to `val/labels` for validation in the next stripped.
guis98's avatar
guis98 committed


guis98's avatar
guis98 committed
# 3. The model is now trained using a pretrained `yolov8x-seg` 
Ensure that the directory path is good
guis98's avatar
guis98 committed

guis98's avatar
guis98 committed
> Run `yolo task=segment mode=train model=yolov8x-seg data=data.yaml epochs=20 imgsz=640` in a terminal opened in the directory

(See output `train_output.txt`)
guis98's avatar
guis98 committed

guis98's avatar
guis98 committed
This will create a `runs` folder and all the metrics and model weights will be stored there.
guis98's avatar
guis98 committed


guis98's avatar
guis98 committed
# 4. Use the best weights as input model for tracking

> Run `python track.py` 
guis98's avatar
guis98 committed

guis98's avatar
guis98 committed
(See `output track_output.txt`, uncomment line no. 34 if you want to visualize the output alongside running)
guis98's avatar
guis98 committed

guis98's avatar
guis98 committed
The final tracking video would be saved under the directory.