huggingface / pytorch-image-models

The largest collection of PyTorch image encoders / backbones. Including train, eval, inference, export scripts, and pretrained weights -- ResNet, ResNeXT, EfficientNet, NFNet, Vision Transformer (ViT), MobileNetV4, MobileNet-V3 & V2, RegNet, DPN, CSPNet, Swin Transformer, MaxViT, CoAtNet, ConvNeXt, and more
https://huggingface.co/docs/timm
Apache License 2.0
32.13k stars 4.76k forks source link

Add FPN head #217

Closed quocnhat closed 4 years ago

quocnhat commented 4 years ago

Hi, thanks for sharing this project. I want to add FPN for object detection, How can I export some specific layers? for example, with backbone Resnet style, they defined layer name by : layer1, layer2,... When applying FPN, it is simple to return layers to the specific layer name. But your backbone defines all modules in a self.blocks. How to export layers children of that block? thank you

rwightman commented 4 years ago

There is no FPN head here, just models that can be used as backbones with an FPN head. You can see my usage of the models here as backbones for a BiFPN head (EfficientDet) here https://github.com/rwightman/efficientdet-pytorch/blob/master/effdet/efficientdet.py#L454

rwightman commented 4 years ago

@quocnhat oh and you don't have to worry about layer names or feature locations, that's figured out for every model, you just need to create the models with features_only=True as an arg for the factory and specify the output indices (zero based) e.g. out_indices=(0,1,2,3,4) of the features you want to extract, the model forward will return a list with a feature map for each index you specify.