johschmidt42 / PyTorch-Object-Detection-Faster-RCNN-Tutorial

76 stars 34 forks source link

Error when using FPN #5

Closed KrusteBang closed 2 years ago

KrusteBang commented 2 years ago

Hi John,

Thanks for your amazing tutorial! I have run some experiments using resnet34 and resnet18, the performance looks good. I'm interested to try using FPN, but there is error "raise ValueError("Anchors should be Tuple[Tuple[int]] because each feature " ValueError: Anchors should be Tuple[Tuple[int]] because each feature map could potentially have different sizes and aspect ratios. There needs to be a match between the number of feature maps passed and the number of sizes / aspect ratios " Is there somewhere need to set up ?

Thanks for looking into this

johschmidt42 commented 2 years ago

Hey @KrusteBang,

You are right, there needs to be a match between the number of feature maps and the number of sizes / aspect ratios. What's the exact backbone you are using for FPN? And what are the anchor_sizes you would like to use for that? The error indicates that your you don't pass a tuple of tuples that contain integers (Tuple[Tuple[int]])

Assuming you have 5 layers that should be used to create the anchor boxes, then your anchor_sizes var could be something likeanchor_sizes=((240,), (120,), (60,), (30,), (15,)) or if you want to go super overkill: ((240, 120, 60, 30, 15),) * 4 to be really sure that the algorithm creates anchor boxes that match well with the actual bounding boxes.

johschmidt42 commented 2 years ago

Closing due to inactivity