Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
4"""MobileNetV2 U-Net model for image segmentation
6The MobileNetV2 architecture is based on an inverted residual structure where
7the input and output of the residual block are thin bottleneck layers opposite
8to traditional residual models which use expanded representations in the input
9an MobileNetV2 uses lightweight depthwise convolutions to filter features in
10the intermediate expansion layer. This model implements a MobileNetV2 U-Net
11model, henceforth named M2U-Net, combining the strenghts of U-Net for medical
12segmentation applications and the speed of MobileNetV2 networks.
14References: [SANDLER-2018]_, [RONNEBERGER-2015]_
15"""
17from torch.optim.lr_scheduler import MultiStepLR
19from bob.ip.binseg.engine.adabound import AdaBound
20from bob.ip.binseg.models.losses import SoftJaccardBCELogitsLoss
21from bob.ip.binseg.models.m2unet import m2unet
23# config
24lr = 0.001
25betas = (0.9, 0.999)
26eps = 1e-08
27weight_decay = 0
28final_lr = 0.1
29gamma = 1e-3
30eps = 1e-8
31amsbound = False
33scheduler_milestones = [900]
34scheduler_gamma = 0.1
36model = m2unet()
38# optimizer
39optimizer = AdaBound(
40 model.parameters(),
41 lr=lr,
42 betas=betas,
43 final_lr=final_lr,
44 gamma=gamma,
45 eps=eps,
46 weight_decay=weight_decay,
47 amsbound=amsbound,
48)
50# criterion
51criterion = SoftJaccardBCELogitsLoss(alpha=0.7)
53# scheduler
54scheduler = MultiStepLR(
55 optimizer, milestones=scheduler_milestones, gamma=scheduler_gamma
56)