Validation with YOLOv8 segmentation

Hello,

I train yolov8 segmentation model but, my dataset has 25882588 images and labels. With dividing them 512512, I can trained and predict. but for validation ı want to use 25882588 images and ground truth. Is there any way to compare and create confusion matrix with 25882585 predicted image and ground truth image?

Hello!

Validating directly on the full 2588x2588 images after training on 512x512 tiles requires a custom approach. The standard val mode evaluates performance based on the input size specified (usually matching training or a defined imgsz) on the validation dataset split, calculating metrics like the confusion matrix directly from the model’s outputs on those inputs.

To achieve validation on the full-resolution images by comparing stitched predictions against the large ground truth:

  1. Use the predict mode on your large validation images (or predict on the 512x512 tiles derived from them).
  2. Develop a custom script to stitch the resulting predicted masks from the tiles back together into the full 2588x2588 resolution.
  3. Load your 2588x2588 ground truth masks.
  4. Compare the stitched prediction masks with the ground truth masks using your chosen metrics (e.g., IoU, pixel accuracy) and generate a confusion matrix based on this comparison.

The built-in val mode doesn’t automatically handle this stitching and full-resolution comparison process. You can find details on the standard validation process in the Val Mode documentation.

1 Like

You should be able to specify the directory with your images and labels for the full size (2588, 2588) images in your data.yaml

path: ../datasets/custom_data # dataset root dir
train: images/train # train images (512, 512) and split labels
val: images/val # val images (2588, 2588') and full size labels

Thank you, I didn’t think it would work. But how it works? Validation is also use our trained model I think.

Yes, validation uses the training model, but you can specify the imgsz argument when you call validation (in the docs here). So if your validation images are (2588, 2588), then you can use

from ultralytics import YOLO

model = YOLO("path/to/your/model.pt")

model.val(data="path/to/data.yaml", imgsz=2588)

(post deleted by author)

ı dont want to reprediction by yolo. I alredy have predicted images and labels. just comparing. With this validation, model run and predict. I just want to use yolo tools about producing confusion matriw, f1 score table etc. Is this possible?