Package: yolox-backbone
YOLOX-Backboneyolox-backboneis a deep-learning library and collection ofYOLOXbackbone models.Installpip install yolox-backboneLoad a Pretrained ModelPretrained models can be loaded using yolox_backbone.create_model.importyolox_backbonem=yolox_backbone.create_model('yolox-s',pretrained=True)m.eval()Query the architecture informationAfter a feature backbone has been created, it can be queried to provide architecture information. The.scaling_factorattribute is a dictionary encapsulating the information about the scaling factor.importyolox_backbonem=yolox_backbone.create_model('yolox-s',pretrained=True)print('Network scaling factor: ',m.scaling_factor)Output:Networkscalingfactor:{'depth':0.33,'width':0.5}Query the feature informationAfter a feature backbone has been created, it can be queried to provide channel information to the downstream heads without requiring static config or hardcoded constants. The.out_channelsattribute is a dictionary encapsulating the information about the feature extraction points.importyolox_backbonem=yolox_backbone.create_model('yolox-s',pretrained=True)print('Feature channels: ',m.out_channels)Output:Featurechannels:{'P3':128,'P4':256,'P5':512}List Supported Modelsimportyolox_backbonefrompprintimportpprintmodel_names=yolox_backbone.list_models()pprint(model_names)Output:['yolox-s','yolox-m','yolox-l','yolox-x','yolox-nano','yolox-tiny','yolox-darknet53']Select specific feature levelsThere is one creation argument impacting the output features.out_featuresselects which FPN features to outputSupport for different number of input channelsYou can create the model without the constraint that the number of input channel is 3.But you have to setpretrainedtoFalse.importyolox_backbonemodel=yolox_backbone.create_model(model_name=model_name,pretrained=False,input_tensor_channels=4,out_features=["P3","P4","P5"])Exampleimportyolox_backboneimporttorchfrompprintimportpprintpprint(yolox_backbone.list_models())model_names=yolox_backbone.list_models()formodel_nameinmodel_names:print("model_name: ",model_name)model=yolox_backbone.create_model(model_name=model_name,pretrained=True,out_features=["P3","P4","P5"])input_tensor=torch.randn((1,3,640,640))fpn_output_tensors=model(input_tensor)p3=fpn_output_tensors["P3"]p4=fpn_output_tensors["P4"]p5=fpn_output_tensors["P5"]print("input_tensor.shape: ",input_tensor.shape)print("p3.shape: ",p3.shape)print("p4.shape: ",p4.shape)print("p5.shape: ",p5.shape)print("-"*50)Output:['yolox-s','yolox-m','yolox-l','yolox-x','yolox-nano','yolox-tiny','yolox-darknet53']model_name:yolox-sinput_tensor.shape:torch.Size([1,3,640,640])p3.shape:torch.Size([1,128,80,80])p4.shape:torch.Size([1,256,40,40])p5.shape:torch.Size([1,512,20,20])--------------------------------------------------model_name:yolox-minput_tensor.shape:torch.Size([1,3,640,640])p3.shape:torch.Size([1,192,80,80])p4.shape:torch.Size([1,384,40,40])p5.shape:torch.Size([1,768,20,20])--------------------------------------------------model_name:yolox-linput_tensor.shape:torch.Size([1,3,640,640])p3.shape:torch.Size([1,256,80,80])p4.shape:torch.Size([1,512,40,40])p5.shape:torch.Size([1,1024,20,20])--------------------------------------------------model_name:yolox-xinput_tensor.shape:torch.Size([1,3,640,640])p3.shape:torch.Size([1,320,80,80])p4.shape:torch.Size([1,640,40,40])p5.shape:torch.Size([1,1280,20,20])--------------------------------------------------model_name:yolox-nanoinput_tensor.shape:torch.Size([1,3,640,640])p3.shape:torch.Size([1,64,80,80])p4.shape:torch.Size([1,128,40,40])p5.shape:torch.Size([1,256,20,20])--------------------------------------------------model_name:yolox-tinyinput_tensor.shape:torch.Size([1,3,640,640])p3.shape:torch.Size([1,96,80,80])p4.shape:torch.Size([1,192,40,40])p5.shape:torch.Size([1,384,20,20])--------------------------------------------------model_name:yolox-darknet53input_tensor.shape:torch.Size([1,3,640,640])p3.shape:torch.Size([1,128,80,80])p4.shape:torch.Size([1,256,40,40])p5.shape:torch.Size([1,512,20,20])--------------------------------------------------AcknowledgementThe docs are heavily based ontimm docs. Thanks for their awesome works.