U-Net_v2是否能用于做实例分割的任务?
Closed this issue · 1 comments
wjpstudy commented
我迫切需要使用U-Net_v2(或者U-Net系列)做实例分割的任务,请问您有U-Net_v2做实例分割的示例吗?谢谢!期待您的回复!
yaoppeng commented
可以用于实例分割,但是我没做过相关实验。推荐使用mmsegmentation。如果要把这个嵌入进去的话应该很简单,
例如下面的代码
from unet_v2.UNet_v2 import *
n_classes=2
pretrained_path="/path/to/pretrained/pvt"
model = UNetV2(n_classes=n_classes, deep_supervision=True, pretrained_path=pretrained_path)
x = torch.rand((2, 3, 256, 256))
ys = model(x) # ys is a list because of deep supervision
图像通过backbone
之后得到hierarchical特征ys
,将ys
送入到segmentation head即可。