Hello there!
I guess you need to loop over your ground truths/nuclei, comparing if its IOU >.5 for each prediction and if one is, you mark the nuclei as found and remove both the nuclei and prediction.
There is a library 7 that does what you are looking for but this one only works for bounding boxes. Perhaps you could fork this repo? Good luck!