YOLO Conformal Prediction #63
-
|
Hi ! i wanted to apply CP to object detection using a yolo finetuned model as a predictor, from what i understood i need to wrapped my predictor (so a class containing a predict method that's doing inference of the model). conformal_predictor.fit( alpha = 0.2 gives this error : In my case X contains images paths of my database, and Y a padded list of bounded boxes as a numpy array, if somebody understand please tell me ! have a nice day :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hi @alyasltd, I agree, the error message is not very clear in this case. Let me explain why your code isn't working and provide a way to make it functional.
For simplicity, we crafted the toy example you mentionned in a way that skips the step of matching true and predicted bounding boxes. This is not the case in real-world scenarios. Therefore, you need to process the outputs of your YOLO model and use a matching algorithm to link predictions with ground truth. A full example is provided in our Conformal Object Detection Tutorial. In this tutorial, you’ll find a wrapper class, Finally, due to the processing overhead introduced by the object prediction wrapper, we recommend using an # Code snippet from the COD tutorial
from deel.puncc.api.prediction import IdPredictor
from deel.puncc.object_detection import SplitBoxWise
# Create the proxy for the object detection model
api_model = IdPredictor()
# Get matching true and predicted bbox coordinates from calibration data through the wrapper object
y_calib_api, y_calib_coco, _, _ = object_detection_api.query(calib_dataset, n_instances=150)
# Instantiate the conformal predictor
conformal_predictor = SplitBoxWise(api_model, method="multiplicative", train=False)
# Fit the conformal predictor, directly provide the predicted bboxes rather than image inputs
conformal_predictor.fit(X_calib=y_calib_api, y_calib=y_calib_coco)
# Inference
...All the steps are detailed in the tutorial. Let me know if you need further clarification. |
Beta Was this translation helpful? Give feedback.

Hi @alyasltd,
I agree, the error message is not very clear in this case. Let me explain why your code isn't working and provide a way to make it functional.
First, the predictor model must output only the bounding box (bbox) coordinates in the specific format$[x1, y1, x2, y2]$ , where $(x1, y1)$ represents the top-left corner and $(x2, y2)$ represents the bottom-right corner of the predicted bounding box. However, YOLO typically outputs additional information, including an objectness score and class probabilities. Therefore, you need to process YOLO's outputs to extract only the bbox coordinates in the required format.
Second, for each image in the calibration set, YOLO may predict mu…