2021-03-15 03:08:56 +08:00
# Deep Layer Aggregation
2021-03-12 00:52:13 +08:00
Extending “shallow” skip connections, **Dense Layer Aggregation (DLA)** incorporates more depth and sharing. The authors introduce two structures for deep layer aggregation (DLA): iterative deep aggregation (IDA) and hierarchical deep aggregation (HDA). These structures are expressed through an architectural framework, independent of the choice of backbone, for compatibility with current and future networks.
IDA focuses on fusing resolutions and scales while HDA focuses on merging features from all modules and channels. IDA follows the base hierarchy to refine resolution and aggregate scale stage-bystage. HDA assembles its own hierarchy of tree-structured connections that cross and merge stages to aggregate different levels of representation.
## How do I use this model on an image?
To load a pretrained model:
```python
import timm
2021-03-13 02:38:10 +08:00
model = timm.create_model('dla102', pretrained=True)
2021-03-12 00:52:13 +08:00
model.eval()
```
To load and preprocess the image:
```python
import urllib
from PIL import Image
from timm.data import resolve_data_config
from timm.data.transforms_factory import create_transform
config = resolve_data_config({}, model=model)
transform = create_transform(**config)
url, filename = ("https://github.com/pytorch/hub/raw/master/images/dog.jpg", "dog.jpg")
urllib.request.urlretrieve(url, filename)
img = Image.open(filename).convert('RGB')
tensor = transform(img).unsqueeze(0) # transform and add batch dimension
```
To get the model predictions:
```python
import torch
with torch.no_grad():
out = model(tensor)
probabilities = torch.nn.functional.softmax(out[0], dim=0)
print(probabilities.shape)
# prints: torch.Size([1000])
```
To get the top-5 predictions class names:
```python
# Get imagenet class mappings
url, filename = ("https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt", "imagenet_classes.txt")
urllib.request.urlretrieve(url, filename)
with open("imagenet_classes.txt", "r") as f:
categories = [s.strip() for s in f.readlines()]
# Print top categories per image
top5_prob, top5_catid = torch.topk(probabilities, 5)
for i in range(top5_prob.size(0)):
print(categories[top5_catid[i]], top5_prob[i].item())
# prints class names and probabilities like:
# [('Samoyed', 0.6425196528434753), ('Pomeranian', 0.04062102362513542), ('keeshond', 0.03186424449086189), ('white wolf', 0.01739676296710968), ('Eskimo dog', 0.011717947199940681)]
```
2021-03-13 02:38:10 +08:00
Replace the model name with the variant you want to use, e.g. `dla102` . You can find the IDs in the model summaries at the top of this page.
2021-03-12 00:52:13 +08:00
To extract image features with this model, follow the [timm feature extraction examples ](https://rwightman.github.io/pytorch-image-models/feature_extraction/ ), just change the name of the model you want to use.
## How do I finetune this model?
You can finetune any of the pre-trained models just by changing the classifier (the last layer).
```python
2021-03-15 03:22:59 +08:00
model = timm.create_model('dla102', pretrained=True, num_classes=NUM_FINETUNE_CLASSES)
2021-03-12 00:52:13 +08:00
```
To finetune on your own dataset, you have to write a training loop or adapt [timm's training
script](https://github.com/rwightman/pytorch-image-models/blob/master/train.py) to use your dataset.
## How do I train this model?
You can follow the [timm recipe scripts ](https://rwightman.github.io/pytorch-image-models/scripts/ ) for training a new model afresh.
## Citation
```BibTeX
@misc {yu2019deep,
title={Deep Layer Aggregation},
author={Fisher Yu and Dequan Wang and Evan Shelhamer and Trevor Darrell},
year={2019},
eprint={1707.06484},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
```
<!--
2021-03-13 02:38:10 +08:00
Type: model-index
Collections:
- Name: DLA
Paper:
Title: Deep Layer Aggregation
URL: https://paperswithcode.com/paper/deep-layer-aggregation
2021-03-12 00:52:13 +08:00
Models:
2021-03-13 02:38:10 +08:00
- Name: dla102
In Collection: DLA
2021-03-12 00:52:13 +08:00
Metadata:
2021-03-13 02:38:10 +08:00
FLOPs: 7192952808
Parameters: 33270000
File Size: 135290579
2021-03-12 00:52:13 +08:00
Architecture:
- 1x1 Convolution
- Batch Normalization
- Convolution
- DLA Bottleneck Residual Block
- DLA Residual Block
- Global Average Pooling
- Max Pooling
- ReLU
- Residual Block
- Residual Connection
- Softmax
Tasks:
- Image Classification
2021-03-13 02:38:10 +08:00
Training Techniques:
- SGD with Momentum
- Weight Decay
Training Data:
- ImageNet
Training Resources: 8x GPUs
ID: dla102
2021-03-12 00:52:13 +08:00
LR: 0.1
2021-03-13 02:38:10 +08:00
Epochs: 120
Layers: 102
2021-03-12 00:52:13 +08:00
Crop Pct: '0.875'
Momentum: 0.9
2021-03-13 02:38:10 +08:00
Batch Size: 256
2021-03-12 00:52:13 +08:00
Image Size: '224'
Weight Decay: 0.0001
Interpolation: bilinear
2021-03-13 02:38:10 +08:00
Code: https://github.com/rwightman/pytorch-image-models/blob/d8e69206be253892b2956341fea09fdebfaae4e3/timm/models/dla.py#L410
Weights: http://dl.yf.io/dla/models/imagenet/dla102-d94d9790.pth
Results:
- Task: Image Classification
Dataset: ImageNet
Metrics:
Top 1 Accuracy: 78.03%
Top 5 Accuracy: 93.95%
- Name: dla102x
2021-03-12 00:52:13 +08:00
In Collection: DLA
Metadata:
2021-03-13 02:38:10 +08:00
FLOPs: 5886821352
Parameters: 26310000
File Size: 107552695
2021-03-12 00:52:13 +08:00
Architecture:
- 1x1 Convolution
- Batch Normalization
- Convolution
- DLA Bottleneck Residual Block
- DLA Residual Block
- Global Average Pooling
- Max Pooling
- ReLU
- Residual Block
- Residual Connection
- Softmax
Tasks:
- Image Classification
2021-03-13 02:38:10 +08:00
Training Techniques:
- SGD with Momentum
- Weight Decay
Training Data:
- ImageNet
Training Resources: 8x GPUs
ID: dla102x
2021-03-12 00:52:13 +08:00
LR: 0.1
2021-03-13 02:38:10 +08:00
Epochs: 120
Layers: 102
2021-03-12 00:52:13 +08:00
Crop Pct: '0.875'
Momentum: 0.9
2021-03-13 02:38:10 +08:00
Batch Size: 256
2021-03-12 00:52:13 +08:00
Image Size: '224'
Weight Decay: 0.0001
Interpolation: bilinear
2021-03-13 02:38:10 +08:00
Code: https://github.com/rwightman/pytorch-image-models/blob/d8e69206be253892b2956341fea09fdebfaae4e3/timm/models/dla.py#L418
Weights: http://dl.yf.io/dla/models/imagenet/dla102x-ad62be81.pth
Results:
- Task: Image Classification
Dataset: ImageNet
Metrics:
Top 1 Accuracy: 78.51%
Top 5 Accuracy: 94.23%
2021-03-12 00:52:13 +08:00
- Name: dla102x2
2021-03-13 02:38:10 +08:00
In Collection: DLA
2021-03-12 00:52:13 +08:00
Metadata:
FLOPs: 9343847400
2021-03-13 02:38:10 +08:00
Parameters: 41280000
File Size: 167645295
2021-03-12 00:52:13 +08:00
Architecture:
- 1x1 Convolution
- Batch Normalization
- Convolution
- DLA Bottleneck Residual Block
- DLA Residual Block
- Global Average Pooling
- Max Pooling
- ReLU
- Residual Block
- Residual Connection
- Softmax
Tasks:
- Image Classification
2021-03-13 02:38:10 +08:00
Training Techniques:
- SGD with Momentum
- Weight Decay
Training Data:
- ImageNet
Training Resources: 8x GPUs
2021-03-12 00:52:13 +08:00
ID: dla102x2
LR: 0.1
2021-03-13 02:38:10 +08:00
Epochs: 120
2021-03-12 00:52:13 +08:00
Layers: 102
Crop Pct: '0.875'
Momentum: 0.9
2021-03-13 02:38:10 +08:00
Batch Size: 256
2021-03-12 00:52:13 +08:00
Image Size: '224'
Weight Decay: 0.0001
Interpolation: bilinear
Code: https://github.com/rwightman/pytorch-image-models/blob/d8e69206be253892b2956341fea09fdebfaae4e3/timm/models/dla.py#L426
2021-03-13 02:38:10 +08:00
Weights: http://dl.yf.io/dla/models/imagenet/dla102x2-262837b6.pth
Results:
- Task: Image Classification
Dataset: ImageNet
Metrics:
Top 1 Accuracy: 79.44%
Top 5 Accuracy: 94.65%
- Name: dla169
2021-03-12 00:52:13 +08:00
In Collection: DLA
Metadata:
2021-03-13 02:38:10 +08:00
FLOPs: 11598004200
Parameters: 53390000
File Size: 216547113
2021-03-12 00:52:13 +08:00
Architecture:
- 1x1 Convolution
- Batch Normalization
- Convolution
- DLA Bottleneck Residual Block
- DLA Residual Block
- Global Average Pooling
- Max Pooling
- ReLU
- Residual Block
- Residual Connection
- Softmax
Tasks:
- Image Classification
2021-03-13 02:38:10 +08:00
Training Techniques:
- SGD with Momentum
- Weight Decay
Training Data:
- ImageNet
Training Resources: 8x GPUs
ID: dla169
2021-03-12 00:52:13 +08:00
LR: 0.1
2021-03-13 02:38:10 +08:00
Epochs: 120
Layers: 169
2021-03-12 00:52:13 +08:00
Crop Pct: '0.875'
Momentum: 0.9
2021-03-13 02:38:10 +08:00
Batch Size: 256
2021-03-12 00:52:13 +08:00
Image Size: '224'
Weight Decay: 0.0001
Interpolation: bilinear
2021-03-13 02:38:10 +08:00
Code: https://github.com/rwightman/pytorch-image-models/blob/d8e69206be253892b2956341fea09fdebfaae4e3/timm/models/dla.py#L434
Weights: http://dl.yf.io/dla/models/imagenet/dla169-0914e092.pth
Results:
- Task: Image Classification
Dataset: ImageNet
Metrics:
Top 1 Accuracy: 78.69%
Top 5 Accuracy: 94.33%
- Name: dla34
2021-03-12 00:52:13 +08:00
In Collection: DLA
Metadata:
2021-03-13 02:38:10 +08:00
FLOPs: 3070105576
Parameters: 15740000
File Size: 63228658
2021-03-12 00:52:13 +08:00
Architecture:
- 1x1 Convolution
- Batch Normalization
- Convolution
- DLA Bottleneck Residual Block
- DLA Residual Block
- Global Average Pooling
- Max Pooling
- ReLU
- Residual Block
- Residual Connection
- Softmax
Tasks:
- Image Classification
2021-03-13 02:38:10 +08:00
Training Techniques:
- SGD with Momentum
- Weight Decay
Training Data:
- ImageNet
ID: dla34
2021-03-12 00:52:13 +08:00
LR: 0.1
2021-03-13 02:38:10 +08:00
Epochs: 120
Layers: 32
2021-03-12 00:52:13 +08:00
Crop Pct: '0.875'
Momentum: 0.9
2021-03-13 02:38:10 +08:00
Batch Size: 256
2021-03-12 00:52:13 +08:00
Image Size: '224'
Weight Decay: 0.0001
Interpolation: bilinear
2021-03-13 02:38:10 +08:00
Code: https://github.com/rwightman/pytorch-image-models/blob/d8e69206be253892b2956341fea09fdebfaae4e3/timm/models/dla.py#L362
Weights: http://dl.yf.io/dla/models/imagenet/dla34-ba72cf86.pth
Results:
- Task: Image Classification
Dataset: ImageNet
Metrics:
Top 1 Accuracy: 74.62%
Top 5 Accuracy: 92.06%
- Name: dla46_c
2021-03-12 00:52:13 +08:00
In Collection: DLA
Metadata:
2021-03-13 02:38:10 +08:00
FLOPs: 583277288
Parameters: 1300000
File Size: 5307963
2021-03-12 00:52:13 +08:00
Architecture:
- 1x1 Convolution
- Batch Normalization
- Convolution
- DLA Bottleneck Residual Block
- DLA Residual Block
- Global Average Pooling
- Max Pooling
- ReLU
- Residual Block
- Residual Connection
- Softmax
Tasks:
- Image Classification
2021-03-13 02:38:10 +08:00
Training Techniques:
- SGD with Momentum
- Weight Decay
Training Data:
- ImageNet
ID: dla46_c
2021-03-12 00:52:13 +08:00
LR: 0.1
2021-03-13 02:38:10 +08:00
Epochs: 120
Layers: 46
2021-03-12 00:52:13 +08:00
Crop Pct: '0.875'
Momentum: 0.9
2021-03-13 02:38:10 +08:00
Batch Size: 256
2021-03-12 00:52:13 +08:00
Image Size: '224'
Weight Decay: 0.0001
Interpolation: bilinear
2021-03-13 02:38:10 +08:00
Code: https://github.com/rwightman/pytorch-image-models/blob/d8e69206be253892b2956341fea09fdebfaae4e3/timm/models/dla.py#L369
Weights: http://dl.yf.io/dla/models/imagenet/dla46_c-2bfd52c3.pth
Results:
- Task: Image Classification
Dataset: ImageNet
Metrics:
Top 1 Accuracy: 64.87%
Top 5 Accuracy: 86.29%
2021-03-12 00:52:13 +08:00
- Name: dla46x_c
2021-03-13 02:38:10 +08:00
In Collection: DLA
2021-03-12 00:52:13 +08:00
Metadata:
FLOPs: 544052200
2021-03-13 02:38:10 +08:00
Parameters: 1070000
File Size: 4387641
2021-03-12 00:52:13 +08:00
Architecture:
- 1x1 Convolution
- Batch Normalization
- Convolution
- DLA Bottleneck Residual Block
- DLA Residual Block
- Global Average Pooling
- Max Pooling
- ReLU
- Residual Block
- Residual Connection
- Softmax
Tasks:
- Image Classification
2021-03-13 02:38:10 +08:00
Training Techniques:
- SGD with Momentum
- Weight Decay
Training Data:
- ImageNet
2021-03-12 00:52:13 +08:00
ID: dla46x_c
LR: 0.1
2021-03-13 02:38:10 +08:00
Epochs: 120
2021-03-12 00:52:13 +08:00
Layers: 46
Crop Pct: '0.875'
Momentum: 0.9
2021-03-13 02:38:10 +08:00
Batch Size: 256
2021-03-12 00:52:13 +08:00
Image Size: '224'
Weight Decay: 0.0001
Interpolation: bilinear
Code: https://github.com/rwightman/pytorch-image-models/blob/d8e69206be253892b2956341fea09fdebfaae4e3/timm/models/dla.py#L378
2021-03-13 02:38:10 +08:00
Weights: http://dl.yf.io/dla/models/imagenet/dla46x_c-d761bae7.pth
Results:
- Task: Image Classification
Dataset: ImageNet
Metrics:
Top 1 Accuracy: 65.98%
Top 5 Accuracy: 86.99%
- Name: dla60
2021-03-12 00:52:13 +08:00
In Collection: DLA
Metadata:
2021-03-13 02:38:10 +08:00
FLOPs: 4256251880
Parameters: 22040000
File Size: 89560235
2021-03-12 00:52:13 +08:00
Architecture:
- 1x1 Convolution
- Batch Normalization
- Convolution
- DLA Bottleneck Residual Block
- DLA Residual Block
- Global Average Pooling
- Max Pooling
- ReLU
- Residual Block
- Residual Connection
- Softmax
Tasks:
- Image Classification
2021-03-13 02:38:10 +08:00
Training Techniques:
- SGD with Momentum
- Weight Decay
Training Data:
- ImageNet
ID: dla60
LR: 0.1
Epochs: 120
2021-03-12 00:52:13 +08:00
Layers: 60
2021-03-13 02:38:10 +08:00
Dropout: 0.2
2021-03-12 00:52:13 +08:00
Crop Pct: '0.875'
2021-03-13 02:38:10 +08:00
Momentum: 0.9
Batch Size: 256
2021-03-12 00:52:13 +08:00
Image Size: '224'
2021-03-13 02:38:10 +08:00
Weight Decay: 0.0001
2021-03-12 00:52:13 +08:00
Interpolation: bilinear
2021-03-13 02:38:10 +08:00
Code: https://github.com/rwightman/pytorch-image-models/blob/d8e69206be253892b2956341fea09fdebfaae4e3/timm/models/dla.py#L394
Weights: http://dl.yf.io/dla/models/imagenet/dla60-24839fc4.pth
Results:
- Task: Image Classification
Dataset: ImageNet
Metrics:
Top 1 Accuracy: 77.04%
Top 5 Accuracy: 93.32%
- Name: dla60_res2net
2021-03-12 00:52:13 +08:00
In Collection: DLA
Metadata:
2021-03-13 02:38:10 +08:00
FLOPs: 4147578504
Parameters: 20850000
File Size: 84886593
2021-03-12 00:52:13 +08:00
Architecture:
- 1x1 Convolution
- Batch Normalization
- Convolution
- DLA Bottleneck Residual Block
- DLA Residual Block
- Global Average Pooling
- Max Pooling
- ReLU
- Residual Block
- Residual Connection
- Softmax
Tasks:
- Image Classification
2021-03-13 02:38:10 +08:00
Training Techniques:
- SGD with Momentum
- Weight Decay
Training Data:
- ImageNet
ID: dla60_res2net
2021-03-12 00:52:13 +08:00
Layers: 60
Crop Pct: '0.875'
Image Size: '224'
Interpolation: bilinear
2021-03-13 02:38:10 +08:00
Code: https://github.com/rwightman/pytorch-image-models/blob/d8e69206be253892b2956341fea09fdebfaae4e3/timm/models/dla.py#L346
Weights: https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-res2net/res2net_dla60_4s-d88db7f9.pth
Results:
- Task: Image Classification
Dataset: ImageNet
Metrics:
Top 1 Accuracy: 78.46%
Top 5 Accuracy: 94.21%
- Name: dla60_res2next
2021-03-12 00:52:13 +08:00
In Collection: DLA
Metadata:
2021-03-13 02:38:10 +08:00
FLOPs: 3485335272
Parameters: 17030000
File Size: 69639245
2021-03-12 00:52:13 +08:00
Architecture:
- 1x1 Convolution
- Batch Normalization
- Convolution
- DLA Bottleneck Residual Block
- DLA Residual Block
- Global Average Pooling
- Max Pooling
- ReLU
- Residual Block
- Residual Connection
- Softmax
Tasks:
- Image Classification
2021-03-13 02:38:10 +08:00
Training Techniques:
- SGD with Momentum
- Weight Decay
Training Data:
- ImageNet
ID: dla60_res2next
Layers: 60
2021-03-12 00:52:13 +08:00
Crop Pct: '0.875'
Image Size: '224'
Interpolation: bilinear
2021-03-13 02:38:10 +08:00
Code: https://github.com/rwightman/pytorch-image-models/blob/d8e69206be253892b2956341fea09fdebfaae4e3/timm/models/dla.py#L354
Weights: https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-res2net/res2next_dla60_4s-d327927b.pth
Results:
- Task: Image Classification
Dataset: ImageNet
Metrics:
Top 1 Accuracy: 78.44%
Top 5 Accuracy: 94.16%
2021-03-12 00:52:13 +08:00
- Name: dla60x
2021-03-13 02:38:10 +08:00
In Collection: DLA
2021-03-12 00:52:13 +08:00
Metadata:
FLOPs: 3544204264
2021-03-13 02:38:10 +08:00
Parameters: 17350000
File Size: 70883139
2021-03-12 00:52:13 +08:00
Architecture:
- 1x1 Convolution
- Batch Normalization
- Convolution
- DLA Bottleneck Residual Block
- DLA Residual Block
- Global Average Pooling
- Max Pooling
- ReLU
- Residual Block
- Residual Connection
- Softmax
Tasks:
- Image Classification
2021-03-13 02:38:10 +08:00
Training Techniques:
- SGD with Momentum
- Weight Decay
Training Data:
- ImageNet
2021-03-12 00:52:13 +08:00
ID: dla60x
LR: 0.1
2021-03-13 02:38:10 +08:00
Epochs: 120
2021-03-12 00:52:13 +08:00
Layers: 60
Crop Pct: '0.875'
Momentum: 0.9
2021-03-13 02:38:10 +08:00
Batch Size: 256
2021-03-12 00:52:13 +08:00
Image Size: '224'
Weight Decay: 0.0001
Interpolation: bilinear
Code: https://github.com/rwightman/pytorch-image-models/blob/d8e69206be253892b2956341fea09fdebfaae4e3/timm/models/dla.py#L402
2021-03-13 02:38:10 +08:00
Weights: http://dl.yf.io/dla/models/imagenet/dla60x-d15cacda.pth
Results:
- Task: Image Classification
Dataset: ImageNet
Metrics:
Top 1 Accuracy: 78.25%
Top 5 Accuracy: 94.02%
2021-03-12 00:52:13 +08:00
- Name: dla60x_c
2021-03-13 02:38:10 +08:00
In Collection: DLA
2021-03-12 00:52:13 +08:00
Metadata:
FLOPs: 593325032
2021-03-13 02:38:10 +08:00
Parameters: 1320000
File Size: 5454396
2021-03-12 00:52:13 +08:00
Architecture:
- 1x1 Convolution
- Batch Normalization
- Convolution
- DLA Bottleneck Residual Block
- DLA Residual Block
- Global Average Pooling
- Max Pooling
- ReLU
- Residual Block
- Residual Connection
- Softmax
Tasks:
- Image Classification
2021-03-13 02:38:10 +08:00
Training Techniques:
- SGD with Momentum
- Weight Decay
Training Data:
- ImageNet
2021-03-12 00:52:13 +08:00
ID: dla60x_c
LR: 0.1
2021-03-13 02:38:10 +08:00
Epochs: 120
2021-03-12 00:52:13 +08:00
Layers: 60
Crop Pct: '0.875'
Momentum: 0.9
2021-03-13 02:38:10 +08:00
Batch Size: 256
2021-03-12 00:52:13 +08:00
Image Size: '224'
Weight Decay: 0.0001
Interpolation: bilinear
Code: https://github.com/rwightman/pytorch-image-models/blob/d8e69206be253892b2956341fea09fdebfaae4e3/timm/models/dla.py#L386
2021-03-13 02:38:10 +08:00
Weights: http://dl.yf.io/dla/models/imagenet/dla60x_c-b870c45c.pth
Results:
- Task: Image Classification
Dataset: ImageNet
Metrics:
Top 1 Accuracy: 67.91%
Top 5 Accuracy: 88.42%
2021-03-12 00:52:13 +08:00
-->