keras-cv icon indicating copy to clipboard operation
keras-cv copied to clipboard

Convolutional Block Attention Module

Open innat opened this issue 3 years ago • 4 comments

https://arxiv.org/abs/1807.06521 Cited by 4701

innat avatar Apr 16 '22 23:04 innat

https://github.com/tensorflow/models/blob/master/official/vision/beta/projects/yolo/modeling/layers/nn_blocks.py#L1333

bhack avatar Apr 16 '22 23:04 bhack

Yep, highly cited and used. makes sense; perhaps as a part of the upoming training templates effort.

LukeWood avatar Apr 21 '22 06:04 LukeWood

Hi @LukeWood @innat I would like to work on this! I was thinking of something like this

def attach_attention_module(net, attention_module):
  if attention_module == 'se_block': # SE_block
    net = se_block(net)
  elif attention_module == 'bam_block': # BAM_block
    net = cbam_block(net)
  elif attention_module == 'cbam_block': # CBAM_block
    net = cbam_block(net)
  elif attention_module == 'gala_block': # GALA_block
    net = cbam_block(net)
  else:
    raise Exception(f"{attention_module} is not supported attention module.")
  return net

We can also give option to pass their own attention module. Thoghts?

old-school-kid avatar Jun 30 '22 06:06 old-school-kid

@old-school-kid That would be cool. But I think according to keras design, it might want to include a separate class for each.. (SE block in currently in progress https://github.com/keras-team/keras-cv/pull/505).

innat avatar Jun 30 '22 08:06 innat

Now at https://github.com/tensorflow/models/blob/master/official/vision/modeling/layers/nn_blocks.py

bhack avatar Oct 18 '22 15:10 bhack

Thanks for your enthusiasm @GLOMQuyet !

Apologies for shifting priorities and changes in terms of what we are interested in merging. We've done a lot of work to figure out exactly what our value add to users is, what components we want to offer as APIs, and we don't want to offer as APIs in the last few years. For now, I think closing this PR makes sense and if models need this component we can implement this style layer alongside the model.

This usually has to happen to match exact numerics of architectures anyways. For now lets close, and if theres a super strong user need to fill we can re-open.

LukeWood avatar Apr 26 '23 22:04 LukeWood