Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mask R-CNN 돌려보기 #9

Open
liv0vil opened this issue Mar 11, 2021 · 2 comments
Open

Mask R-CNN 돌려보기 #9

liv0vil opened this issue Mar 11, 2021 · 2 comments
Labels
code 코드 구현

Comments

@liv0vil
Copy link
Contributor

liv0vil commented Mar 11, 2021

TorchVision 객체 검출 미세조정(Finetuning) 튜토리얼
Mask R-CNN Colab Code

@liv0vil liv0vil added the code 코드 구현 label Mar 11, 2021
@mingxoxo
Copy link
Member

@mingxoxo
Copy link
Member

mingxoxo commented Mar 21, 2021

파이토치 torchvision의 Mask R-CNN을 활용한 학습용 코드
공식문서 튜토리얼

위의 링크를 통해 mmdetection을 사용하지 않고 자체적으로 구현한 Mask R-CNN 코드 돌려보기

image: a PIL Image of size (H, W)
target: a dict containing the following fields
- boxes (FloatTensor[N, 4])
- labels (Int64Tensor[N])
- image_id (Int64Tensor[1])
- area (Tensor[N])
- iscrowd (UInt8Tensor[N])
- masks (UInt8Tensor[N, H, W])


코드 돌릴 때 error : colab CUDA error: device-side assert triggered
오류 해결 : len(classes) ---> len(classes)+1 로 변경
class의 종류 갯수에서 + 1을 해주는 이유는 background class를 추가해주기 위함.

model = torchvision.models.detection.maskrcnn_resnet50_fpn(pretrained=True)
in_features = model.roi_heads.box_predictor.cls_score.in_features
model.roi_heads.box_predictor = FastRCNNPredictor(in_features, len(classes)+1)
in_features_mask = model.roi_heads.mask_predictor.conv5_mask.in_channels
hidden_layer = 256
model.roi_heads.mask_predictor = MaskRCNNPredictor(
    in_features_mask, hidden_layer, len(classes)+1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code 코드 구현
Projects
None yet
Development

No branches or pull requests

2 participants