Creating image masks for unets

I have a dataset with multiple objects in each image. The objects are bright spots. I have already used blobs_dog to detect the bright spots.

    image = io.imread(image_file)
    blobs_dog = blob_dog(image, min_sigma=min_sigma,
                         max_sigma=max_sigma, threshold=threshold)
    blobs_dog[:, 2] = blobs_dog[:, 2] * np.sqrt(2)

    num_objects = blobs_dog.shape[0]
    print(f"{num_objects} identified.")

    fig, (ax1, ax2) = plt.subplots(1,2)

    ax1.imshow(image, cmap=DEFAULT_CMAP, interpolation='none')
    for blob in blobs_dog:
        y, x, r = blob
        c = plt.Circle((x, y), r, color='lime', linewidth=2, fill=False)
        
        ax1.add_patch(c)

    ax1.set_axis_off()

    ax2.imshow(equalize_adapthist(image), cmap=DEFAULT_CMAP, interpolation='none')
    ax2.set_axis_off()

I now want to make masks of these images to pass them to a U-net.

I use labelme GitHub - wkentaro/labelme: Image Polygonal Annotation with Python (polygon, rectangle, circle, line, point and image-level flag annotation)..

It outputs in json so you need to do a bit of work to get it into a format for pytorch but it is free and straight forward with no nonsene