Closed kisenera closed 2 years ago
Well, I should have added some of these features to make it really a practical tool but haven't so far. Sorry about that.
I am not aware of any similar utility functions in AdelaiDet or Detectron2, but given the semantic masks and bounding boxes it should be simple to implement it yourself.
I found a demo of this segmenter on HuggingFace: https://huggingface.co/spaces/hysts/Yet-Another-Anime-Segmenter
In the app.py
file, the construction of the images is handled in the predict
function. You can add an alpha channel to masked
like so:
# Copy image and add alpha channel.
masked = image.copy()[:, :, ::-1]
alpha = np.full(masked.shape[:-1], 255)
masked = np.dstack((masked, alpha))
# Mark blank areas.
mask = instances.pred_masks.cpu().numpy().astype(int).max(axis=0)
masked[mask == 0] = [0, 0, 0, 0]
Note that the colours of the resultant image look a bit weird (more faded than the original; not sure why this happens) (nevermind, it was a mistake with how I turned the numpy array back into an image):
but it should be easy to copy the pixels from the original image using the alpha channel as a mask.
very nice, thanks guys
Like place the detection over a transparent/white background