Spaces:
Sleeping
Sleeping
Alex Hortua
commited on
Commit
Β·
2add545
1
Parent(s):
1f4fef5
Unfreeze model and allocate 3 blocks of Resnet50 by default to retrain
Browse files- README.md +13 -0
- config.yaml +3 -2
- src/train.py +4 -4
README.md
CHANGED
@@ -94,6 +94,19 @@ evaluation:
|
|
94 |
iou_threshold: 0.5
|
95 |
```
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
---
|
98 |
|
99 |
## π‘ **Evaluating the Model**
|
|
|
94 |
iou_threshold: 0.5
|
95 |
```
|
96 |
|
97 |
+
---
|
98 |
+
|
99 |
+
## π **Training Strategies for Faster R-CNN with ResNet-50 Backbone**
|
100 |
+
|
101 |
+
| Trainable Backbone Layers | Epochs | Batch Size | Recommended Learning Rate | Optimizer | Scheduler |
|
102 |
+
|--------------------------|--------|-----------|--------------------------|-----------|------------------|
|
103 |
+
| 0 | 10 | 4 | 0.0100 | SGD | StepLR(3, 0.1) |
|
104 |
+
| 3 | 10 | 8 | 0.0050 | SGD | StepLR(3, 0.1) |
|
105 |
+
| 5 | 10 | 16 | 0.0001 | AdamW | CosineAnnealing |
|
106 |
+
| 3 | 20 | 8 | 0.0050 | SGD | StepLR(5, 0.1) |
|
107 |
+
| 5 | 20 | 16 | 0.0001 | AdamW | CosineAnnealing |
|
108 |
+
|
109 |
+
|
110 |
---
|
111 |
|
112 |
## π‘ **Evaluating the Model**
|
config.yaml
CHANGED
@@ -2,11 +2,12 @@ model:
|
|
2 |
backbone: resnet50
|
3 |
num_classes: 2
|
4 |
pretrained: true
|
5 |
-
learning_rate:
|
6 |
-
epochs:
|
7 |
batch_size: 8
|
8 |
optimizer: adam
|
9 |
image_sample_size: 10
|
|
|
10 |
|
11 |
dataset:
|
12 |
image_dir: datasets/images
|
|
|
2 |
backbone: resnet50
|
3 |
num_classes: 2
|
4 |
pretrained: true
|
5 |
+
learning_rate: 0.0050
|
6 |
+
epochs: 10
|
7 |
batch_size: 8
|
8 |
optimizer: adam
|
9 |
image_sample_size: 10
|
10 |
+
trainable_backbone_layers: 3
|
11 |
|
12 |
dataset:
|
13 |
image_dir: datasets/images
|
src/train.py
CHANGED
@@ -15,11 +15,11 @@ with open("config.yaml", "r") as f:
|
|
15 |
config = yaml.safe_load(f)
|
16 |
|
17 |
# Load Pretrained Model
|
18 |
-
model = torchvision.models.detection.fasterrcnn_resnet50_fpn(weights="DEFAULT")
|
19 |
|
20 |
-
# Freeze Backbone
|
21 |
-
for param in model.backbone.parameters():
|
22 |
-
|
23 |
|
24 |
# Modify Predictor
|
25 |
num_classes = config["model"]["num_classes"]
|
|
|
15 |
config = yaml.safe_load(f)
|
16 |
|
17 |
# Load Pretrained Model
|
18 |
+
model = torchvision.models.detection.fasterrcnn_resnet50_fpn(weights="DEFAULT", trainable_backbone_layers=config["model"]["trainable_backbone_layers"])
|
19 |
|
20 |
+
# # Freeze Backbone
|
21 |
+
# for param in model.backbone.parameters():
|
22 |
+
# param.requires_grad = False
|
23 |
|
24 |
# Modify Predictor
|
25 |
num_classes = config["model"]["num_classes"]
|