Skip to content

Commit

Permalink
fix #169 by constructing pretrained backbone correctly (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzoh authored Sep 17, 2021
1 parent e0a5538 commit ea6c096
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion notebooks/imagesegmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@
"outputs": [],
"source": [
"using Metalhead\n",
"backbone = Metalhead.ResNet50(pretrain=true).layers[1:end-3]\n",
"backbone = Metalhead.ResNet50(pretrain=true).layers[1][1:end-1]\n",
"model = methodmodel(method, backbone);"
]
},
Expand Down
2 changes: 1 addition & 1 deletion notebooks/keypointregression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@
"source": [
"using Metalhead\n",
"\n",
"backbone = Metalhead.ResNet50(pretrain=true).layers[1:end-3]\n",
"backbone = Metalhead.ResNet50(pretrain=true).layers[1][1:end-1]\n",
"model = methodmodel(method, backbone);"
]
},
Expand Down
2 changes: 1 addition & 1 deletion notebooks/serialization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
" )\n",
")\n",
"\n",
"backbone = Metalhead.ResNet50(pretrain=true).layers[1:end-3]\n",
"backbone = Metalhead.ResNet50(pretrain=true).layers[1][1:end-1]\n",
"learner = methodlearner(method, data; backbone=backbone, callbacks=[ToGPU(), Metrics(accuracy)])\n",
"finetune!(learner, 3)"
]
Expand Down
4 changes: 2 additions & 2 deletions notebooks/siamese.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@
"source": [
"using Metalhead\n",
"encoder = Models.xresnet18()\n",
"encoder = Metalhead.ResNet50(pretrain=true).layers[1:end-3]\n",
"encoder = Metalhead.ResNet50(pretrain=true).layers[1][1:end-1]\n",
"h, w, ch, b = Flux.outputsize(encoder, (128, 128, 3, 1))"
]
},
Expand Down Expand Up @@ -961,7 +961,7 @@
}
],
"source": [
"encoder = Metalhead.ResNet50(pretrain=true).layers[1:end-3]\n",
"encoder = Metalhead.ResNet50(pretrain=true).layers[1][1:end-1]\n",
"h, w, ch, b = Flux.outputsize(encoder, (128, 128, 3, 1))\n",
"head = Models.visionhead(2ch, 2)\n",
"model = SiameseModel(encoder, head);\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/training.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@
"data, blocks = loaddataset(\"imagenette2-160\", (Image, Label))\n",
"method = ImageClassificationSingle(blocks)\n",
"learner = methodlearner(method, data;\n",
" backbone=Metalhead.ResNet50(pretrain=true).layers[1:end-3],\n",
" backbone=Metalhead.ResNet50(pretrain=true).layers[1][1:end-1],\n",
" callbacks=[ToGPU(), Metrics(accuracy)])\n",
"finetune!(learner, 5, 0.0005)"
]
Expand Down
2 changes: 1 addition & 1 deletion src/models/unet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ the same spatial output dimensions as its input.
```julia
using FastAI, Metalhead
backbone = Metalhead.ResNet50(pretrain=true).layers[1:end-3]
backbone = Metalhead.ResNet50(pretrain=true).layers[1][1:end-1]
unet = UNetDynamic(backbone, (256, 256, 3, 1); k_out = 10)
Flux.outputsize(unet, (256, 256, 3, 1)) == (256, 256, 10, 1)
Expand Down

0 comments on commit ea6c096

Please sign in to comment.